我收到了3个内容相同的推送通知。一开始,我想我收到了重复的推送通知。
但是我发现这个推送通知是由不同的deviceToken发送的。
当我一次又一次地用Xcode重装app时,可能出了什么问题,所以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);
}发布于 2016-02-26 21:56:53
重新安装app会自动吊销旧令牌。因此,具有唯一捆绑Id的应用程序不能同时拥有多个令牌。
您可能在服务器端遇到问题,服务器端可能正在向此令牌发送多个推送通知,或者可能正在将同一令牌链接到多个用户。
https://stackoverflow.com/questions/35651841
复制相似问题