Parse.com deviceToken and PFInstallation not saved

杀马特。学长 韩版系。学妹 提交于 2020-01-02 04:52:05

问题


I am encountering a weird behavior of the PFInstallation of my iOS App. On every app launch I am registering the device to receive push notifications and calling the below code on the method didRegisterForRemoteNotificationsWithDeviceToken:

PFInstallation *currentInstallation = [PFInstallation currentInstallation];

[currentInstallation setDeviceTokenFromData:deviceToken];

NSLog(@"%@", currentInstallation );

[currentInstallation saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
    if (succeeded) {

        NSLog(@"currentInstallation saved" );

    }

    if (error) {

        NSLog(@"currentInstallation NOT saved" );

    }
}];

When I install the app on my iphone the installation is saved correctly with its deviceToken. I am absolutely sure that some days ago i was manually deleting the deviceToken through the Parse Dashboard (to try out things) then on app re-launch the device token was saved correctly again. Same thing for some channels I was using. Today the deviceToken is not being saved, nor the channels. The saveInBackgroundWithBlock succeeds but the deviceToken field is empty. The NSLog of the currentInstallation contains the deviceToken, but it's not saved. While trying to understand the reason for this behavior i found out that if I add the line currentInstallation.deviceToken = @""; just after PFInstallation *currentInstallation = [PFInstallation currentInstallation]; then the deviceToken gets saved correctly. Consume Parse guru explain to me why this is happening and why some days ago it wasn't? I recently upgraded the Parse Framework on this app, can that be the reason?

来源:https://stackoverflow.com/questions/31116849/parse-com-devicetoken-and-pfinstallation-not-saved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!