2019-04-05 19:43:08 +05:30
|
|
|
# cordova-plugin-apns-push
|
2019-04-05 19:51:32 +05:30
|
|
|
|
2023-07-15 20:04:18 +08:00
|
|
|
> 从 https://github.com/NeutrinosPlatform/cordova-plugin-apns-push 克隆的。
|
|
|
|
|
> 主要修改:
|
|
|
|
|
> 1. 调整了 app 在活动/非活动状态的逻辑,在活动状态时是不会弹出提醒的。
|
|
|
|
|
> 2. 需要在发消息时指定 "content-available": 1,这样才能接收到数据。但是在试用 https://github.com/PerfectExamples/Perfect-APNS-Demo 时,并不需要这个参数。还是有很多东西没搞明白。
|
|
|
|
|
> 3. 如果想在活动状态弹出提醒,需要配合 cordova-plugin-local-notifications 插件。
|
|
|
|
|
|
2019-04-05 19:51:32 +05:30
|
|
|
> Register and receive APNS push notifications
|
|
|
|
|
|
2019-04-05 19:53:16 +05:30
|
|
|
# Install
|
|
|
|
|
|
2023-07-15 20:04:18 +08:00
|
|
|
`cordova plugin add git+https://m.shuto.cn:8681/public/cordova-plugin-apns-push`
|
2019-04-05 19:53:16 +05:30
|
|
|
|
2019-04-05 19:51:32 +05:30
|
|
|
# Usage
|
|
|
|
|
|
2023-07-15 20:04:18 +08:00
|
|
|
```js
|
2019-04-05 19:51:32 +05:30
|
|
|
|
|
|
|
|
var push = window['APNSPushNotification'].init({
|
|
|
|
|
ios: {
|
|
|
|
|
alert: "true",
|
|
|
|
|
badge: "true",
|
|
|
|
|
sound: "true"
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
push.on('registration', (data) => {
|
|
|
|
|
// data.registrationId
|
|
|
|
|
this.sendRegDetails(data.registrationId);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
push.on('notification', (data) => {
|
|
|
|
|
window['cordova'].plugins.notification.local.schedule({
|
|
|
|
|
title: data.title,
|
|
|
|
|
text: data.message,
|
|
|
|
|
sound: data.sound,
|
|
|
|
|
at: new Date().getTime()
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
push.on('error', (e) => {
|
|
|
|
|
// e.message
|
|
|
|
|
console.error(e);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
# Supported Platforms
|
2023-07-15 20:04:18 +08:00
|
|
|
|
2019-04-05 19:51:32 +05:30
|
|
|
- iOS
|
|
|
|
|
|
|
|
|
|
# More about us
|
|
|
|
|
Find out more or contact us directly here :- http://www.neutrinos.co/
|
|
|
|
|
|
|
|
|
|
Facebook :- https://www.facebook.com/Neutrinos.co/ <br/>
|
|
|
|
|
LinkedIn :- https://www.linkedin.com/company/25057297/ <br/>
|
|
|
|
|
Twitter :- https://twitter.com/Neutrinosco <br/>
|
|
|
|
|
Instagram :- https://www.instagram.com/neutrinos.co/
|
|
|
|
|
|
2023-07-15 20:04:18 +08:00
|
|
|
[](http://www.neutrinos.co/)
|
2019-04-05 19:51:32 +05:30
|
|
|
|