0

我正在尝试让 Bluemix Cordova Hello World 示例与 IBMPushNotifications Service 一起使用。我已经安装了科尔多瓦插件,如果我运行科尔多瓦插件列表,我会看到:

ibm-mfp-core 1.0.10 "MFPCore"
ibm-mfp-push 1.0.12 "MFPPush"

我的 index.js 初始化代码如下所示:

  onDeviceReady: function() {
    BMSClient.initialize(app.route, app.guid);
    BMSClient.registerAuthenticationListener("MyRealm", customAuthenticationListener);
   // alert("******** ABOUT TO CALL MFPPush.registerDevice **************");
  // MFPPush.registerDevice(iosPushSettings, pushSuccess, pushFailure); 
    MFPPush.registerDevice({}, pushSuccess, pushFailure);

我确实有 MAS customAuthentication 服务正在运行和工作。

我正在通过 Xcode 在连接的 iPad 上运行代码。我在插件 swift 文件中添加了一些 debugPrint 语句,并在 Xcode 控制台中看到以下消息:

"Inside Register Device!!!!!!!"
"Inside registerNotificationsCallback"
"Settings Parameter is not null"
"settings.count == 0"
"about to set notificationSettings"
"About to registerForRemoteNotifications"
"Called registerForRemoteNotifications"

我不是 swift 或 iOS 开发人员,所以我对调试和使用 iOS 应用程序一无所知。我试图在AppDelegate.m文件中设置断点,并且似乎代码正在达到断点,didRegisterForRemoteNotificationsWithDeviceToken并且我认为正在设置令牌值。但是,我从来没有看到我的 debugPrint 代码在CDVMFPPush.swift里面的文件中被触发

 func didRegisterForRemoteNotifications(deviceToken: NSData) {
    debugPrint("Inside didRegisterForRemoteNotifications")

或在里面

 func didFailToRegisterForRemoteNotifications(error: NSError) {

debugPrint("Inside didFailToRegisterForRemoteNotifications")

据我所知,我已经设置了 APNS 证书和供应配置文件,并且我已经将我的sandboxAPNS.p12文件上传到了我的 Bluemix Push 服务中,并且没有任何错误。

在 Bluemix Push Dashboard 上,如果我尝试向所有设备发送推送通知,我会收到以下错误:

Internal server error. No devices found

我还在 XCode 中的应用程序的功能选项卡中看到启用了 PushNotifications。

我试图确定为什么我从来没有看到我的 debugPrint 语句,didRegister或者didFailToRegister为什么 Bluemix 没有看到我的设备。感谢您提供有关如何调试的任何建议,并再次为我对 swift 和 XCode 的无知表示歉意。

捷通

4

1 回答 1

1

好的,我得到了推送通知。事实证明,我需要根据文档和 Git 自述文件修改 AppDelegate.m 文件:

    // Register device token with Bluemix Push Notification Service
- (void)application:(UIApplication *)application
     didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{

     [[CDVMFPPush sharedInstance] didRegisterForRemoteNotifications:deviceToken];
}

// Handle error when failed to register device token with APNs
- (void)application:(UIApplication*)application
     didFailToRegisterForRemoteNotificationsWithError:(NSError*)error {

    [[CDVMFPPush sharedInstance] didFailToRegisterForRemoteNotifications:error];
}

// Handle receiving a remote notification
-(void)application:(UIApplication *)application 
    didReceiveRemoteNotification:(NSDictionary *)userInfo 
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {

    [[CDVMFPPush sharedInstance] didReceiveRemoteNotification:userInfo];
}
于 2016-02-07T19:27:19.223 回答