https://github.com/abler98/php-huawei-pushkit
HUAWEI Push Kit SDK for PHP
https://github.com/abler98/php-huawei-pushkit
hms hms-pushkit huawei php push
Last synced: 9 months ago
JSON representation
HUAWEI Push Kit SDK for PHP
- Host: GitHub
- URL: https://github.com/abler98/php-huawei-pushkit
- Owner: abler98
- License: mit
- Created: 2020-11-13T20:58:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-14T12:15:58.000Z (over 5 years ago)
- Last Synced: 2025-06-24T09:15:10.539Z (9 months ago)
- Topics: hms, hms-pushkit, huawei, php, push
- Language: PHP
- Homepage:
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HUAWEI Push Kit SDK for PHP
[](//packagist.org/packages/megakit/php-huawei-pushkit)
[](//packagist.org/packages/megakit/php-huawei-pushkit)
[](//packagist.org/packages/megakit/php-huawei-pushkit)
[](//packagist.org/packages/megakit/php-huawei-pushkit)
Simple SDK for HUAWEI Push Kit server.
## Installation
Use [Composer] to install the package:
```shell script
$ composer require megakit/php-huawei-pushkit
```
## Quickstart example
```php
'',
'oauth_client_id' => '',
'oauth_client_secret' => '',
];
$tokens = [
'',
];
$huaweiConfig = HuaweiConfigBuilder::withDefaults()
->setAppId($config['app_id'])
->setOAuthCredentials($config['oauth_client_id'], $config['oauth_client_secret'])
->build();
$httpConfig = HttpConfigBuilder::withDefaults()->build();
$senderFactory = new SenderFactory();
$sender = $senderFactory->createSenderWithConfig($huaweiConfig, $httpConfig);
$notification = NotificationBuilder::make()
->setTitle('Hello')
->setBody('World')
->build();
$androidNotification = AndroidNotificationBuilder::make()
->setClickAction(
AndroidClickActionBuilder::make()
->setType(AndroidClickAction::TYPE_START_APP)
->build()
)
->build();
$androidConfig = AndroidConfigBuilder::make()
->setNotification($androidNotification)
->build();
$message = MessageBuilder::make()
->setNotification($notification)
->setAndroid($androidConfig)
->setData(['hello' => 'world'])
->build();
$destination = new TokenDestination($tokens);
try {
$sender->sendMessage($message, $destination);
echo 'Message sent successfully' . PHP_EOL;
} catch (HuaweiException $e) {
echo 'Error sending message: ' . $e->getMessage() . ' (' . $e->getCode() . ')' . PHP_EOL;
}
```
License
-------
All contents of this package are licensed under the [MIT license].
[Composer]: https://getcomposer.org
[MIT license]: LICENSE