简体   繁体   English

Bluemix Cordova iOS推送通知-看不到设备-内部服务器错误。 找不到设备

[英]Bluemix Cordova iOS Push notifications - Don't see device - Internal server error. No devices found

I am trying to get the Bluemix Cordova Hello World sample working with IBMPushNotifications Service. 我正在尝试与IBMPushNotifications Service一起使用Bluemix Cordova Hello World示例。 I have installed the cordova plugins and if I run cordova plugin list I see: 我已经安装了cordova插件,如果我运行cordova插件列表,我会看到:

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

My index.js initialization code looks like this: 我的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);

I do have the MAS customAuthentication service running and working. 我确实正在运行MAS customAuthentication服务。

I am running the code on an attached iPad via Xcode. 我正在通过Xcode在连接的iPad上运行代码。 I've added some debugPrint statements inside the plugin swift file and see the following messages in the Xcode Console: 我在插件swift文件中添加了一些debugPrint语句,并在Xcode Console中看到以下消息:

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

I am not a swift or iOS developer, so I am pretty ignorant on debugging and working with iOS apps. 我不是敏捷开发人员,也不是iOS开发人员,因此我对调试和使用iOS应用程序一无所知。 I tried to set breakpoints in the AppDelegate.m file and appears that the code is hitting the breakpoint in didRegisterForRemoteNotificationsWithDeviceToken and I think a token value is getting set. 我试图在AppDelegate.m文件中设置断点,并且似乎代码在didRegisterForRemoteNotificationsWithDeviceToken命中了断点,并且我认为正在设置令牌值。 However, I never see my debugPrint code getting triggered in the CDVMFPPush.swift file inside 但是,我从未在CDVMFPPush.swift文件中看到我的debugPrint代码被触发

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

or inside 或里面

 func didFailToRegisterForRemoteNotifications(error: NSError) {

debugPrint("Inside didFailToRegisterForRemoteNotifications")

As far as I can tell, I have set up the APNS Cert and provisioning profile and I have uploaded my sandboxAPNS.p12 file without any errors into my Bluemix Push service. 据我所知,我已经设置了APNS证书和供应配置文件,并且已经将我的sandboxAPNS.p12文件上传到我的Bluemix Push服务中,没有任何错误。

On the Bluemix Push Dashboard, if I try to send a push notification to all devices, I receive the following error: 在Bluemix推送仪表板上,如果我尝试向所有设备发送推送通知,则会收到以下错误:

Internal server error. No devices found

I also see PushNotifications enabled in the capabilities tab for my app in XCode. 我还在XCode中为我的应用程序的功能选项卡中看到启用了PushNotifications。

I am trying to determine why I never see my debugPrint statements for the didRegister or didFailToRegister and why Bluemix does not see my device. 我试图确定为什么我永远都看不到didRegisterdidFailToRegister debugPrint语句,以及为什么Bluemix无法看到我的设备。 Thanks for any suggestions on how to debug and again my apologies for my ignorance on swift and XCode. 感谢您提供有关如何调试的建议,并再次感谢您对swift和XCode的不了解。

JT 日本电信

OK, I got Push notifications working. 好的,我收到了推送通知。 It turns out I needed to modify the AppDelegate.m file as per the docs and the Git readme: 事实证明,我需要根据文档和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];
}

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

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