【问题标题】:Laravel push notifications: certificate doesn't existLaravel 推送通知:证书不存在
【发布时间】:2018-01-14 08:51:17
【问题描述】:

我正在尝试将 Laravel 中的推送通知发送到 iOS 应用程序,并且我正在使用 Laravel 的 Push Notification Package。这是我的配置文件:

 return array(

        'appNameIOS' => array(
            'environment' => 'development',
            'certificate' => base_path('app/cert/APNS_Cert_Hasalty_dev.p12'),
//I am using absolute path in the actual code
            'passPhrase' => '',
            'service' => 'apns'
        ),
        'appNameAndroid' => array(
            'environment' => 'production',
            'apiKey' => 'yourAPIKey',
            'service' => 'gcm'
        )

    );

这就是我发送通知的方式:

$payload = PushNotification::Message('Hello World, i`m a push message from hasalty', array(
            'badge' => 1,
            'sound' => 'default',
        ));

        PushNotification::app('appNameIOS')
            ->to($deviceToken)
            ->send($payload);

现在,证书文件存在于配置中给出的路径中,但它抛出了错误:

证书 应用程序/证书/APNS_Cert_Hasalty_dev.p12 不存在

我做错了什么?有什么帮助吗? Laravel 的版本是5.3.31

【问题讨论】:

  • 添加您的 .p12 路径而不是 path/to/APNS_Cert_Hasalty_dev.p12,例如 'certificate' => '..../APNS_Cert_Hasalty_dev.p12',(....您保存 p12 的位置将该路径添加到证书)
  • 我已经更新了我的问题,请看一下。
  • 检查您的路径是否有效,如果有效,请检查 .p12 文件是否放置在该位置
  • 路径是对的,我用绝对路径也试过了,还是一样的错误,所以路径没有问题。
  • 您是否看到添加了 .pem 文件 'certificate' => '/path/to/certificate.pem', 而不是 .p12 的示例,另请参阅 //Path to the 'app' folder 'certificate'=>app_path().'/myCert.pem'

标签: php ios laravel-5 push-notification certificate


【解决方案1】:

我明白了。事实上,我正在使用.p12 文件并将其更改为.pem 文件并且它有效。可以研究这些的黑白差异here

【讨论】:

    【解决方案2】:

    试试这个,改用绝对路径。 __DIR__.'/path/to/certificate.pem'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-10
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多