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

时间:2015-02-05 08:13:16

标签: ios objective-c iphone device devicetoken

我写了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]);}

2 个答案:

答案 0 :(得分:3)

这是完全正常的!

设备令牌同时识别设备 应用。考虑一下,它非常有意义,因为在收到推送通知时,设备令牌用于识别iOS中的应用程序。如果每个应用都会返回设备令牌,那么iOS一旦到达设备就无法知道推送通知的位置。

答案 1 :(得分:0)

完全正常。设备令牌随应用程序的包ID和用于创建它的证书而变化。