Skip to content

Commit

Permalink
update the readme
Browse files Browse the repository at this point in the history
  • Loading branch information
iflamed committed Jan 17, 2017
1 parent 4dc8b4c commit da2a16f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions README.md
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)
```
2 changes: 1 addition & 1 deletion src/android/CordovaHuaweiPush.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static void pushMsgReceived (String msg) {
}
try {
JSONObject object = new JSONObject();
object.put("msg",msg);
object.put("extras",msg);
String format = "window.cordova.plugins.huaweipush.pushMsgReceived(%s);";
final String js = String.format(format, object.toString());
activity.runOnUiThread(new Runnable() {
Expand Down

0 comments on commit da2a16f

Please sign in to comment.