2016-02-26 51 views
2

我收到了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); 
} 
+0

您是否有多個版本的應用程序在您的iPhone上安裝了不同的捆綁ID? –

+0

可能是服務器端存儲了你的設備令牌n次?檢查它.. –

+0

Paradeep,不,我不知道。 Kishorem,好吧,我會檢查它 – jim

回答

0

重新安裝應用程序會自動撤銷舊的令牌。所以具有唯一捆綁ID的應用程序一次不能有多個令牌。

服務器端可能有問題,可能是將多個推送通知發送給此令牌,或者可能將同一令牌鏈接到多個用戶。

+0

,但只是我得到多個推送通知,這是讓我困惑 – jim

+0

問題是在您的服務器端。現在問題是,如何跟蹤你的服務器算法發送PUSH。多個令牌不應該有任何事情做,它會自動過期。檢查您的服務器數據庫,當前設備令牌以及與其鏈接的用戶數量。 –