Closed GoogleCodeExporter closed 8 years ago
Hello,
You need the deviceToken, not device UID. The device token is returned by apple
when you activate pns for your application. You should write this in the
ApplicationDidFichishedLaunching...
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
and create those method to get the token:
- (void)application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)dt
{
NSLog(@"My token is: %@", dt); // dt is the token.
// here is what i do to get a good 64bit string that will be used for a token
NSString *tt = [NSString stringWithFormat:@"%@",dt];
NSString *deviceToken = [[tt substringWithRange:NSMakeRange(1, [tt length]-2)]stringByReplacingOccurrencesOfString:@" " withString:@""];
NSLog(@"My token is: %@", deviceToken);
// then do whatever your want to keep the token
}
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
NSLog(@"Failed to get token, error: %@", error);
}
Original comment by patrice....@gmail.com
on 3 Sep 2011 at 5:38
Closing issue, since the problem was that a device UDID was passed to the
library instead of a device token.
The error reported by the library was slightly incorrect though, as it stated
the token had to be 64bits long. I have fixed it to say "64 bytes". The fix
will be in my next commit to the 2.0 branch.
Original comment by sype...@gmail.com
on 7 Sep 2011 at 4:40
Hi thank you for above explaination. I am implementing push notification using
javapans . I am little bit confusion on DeviceToken concept .I understood that
UDID is different from DeviceToken and i got device token using above code. My
doubt is can i use this DeviceToken for multipleDevices..
Original comment by rajarame...@gmail.com
on 4 Mar 2013 at 9:13
Original issue reported on code.google.com by
rhodebump@gmail.com
on 2 Sep 2011 at 12:09