目前,我坐在一些空的deviceToken字段中。我发现这是因为在创建安装对象之前添加组存在问题 - 它会阻止后续的创建工作。
我现在要做的是再次获取deviceToken并在Parse中更新它,但问题是,didRegisterForRemoteNotificationsWithDeviceToken
在第一次之后永远不会再次运行...
在初次调用didRegisterForRemoteNotificationsWithDeviceToken
之后获取设备令牌的任何方法?
答案 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
的委托回调。