我试图向设备发送推送通知,我已经创建了pkpass。 设备已成功注册以进行自动更新,我有其令牌。
为了推动APNS我使用包" daim2k5 / laravel-push-notification"。 我使用Laravel 5.2,因为它不是很多包,因为5.3更多。
但是当我试图推动时,我总是得到适配器APNS不支持2a984ecb2a947786dc4479d25109a172令牌的设备(令牌是这种格式,它不是真正的令牌,只是示例)
$devices = \PushNotification::DeviceCollection(array(
\PushNotification::Device('2a984ecb2a947786dc4479d25109a172', array('badge' => 1))
));
$r = \PushNotification::app([
'environment' =>'production',
'certificate' =>'awdrca.pem',
'passPhrase' =>'password',
'service' =>'apns'
])->to($devices) ->send('Test');
令牌我真的无效吗?或者其他地方有错误吗?
答案 0 :(得分:1)
确保您从iOS设备获得正确格式化的设备令牌,这是获取设备令牌所需的正确格式的示例。
NSString * token = [NSString stringWithFormat:@"%@", deviceToken];
//Format token as you need:
token = [token stringByReplacingOccurrencesOfString:@" " withString:@""];
token = [token stringByReplacingOccurrencesOfString:@">" withString:@""];
token = [token stringByReplacingOccurrencesOfString:@"<" withString:@""];
NSLog(@"%@", token);
其次尝试使用davibennun laravel-push-notification软件包,它既简单又易于配置iOS和Android。 https://github.com/davibennun/laravel-push-notification