简体   繁体   中英

IBM-Bluemix Push Service on iOS crashes app when first registering with the service

I'm using the new push-notification service on bluemix, with an iOS device.

The device registers successfully. When I check with the REST-API, I see the device-ID, token and so on.

However, running the iOS-app on the device crashes the app on first run and registration.

The crash happens in CDVMFPPush.swift in func didRegisterForRemoteNotifications(deviceToken: NSData) on line 309 ( let pushToken = response.responseJson["token"] as! String ).

I did a print(response) in this function and it seems that responseJson only contains the deviceId and the userId. The token is missing. When I use the REST-Api again to do the same request, the response seems to be complete.

I think that because of this error the push registration doesn't finish, as I don't receive any notifications when I try to run the service in sandbox-mode.

Any ideas?

(PS I checked this solution - iOS Application crashes when trying to register the device to IBM Mobile First Push service on Bluemix - the linker flag is set [-ObjC])

Here's the request from my console (app-id/secret/device is edited)

Response text: {"createdTime":"2016-06-07T15:28:55Z","lastUpdatedTime":"2016-06-07T15:28:55Z","createdMode":"API","deviceId":"xxxx","userId":"","token":"xxxx","platform":"A","href":"https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx"}
httpStatus: 201
responseHeaders: {
    Connection = "Keep-Alive";
    "Content-Type" = "application/json";
    Date = "Tue, 07 Jun 2016 15:28:55 GMT";
    Location = "https://myapp.mybluemix.net:443/imfpush/v1/apps/xxxx/devices/xxxx";
    "Transfer-Encoding" = Identity;
    "X-Backside-Transport" = "OK OK";
    "X-Global-Transaction-ID" = xxxx;
    "X-Powered-By" = "Servlet/3.0";
}
responseJson: {
    deviceId = "xxxxx";
    userId = "";
}

We've updated the MFPPush iOS Framework to resolve the issue and the MFPPush Cordova Plugin has been updated to incorporate these fixes. We suspect the crashes were caused by the fact that you were being sent a second IMFResponse object through the callback and this second IMFResponse's responseJson didn't have the token as you saw which was resulting in the crash. These changes should resolve that issue.

Easiest way to update the plugin is just to remove the old and re-add it, you should be on version 1.0.14 of ibm-mfp-push to see the fixes.

Can see the update on the related Github as of this morning as well https://github.com/ibm-bluemix-mobile-services/bms-clientsdk-cordova-plugin-push

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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