I am getting Device token in NSData and converting it to NSString. It is printing device token correctly
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)devToken {
deviceToken = [[devToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
deviceToken = [deviceToken stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"Device Token from NSdata is %@",deviceToken);
}
And I am passing this from other class
self.Token = [AppDelegate_iPhone sharedAppDelegate].deviceToken;
but it is crashing on this line
NSLog(@"Device Token from NSdata is %@",deviceToken);
*** -[CFString respondsToSelector:]: message sent to deallocated instance 0x1f9d00
You’re just assigning the value to
deviceToken. You need to retain the value otherwise it will be released right after.