简体   繁体   English

尝试将设备注册到Bluemix上的IBM Mobile First Push服务时,iOS应用程序崩溃

[英]iOS Application crashes when trying to register the device to IBM Mobile First Push service on Bluemix

I have an iOS 9 application running on an iPad mini 4 (iOS 9.0.2). 我有一个在iPad mini 4(iOS 9.0.2)上运行的iOS 9应用程序。 It crashes when trying to register the device to my IMFPush service instance on Bluemix. 尝试在Bluemix上将设备注册到我的IMFPush服务实例时崩溃。

Here is the code that performs the registration in my App delegate: 这是在我的App委托中执行注册的代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Push notifications
    let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Badge, UIUserNotificationType.Alert, UIUserNotificationType.Sound]
    let notificationSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
    application.registerUserNotificationSettings(notificationSettings)
    application.registerForRemoteNotifications()
    return true
}

func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
    // Initialize the Mobile First SDK with IBM Bluemix GUID and route
    IMFClient.sharedInstance().initializeWithBackendRoute(MY_APP_ROUTE_HERE, backendGUID: MY_BACKEND_GUID_HERE)
    let push = IMFPushClient.sharedInstance()
    print("-> Register device token to Mobile First Push for iOS8 Service \(IMFPush.version())");
    push.registerDeviceToken(deviceToken, completionHandler: { (response, error) -> Void in
        if error != nil {
            print("-> Error during device registration to Mobile First Push for iOS8 Service \(error.description)")
        }
        else {
            print("-> Response after device registration (json): \(response.responseJson.description)")
        }
    })
}

And here is the console output when running the app (that crashes on startup): 这是运行应用程序时的控制台输出(启动时崩溃):

-> Register device token to Mobile First Push for iOS8 Service 1.0
2015-10-07 09:53:52.895 greenwell[578:152833] [INFO] [IMFPushClient] -[IMFPushClient registerDeviceToken:completionHandler:] in IMFPushClient.m:70 :: Verifying previous device registration.
2015-10-07 09:53:52.900 greenwell[578:152833] [WARN] [IMF] -[IMFAuthorizationManager cachedAuthorizationHeader] in IMFAuthorizationManager.m:447 :: There is no cached authorization header, use obtainAuthorizationHeaderWithCompletionHandler to get the header
2015-10-07 09:53:52.969 greenwell[578:152833] +[IMFResponse responseWithWLResponse:]: unrecognized selector sent to class 0x100113b48
2015-10-07 09:53:52.969 greenwell[578:152833] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[IMFResponse responseWithWLResponse:]: unrecognized selector sent to class 0x100113b48'
*** First throw call stack:
(0x185e98f5c 0x19a897f80 0x185e9fb64 0x185e9cc14 0x185da0dcc 0x10009c088 0x100093648 0x1000923fc 0x100099cb4 0x101315d70 0x101315d30 0x10131b780 0x185e50258 0x185e4e0c0 0x185d7cdc0 0x190d10088 0x18b456f44 0x10004d744 0x19b0b68b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

Any idea of the issue and how to fix it ? 对这个问题有什么想法,以及如何解决? Thanks for your help... 谢谢你的帮助...

Make sure that your client application is being compiled with the -ObjC flag. 确保正在使用-ObjC标志编译客户端应用程序。

This setting can added under your target's Build Settings>Linking>Other Linker Flags section. 可以在目标的“ 构建设置”>“链接”>“其他链接器标志”部分下添加此设置。

Double-click the existing settings and click the + sign. 双击现有设置,然后单击+号。 Then add "-ObjC" in the text field. 然后在文本字段中添加“ -ObjC”。 This can be accomplished for both Debug and Release settings. 对于“调试”和“发布”设置都可以完成。

Further information can be found regarding this setting from Apple's Q&A session covering Building Objective-C static libraries with categories 在Apple的问答环节中可以找到有关此设置的更多信息,内容涉及使用类别构建Building Objective-C静态库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM