-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,45 @@ | ||
# cordova-huawei-push | ||
The huawei push for cordova, hms sdk version, now only support android. | ||
|
||
## Install | ||
```shell | ||
cordova plugin add cordova-huawei-push --variable APPID=YOURAPPID --variable PACKAGENAME=YOURPACKAGENAME --save | ||
``` | ||
|
||
## How to use | ||
|
||
### Init the hms connection | ||
|
||
```javascript | ||
cordova.plugins.huaweipush.init(); | ||
``` | ||
|
||
### Token Registered | ||
|
||
```javascript | ||
document.addEventListener('huaweipush.receiveRegisterResult', function (event) { | ||
console.log(event) // event will contain the device token value | ||
}.bind(this), false); | ||
``` | ||
You can get the token value by `event.token` | ||
|
||
### Stop the push service | ||
|
||
```javascript | ||
cordova.plugins.huaweipush.stop(); | ||
``` | ||
|
||
### When notification clicked to open the app | ||
|
||
```javascript | ||
document.addEventListener('huaweipush.notificationOpened', function (event) { | ||
console.log(event) // the event will contain a extras key, which contain the data what you send | ||
}.bind(this), false) | ||
``` | ||
|
||
### When push message arrived at the app open status | ||
```javascript | ||
document.addEventListener('huaweipush.pushMsgReceived', function (event) { | ||
console.log(event) // the event will contain a extras key, which contain the data what you send | ||
}.bind(this), false) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters