【发布时间】:2016-02-26 21:56:53
【问题描述】:
我收到了 3 个内容相同的推送通知。 一开始我认为我收到了重复的推送通知。
但我发现这个推送通知是由不同的 deviceToken 发送的。
当我通过 Xcode 一次又一次地重新安装应用程序时可能出现问题,因此 APNS 没有成功撤销 deviceToken。
我的服务器存储了所有的 deviceTokens 并通过这些 deviceTokens 推送通知,APNS 中有一些 deviceTokens 将指向我的 iPhone,所以我收到了很多通知。
如果我是对的,我可以撤销其他 deviceToken 吗? 还是其他原因造成的?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
// Register for Push Notitications, if running iOS 8
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes categories:nil];
[application registerUserNotificationSettings:settings];
[application registerForRemoteNotifications];
} else {
// Register for Push Notifications before iOS 8
[application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound)];
}
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken{
//send deviceToken to server
NSLog(@"Token is: %@", deviceToken);
}
【问题讨论】:
-
您的 iPhone 上是否安装了具有不同捆绑 ID 的应用程序的多个版本?
-
可能是服务器端您的设备令牌存储 n 次?检查它..
-
Paradeep,不,我没有。 Kishorem,好的,我会检查它
标签: ios apple-push-notifications