https://github.com/waitaction/cordova-plugin-xiaomi-push
小米推送
https://github.com/waitaction/cordova-plugin-xiaomi-push
Last synced: about 1 year ago
JSON representation
小米推送
- Host: GitHub
- URL: https://github.com/waitaction/cordova-plugin-xiaomi-push
- Owner: waitaction
- Created: 2020-11-12T02:26:52.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-12T08:41:47.000Z (over 5 years ago)
- Last Synced: 2025-02-19T11:06:14.388Z (about 1 year ago)
- Language: Java
- Size: 596 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 小米手机推送
小米手机推送
安装 `cordova-plugin-xiaomi-push`
``` shell
cordova plugin add cordova-plugin-xiaomi-push --variable APP_KEY=YOUR_APP_KEY --variable APP_ID=YOUR_APP_ID
```
## 使用
使用前需注册,以获取 `token` ,你可以将 `token` 与你的app用户信息关联后上传到服务器
``` js
// 注册推送
xiaomiPush.register(function(token) {
console.log(token);
}, function(err) {
console.log(err);
}, []);
// 接收token
xiaomiPush.onNewToken(function(token) {
console.log(token); // 会多次接收到token
});
```
注册完成后,需要监听 `messageReceived` 事件
``` js
document.addEventListener("messageReceived", function(result) {
console.log(result);
}, false);
```