afiqiqmal/huawei-push

Simple Huawei Push in PHP

Maintainers

👁 afiqiqmal

Package info

github.com/afiqiqmal/huawei-push

pkg:composer/afiqiqmal/huawei-push

Statistics

Installs: 72 110

Dependents: 0

Suggesters: 0

Stars: 9

Open Issues: 2

1.4.1 2021-12-02 07:31 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 2ec3732628d4db39628de739ad854de2170173b7

  • Hafiq <hafiqiqmal93.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-29 01:43:56 UTC


README

👁 Build Status
👁 Coverage
👁 Packagist
👁 Packagist
👁 Donate

👁 alt text

Huawei Push PHP

Installation

composer require afiqiqmal/huawei-push

Usage

Get Access Token

References : Huawei OAuth

$access = HuaweiPushKit::make([
 'app_id' => 'YOUR APP ID',
 'client_secret' => 'YOUR CLIENT SECRET'
])
 ->getAccessToken();


//Laravel
$access = HuaweiPushKit::make(config('huawei'))->getAccessToken();
$access = app(HuaweiPushKit::class)->getAccessToken();

Response

{
 "access_token": "ACCESS TOKEN",
 "expires_in": 3600, // seconds
 "token_type": "Bearer"
}

Push Message

References : Huawei Push Kit

$response = HuaweiPushKit::make([])
 ->withAccessToken('ACCESS TOKEN')
 ->push(
 NotificationPayload::make()
 ->setValidateOnly(false)
 ->setMessage(
 Message::make()
 ->setNotification(
 Notification::make()
 ->setTitle("Testing Title")
 ->setBody("Body")
 ->setImage("https://seeklogo.com/images/L/laravel-logo-41EC1D4C3F-seeklogo.com.png")
 )
 ->setAndroid(
 Config::make() // AndroidConfig
 ->setUrgency(2)
 ->setCategory(1)
 ->setTimeToLive(3360)
 ->setTags('TrumpIsDown')
 ->isStaging(true)
 ->setNotification(
 AndroidNotification::make() // Notification
 ->setClickAction(
 ClickAction::make()
 ->setType(1)
 ->setIntent("pushscheme://com.huawei.hms.hmsdemo/deeplink?#Intent;i.isFeed=1;S.feedDocId=0LauP4X6;end")
 ->setUrl('https://www.google.com')
 )
 ->setImage('https://seeklogo.com/images/L/laravel-logo-41EC1D4C3F-seeklogo.com.png')
 ->setIcon('/raw/ic_launcher2')
 ->setColor('#FFFFFF')
 ->setSound('/raw/shake')
 ->setDefaultSound(false)
 ->setPriority(3)
 ->setChannelId("HMSTestDemo")
 ->setAutoClear(100000) // ms
 ->setSummary("Summary")
 ->setStyle(0)
 ->setNotifyId(123456)

 ->setButtons([
 Button::make()->setName("Home")->setActionType(0)
 ])
 )
 )
 ->setTopic("Topic")
 )
 );

Response

{
 "code": "80000000",
 "msg": "Success",
 "requestId": "160502268063038626000406"
}

TODO

  • WebPUSH
  • APNS

License

Licensed under the MIT license

👁 Image