Push Notification Device Token?

前端 未结 3 948
无人共我
无人共我 2021-01-29 23:12

How to get Device Token from my iPhone Device?

3条回答
  •  独厮守ぢ
    2021-01-29 23:40

    This method will show your device token in console.

    - (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    
        NSString *str = [NSString 
                         stringWithFormat:@"%@",deviceToken];
        NSString *newString = [str stringByReplacingOccurrencesOfString:@" " withString:@""];
        newString = [newString stringByReplacingOccurrencesOfString:@"<" withString:@""];
        newString = [newString stringByReplacingOccurrencesOfString:@">" withString:@""];
    
    
        [[NSUserDefaults standardUserDefaults] setObject:newString forKey:@"deviceToken"];
    
    
    
        NSLog(@"Your deviceToken ---> %@",newString);
    
    }
    

提交回复
热议问题