laravel jpush

composer require jpush/jpush

新建 config/jpush.php 文件

<?php
return [
    'appKey' =>env('JPUSH_APP_KEY', 'AppKey'),
    'masterSecret' =>env('JPUSH_MASTER_SECRET', 'Master Secret')
];

php artisan make:controller JPushController –resource

Route::resource(‘jpush’, ‘JPushController’);

use JPush\Client as JPush;

$jpush = new JPush(config(‘jpush.appKey’), config(‘jpush.masterSecret’));
$response = $jpush->push()
->setPlatform(‘all’)
->addRegistrationId(‘190e35f7e0007dd42b0’)
->setNotificationAlert(‘hello tp3.2’)
->options([‘apns_production’=>true])//这句很重要,开发和生产版本通知切换,之前遇的坑。
->send();
print_r($response);

问题:laravel ios jpush 无法收到推送,web端正常,api不成功。

options 的 apns_production 要为true。见上方代码。

laravel openssl_cipher_iv_length()

laravel 错误

Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()

phpinfo()

OpenSSL support disabled (install ext/openssl)

下载https://windows.php.net/downloads/php-sdk/deps/vc15/x64/openssl-1.1.1a-vc15-x64.zip

解压后bin目录能看到libcrypto-1_1-x64.dll和libssl-1_1-x64.dll,两个文件都拷到php目录和apache的bin下

开启extension=openssl

重启Apache就好了