注册后更新解析deviceToken

时间:2015-07-14 11:22:11

标签: ios swift parse-platform push-notification apple-push-notifications

目前,我坐在一些空的deviceToken字段中。我发现这是因为在创建安装对象之前添加组存在问题 - 它会阻止后续的创建工作。

我现在要做的是再次获取deviceToken并在Parse中更新它,但问题是,didRegisterForRemoteNotificationsWithDeviceToken在第一次之后永远不会再次运行...

在初次调用didRegisterForRemoteNotificationsWithDeviceToken之后获取设备令牌的任何方法?

2 个答案:

答案 0 :(得分:0)

这适用于iOS 8:

Enum.reduce/3

答案 1 :(得分:-1)

可以重复调用

didRegisterForRemoteNotificationsWithDeviceToken。只需在方法AppDelegate.m中调用didFinishLaunchingWithOptions中的推送注册码即可。

以下是我使用的内容:

//Check for iOS 7 vs 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
    [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
}

就是这样 - 如果你每次调用它,你将在每次加载时获得didRegisterForRemoteNotificationsWithDeviceToken的委托回调。