How can I convert my device token (NSData) into an NSString?

后端 未结 30 2003
挽巷
挽巷 2020-11-28 18:31

I am implementing push notifications. I\'d like to save my APNS Token as a String.

- (void)application:(UIApplication *)application
didRegisterForRemoteNotif         


        
30条回答
  •  我在风中等你
    2020-11-28 19:17

    use this :

    NSString * deviceTokenString = [[[[deviceToken description]
                             stringByReplacingOccurrencesOfString: @"<" withString: @""] 
                            stringByReplacingOccurrencesOfString: @">" withString: @""] 
                           stringByReplacingOccurrencesOfString: @" " withString: @""];
    
    NSLog(@"The generated device token string is : %@",deviceTokenString);
    

提交回复
热议问题