【问题标题】:Bluemix Cordova iOS Push notifications - Don't see device - Internal server error. No devices foundBluemix Cordova iOS 推送通知 - 看不到设备 - 内部服务器错误。未找到设备
【发布时间】:2016-02-07 18:37:36
【问题描述】:

我正在尝试让 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。

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

JT

【问题讨论】:

    标签: swift cordova push-notification ibm-cloud ibm-mobile-services


    【解决方案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];
    }
    

    【讨论】:

    • 比尔,谢谢你清理它:-)。
    猜你喜欢
    • 2023-03-26
    • 1970-01-01
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多