2017-03-24 255 views
1

我试图发送推送通知到设备上,我有我的创建pkpass。 设备已成功注册自动更新,我有它的令牌。发送推送通知到iOS设备

为了推送到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

检查证书。同时检查:https://github.com/davibennun/laravel-push-notification/issues/96 – Priyal

+0

证书应该没问题,我用它来创建Pkpasses,并且它们工作正常。 –

+0

@Priyal看起来像是tokken的字符串长度不正确。我只有32个字符,而gyu robschuh正在检查长度为64个字符。但我保存了整个令牌,我收到了。 –

回答

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推送通知包很简单,易于配置iOS和Android系统。 https://github.com/davibennun/laravel-push-notification

+0

我正在使用您提到的软件包。但是,我无法设置推送通知的到期时间。您是否知道如何设置https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/与APNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1联系中提到的apns_expiration ? –

相关问题