PHP code example of n2boost / laravel-huawei-push
1. Go to this page and download the library: Download n2boost/laravel-huawei-push library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once ('vendor/autoload.php' );
n2boost / laravel-huawei-push example snippets
$push = new HuaweiPush();
$title = 'APP Name' ;
$message = 'This is a Message, Click Me!' ;
$accessToken = $push->getAccessToken();
$data = [
'type' => 'scheme' ,
'data' => "app://www.app.com/activity?id=123456789"
];
$push = $push->setTitle($title)
->setMessage($message)
->setAccessToken($accessToken)
->setCustomize($data);
$push->addDeviceToken("aBX471FWGHmiYZbZyE7o8WWISWYYQuVTEkJIbChBomv6mH3RWiTVOCDtJ-Hc-_E5rMPXzzIVjexXQHbN1GKmLhJqKqxJ4E86MyoUvw" );
$push->sendMessage();
dump($push->isSendSuccess());
dump($push->isSendFail());
dump($push->getAccessTokenExpiresTime());
dump($push->getSendSuccessRequestId());
return [
"APP_ID" => '12345678' ,
"APP_SECRET" => 'appSecret' ,
"APP_PKG_NAME" => 'com.company_name.pkg_name' ,
"TOKEN_URL" => 'https://login.vmall.com/oauth2/token' ,
"API_URL" => 'https://api.push.hicloud.com/pushsend.do' ,
];
bash
php artisan vendor:publish --provider="N2boost\LaravelHuaweiPush\HuaweiPushServiceProvider" --tag="config"