PHP APNS的设备令牌格式

时间:2014-02-10 10:51:09

标签: php laravel apple-push-notifications

我有这个APNS laravel包设置没有问题,但我没有用我们的设备令牌碰到砖墙。

https://github.com/ZhukV/AppleApnPush

我们的令牌存储在mysql中,看起来很像(我更改了几个字符)

'4739a92133dd5311d623e97cbe2d141e1b216c6e'

我们一直在回来

'Device token must be a 64 charsets, "40".'

是否有一些特殊方式我应该将设备令牌传递给这些方法?

1 个答案:

答案 0 :(得分:3)

您需要在AppDelegate中调用此方法来获取令牌:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Prepare the Device Token for Registration (remove spaces and < >)
NSString* devToken = [[[[deviceToken description]
                        stringByReplacingOccurrencesOfString:@"<"withString:@""]
                       stringByReplacingOccurrencesOfString:@">" withString:@""]
                      stringByReplacingOccurrencesOfString: @" " withString: @""];
NSLog(@"devToken=%@",devToken);
}

令牌如下所示:

bbb4231be5df46d6e9c1e4c3418ad56456c671eb7101818d8cc9ac80445727a8

电除尘器。令牌中的尾随“=”看起来很可疑。