另一个应用程序中的设备令牌更改

device token change in another app

我写了 3 个应用程序来获取我 iPad 中的设备令牌,但每个应用程序都有不同的设备令牌。

app1:4e8eb1d864c80fd8426615cd8ca4133c8bde78c30910cd1a8b82c917b612f38d
app2:2645100209412c457e87744c0af9ff323e28f6b2195c0fa9b835ddeebfe1391b
app3:f5958b3bad17feda02e64f9814f01cfafdda0b8283977214916c3d7eaa8b8dc8

这正常吗?我查看了一些信息,说同一台设备上的不同应用程序将获得相同的设备令牌...但根据我的测试,这似乎不是真的。

如有任何意见,我们将不胜感激:)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)])
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert|UIRemoteNotificationTypeSound|UIRemoteNotificationTypeBadge|UIRemoteNotificationTypeNewsstandContentAvailability];
}

return YES;

}

- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken{

NSString *newToken =[deviceToken description];
newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];

NSLog(@"*******************");
NSLog(@"Token%@",newToken);}

-(void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error{
NSLog(@"errorwwwwww:%@",[error description]);}

完全正常!

设备令牌同时识别 设备 应用程序。想一想,这是非常有意义的,因为设备令牌用于在收到推送通知时识别 iOS 内的应用程序。如果每个应用程序都会 return 设备令牌,iOS 将不知道在到达设备后将推送通知发送到哪里。

完美normal.The 设备令牌随应用程序的捆绑 ID 和用于创建它的证书而变化。