我收到了3個推送通知,內容相同。 一開始,我認爲我收到了重複推送通知。我可以撤銷deviceToken嗎?
但我發現這個推送通知是由不同的deviceToken發送的。
當我重新安裝Xcode的應用程序時,可能會出現錯誤,所以APNS沒有成功撤銷deviceToken。
我的服務器存儲了所有deviceToken並通過這些設備推送通知,並且APNS中有一些deviceToken將指向我的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,好吧,我會檢查它 – jim