LaravelPackages.net
Acme Inc.
Toggle sidebar
n2boost/laravel-huawei-push

Huawei Push SDK for Laravel

48.139
2
1.0.0
About n2boost/laravel-huawei-push

n2boost/laravel-huawei-push is a Laravel package for huawei push sdk for laravel. It currently has 2 GitHub stars and 48.139 downloads on Packagist (latest version 1.0.0). Install it with composer require n2boost/laravel-huawei-push. Discover more Laravel packages by n2boost or browse all Laravel packages to compare alternatives.

Last updated

Huawei Push SDK for Laravel

This package offers huawei push service tools.

Here are some push examples:

$push = new HuaweiPush();

$title = 'APP Name';
$message = 'This is a Message, Click Me!';

$accessToken = $push->getAccessToken(); // 获取AccessToken 可以保存起来
$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()); // 获取 AccessToken 过期时间
dump($push->getSendSuccessRequestId()); // 获取推送成功后接口返回的请求 id

Requirements

This package requires Laravel 5.5 or higher, PHP 7.0 or higher.

Installation

You can install the package via composer:

composer require n2boost/laravel-huawei-push:dev-master

The package will automatically register itself.

You can optionally publish the config file with:

php artisan vendor:publish --provider="N2boost\LaravelHuaweiPush\HuaweiPushServiceProvider" --tag="config"

This is the contents of the published config file:

<?php

return [

    /*
     * 用户在华为开发者联盟申请的appId和appSecret(会员中心->应用管理,点击应用名称的链接)
     */
    "APP_ID" => '12345678',

    "APP_SECRET" => 'appSecret',

    /*
     * 获取认证 Token 的 URL
     */
    "APP_PKG_NAME" => 'com.company_name.pkg_name',

    /*
     * 获取认证 Token 的 URL
     */
    "TOKEN_URL" => 'https://login.vmall.com/oauth2/token',

    /*
     * 应用级消息下发 API
     */
    "API_URL" => 'https://api.push.hicloud.com/pushsend.do',

];

TODOs

  • Push Feedback

Reference

License

The MIT License (MIT). Please see License File for more information.

Star History Chart