mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-01-28 00:00:03 +08:00
Compare commits
58 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67421b5091 | ||
|
|
83b7ca162a | ||
|
|
7f2179fe32 | ||
|
|
4f0c186bc3 | ||
|
|
1954d6b55b | ||
|
|
261eb44473 | ||
|
|
504fbb0789 | ||
|
|
cbacc7cb83 | ||
|
|
579e2b6de3 | ||
|
|
5301a2c5ea | ||
|
|
d628cc168b | ||
|
|
cce897daa0 | ||
|
|
0449935bcb | ||
|
|
b730924d74 | ||
|
|
4780eafb72 | ||
|
|
53e3588937 | ||
|
|
4585a13d7b | ||
|
|
f50a8ea5c7 | ||
|
|
9ea65add1f | ||
|
|
9c103753e6 | ||
|
|
3f1fa1e7ba | ||
|
|
c0c7d904e3 | ||
|
|
509184328d | ||
|
|
a0c828a296 | ||
|
|
2d81c7800b | ||
|
|
4cfca93789 | ||
|
|
c254794ace | ||
|
|
6d013438cd | ||
|
|
29970cd306 | ||
|
|
4f4a7e44f8 | ||
|
|
a891578f74 | ||
|
|
07c9722551 | ||
|
|
0b4f328e19 | ||
|
|
bb7b810215 | ||
|
|
5bea9b0bac | ||
|
|
7470258950 | ||
|
|
46f5f41f8e | ||
|
|
a33cc11090 | ||
|
|
c4e2deec06 | ||
|
|
a0752562b5 | ||
|
|
4b929a8e2e | ||
|
|
d3e2e1a5d7 | ||
|
|
001ab96283 | ||
|
|
1314d33c62 | ||
|
|
22b6d9a006 | ||
|
|
0cbedb412c | ||
|
|
fbd9d63590 | ||
|
|
184ee01d1d | ||
|
|
14a40c6572 | ||
|
|
fefaaea14f | ||
|
|
d2f9959ae1 | ||
|
|
3129165d3f | ||
|
|
66932a8bc8 | ||
|
|
07c9b2b945 | ||
|
|
8811dfc002 | ||
|
|
0ee5f8b1a0 | ||
|
|
259ec0a03a | ||
|
|
6283cb26f6 |
30
.gitignore
vendored
30
.gitignore
vendored
@@ -36,4 +36,34 @@ Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Ionic example
|
||||
ionic/example/.sourcemaps/*
|
||||
ionic/example/node_modules/*
|
||||
ionic/example/plugins/*
|
||||
ionic/example/config.xml
|
||||
ionic/example/ionic.config.json
|
||||
ionic/example/package-lock.json
|
||||
ionic/example/package.json
|
||||
ionic/example/tsconfig.json
|
||||
ionic/example/tslint.json
|
||||
ionic/example/resources/README\.md
|
||||
ionic/example/www/*
|
||||
ionic/example/src/assets/*
|
||||
ionic/example/src/theme
|
||||
ionic/example/platforms
|
||||
|
||||
ionic/example/src/manifest\.json
|
||||
|
||||
ionic/example/resources/android/splash/
|
||||
|
||||
ionic/example/resources/
|
||||
|
||||
ionic/example/src/service-worker\.js
|
||||
|
||||
ionic/example/src/index\.html
|
||||
|
||||
ionic/example/src/app/app\.scss
|
||||
|
||||
ionic/example/src/app/main\.ts
|
||||
|
||||
# End of https://www.gitignore.io/api/macos,apachecordova
|
||||
|
||||
43
README.md
43
README.md
@@ -1,7 +1,7 @@
|
||||
# JPush PhoneGap / Cordova Plugin
|
||||
|
||||
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||
|
||||
@@ -11,8 +11,15 @@
|
||||
- 如需要短信验证码功能插件,可关注 [cordova-plugin-jsms](https://github.com/jpush/cordova-plugin-jsms)
|
||||
- 如需要统计分析功能插件,可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics)
|
||||
|
||||
注意:目前插件暂未支持 cordova-android 7.0.0,因此在添加 android platform 时,请指定 7.0.0 以下版本,例如 6.4.0。
|
||||
|
||||
## Install
|
||||
|
||||
> 注意:
|
||||
>
|
||||
> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
|
||||
> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
|
||||
|
||||
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:
|
||||
|
||||
```shell
|
||||
@@ -28,10 +35,31 @@
|
||||
- 或下载到本地安装:
|
||||
|
||||
```shell
|
||||
cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey
|
||||
cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey
|
||||
```
|
||||
|
||||
> 在使用 Xcode 8 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
|
||||
### Ionic
|
||||
|
||||
如果使用了 Ionic,可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native:
|
||||
|
||||
```shell
|
||||
npm install --save @jiguang-ionic/jpush
|
||||
```
|
||||
|
||||
然后在 *app.module.ts* 中增加:
|
||||
|
||||
```js
|
||||
import { JPush } from '@jiguang-ionic/jpush';
|
||||
...
|
||||
providers: [
|
||||
...
|
||||
JPush,
|
||||
...
|
||||
]
|
||||
```
|
||||
|
||||
具体可参考 ./ionic/example 中的文件。
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -72,14 +100,13 @@
|
||||
Android 因为各 Rom 的高度定制化,不像 iOS 一样能有一个统一的管理,如果在 Android 中想自定义通知铃声,推荐通过 JPush 推送自定义
|
||||
消息,之后在 `jpush.receiveMessage` 事件监听中通过 [Cordova Local-Notification Plugin](https://github.com/katzer/cordova-plugin-local-notifications) 触发通知,再配合 [Cordova Background Plugin](https://github.com/katzer/cordova-plugin-background-mode) 插件保证应用的后台运行。
|
||||
|
||||
#### 如果让通知内容像 iOS 一样换行展示?
|
||||
#### 如何让通知内容像 iOS 一样自动换行展示?
|
||||
|
||||
[#267](https://github.com/jpush/jpush-phonegap-plugin/issues/267)
|
||||
|
||||
#### 关闭 App 后收不到通知
|
||||
|
||||
Android 的推送通过长连接的方式实现,只有在连接保持的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动,也就是
|
||||
在退出应用后,应用的所有服务均被杀死,且无法自启动,所以就会收不到通知。
|
||||
Android 的推送通过长连接的方式实现,只有在保持连接的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动,也就是在退出应用后,应用的所有服务均被杀死,且无法自启动,所以就会收不到通知。
|
||||
|
||||
目前 JPush 是做了应用互相拉起机制的,也就是当用户打开其他集成了 JPush 的应用时,你的应用也能同时收到推送消息。
|
||||
|
||||
@@ -98,10 +125,6 @@ Android 的推送通过长连接的方式实现,只有在连接保持的情况
|
||||
cordova platform update ios
|
||||
```
|
||||
|
||||
#### ionic 2 如何调用 API?
|
||||
|
||||
[issue 179](https://github.com/jpush/jpush-phonegap-plugin/issues/179)
|
||||
|
||||
#### PushConfig.plist 文件中的字段都是什么意思?
|
||||
|
||||
- Appkey:应用标识。
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# Android API 简介
|
||||
|
||||
- [注册成功事件](#注册成功事件)
|
||||
- [获取集成日志(同时适用于 iOS)](#获取集成日志同时适用于-ios)
|
||||
- [清除通知](#清除通知)
|
||||
- [设置允许推送时间](#设置允许推送时间)
|
||||
- [设置通知静默时间](#设置通知静默时间)
|
||||
@@ -9,19 +7,6 @@
|
||||
- [设置保留最近通知条数](#设置保留最近通知条数)
|
||||
- [本地通知](#本地通知)
|
||||
|
||||
## 注册成功事件
|
||||
### jpush.receiveRegistrationId
|
||||
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时,JPush 服务器会给客户端返回一个唯一的该设备的标识 - RegistrationID。
|
||||
就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 registrationId,可以直接调用 *getRegistrationID* 方法)。
|
||||
|
||||
#### 代码示例
|
||||
|
||||
```js
|
||||
document.addEventListener('jpush.receiveRegistrationId', function (event) {
|
||||
console.log(event.registrationId)
|
||||
}, false)
|
||||
```
|
||||
|
||||
## 获取集成日志(同时适用于 iOS)
|
||||
|
||||
### API - setDebugMode
|
||||
@@ -103,7 +88,7 @@ window.JPush.setPushTime(days, startHour, endHour)
|
||||
#### 参数说明
|
||||
|
||||
- days: 数组,0 表示星期天,1 表示星期一,以此类推(7天制,数组中值的范围为 0 到 6 )。
|
||||
数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0,则表示任何时间都收不到消息和通知。
|
||||
数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0,则表示任何时间都收不到消息和通知。
|
||||
- startHour: 整形,允许推送的开始时间 (24 小时制:startHour 的范围为 0 到 23)。
|
||||
- endHour: 整形,允许推送的结束时间 (24 小时制:endHour 的范围为 0 到 23)。
|
||||
|
||||
|
||||
@@ -1,15 +1,52 @@
|
||||
# 通用 API 说明(同时适用于 Android 和 iOS 系统)
|
||||
|
||||
- [停止与恢复推送服务](#停止与恢复推送服务)
|
||||
- [注册成功事件](#注册成功事件)
|
||||
- [jpush.receiveRegistrationId](#jpushreceiveregistrationid)
|
||||
- [初始化、停止与恢复推送服务](#初始化停止与恢复推送服务)
|
||||
- [init](#init)
|
||||
- [stopPush](#stoppush)
|
||||
- [resumePush](#resumepush)
|
||||
- [isPushStopped](#ispushstopped)
|
||||
- [开启 Debug 模式](#开启-debug-模式)
|
||||
- [setDebugMode](#setdebugmode)
|
||||
- [获取 RegistrationID](#获取-registrationid)
|
||||
- [getRegistrationID](#getregistrationid)
|
||||
- [设置别名与标签](#设置别名与标签)
|
||||
- [setAlias](#setalias)
|
||||
- [deleteAlias](#deletealias)
|
||||
- [getAlias](#getalias)
|
||||
- [setTags](#settags)
|
||||
- [addTags](#addtags)
|
||||
- [deleteTags](#deletetags)
|
||||
- [cleanTags](#cleantags)
|
||||
- [getAllTags](#getalltags)
|
||||
- [checkTagBindState](#checktagbindstate)
|
||||
- [获取点击通知内容](#获取点击通知内容)
|
||||
- [event - jpush.openNotification](#event---jpushopennotification)
|
||||
- [获取通知内容](#获取通知内容)
|
||||
- [event - jpush.receiveNotification](#event---jpushreceivenotification)
|
||||
- [获取自定义消息推送内容](#获取自定义消息推送内容)
|
||||
- [event - jpush.receiveMessage](#event---jpushreceivemessage)
|
||||
- [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送)
|
||||
|
||||
## 停止与恢复推送服务
|
||||
### API - init
|
||||
## 注册成功事件
|
||||
|
||||
### jpush.receiveRegistrationId
|
||||
|
||||
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时,JPush 服务器会给客户端返回一个唯一的该设备的标识 - Registration ID。
|
||||
此时就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 Registration Id,可以直接调用 `getRegistrationID` 方法)。
|
||||
|
||||
#### 代码示例
|
||||
|
||||
```js
|
||||
document.addEventListener('jpush.receiveRegistrationId', function (event) {
|
||||
console.log(event.registrationId)
|
||||
}, false)
|
||||
```
|
||||
|
||||
## 初始化、停止与恢复推送服务
|
||||
|
||||
### init
|
||||
|
||||
调用此 API,用来开启 JPush SDK 提供的推送服务。
|
||||
|
||||
@@ -27,7 +64,7 @@
|
||||
window.JPush.init()
|
||||
```
|
||||
|
||||
### API - stopPush
|
||||
### stopPush
|
||||
|
||||
- Android:
|
||||
- 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
|
||||
@@ -46,7 +83,7 @@ window.JPush.init()
|
||||
window.JPush.stopPush()
|
||||
```
|
||||
|
||||
### API - resumePush
|
||||
### resumePush
|
||||
|
||||
恢复推送服务。调用了此 API 后:
|
||||
|
||||
@@ -62,7 +99,7 @@ window.JPush.stopPush()
|
||||
window.JPush.resumePush()
|
||||
```
|
||||
|
||||
### API - isPushStopped
|
||||
### isPushStopped
|
||||
|
||||
- Android 平台:
|
||||
- 用来检查 Push Service 是否已经被停止。
|
||||
@@ -93,7 +130,7 @@ window.JPush.isPushStopped(function (result) {
|
||||
```
|
||||
|
||||
## 开启 Debug 模式
|
||||
### API - setDebugMode
|
||||
### setDebugMode
|
||||
用于开启 Debug 模式,显示更多的日志信息。
|
||||
|
||||
#### 代码示例
|
||||
@@ -103,11 +140,13 @@ window.JPush.setDebugMode(true)
|
||||
```
|
||||
|
||||
#### 参数说明
|
||||
- isOpen: true,开启 Debug 模式;false,关闭 Debug 模式,不显示错误信息之外的日志信息。
|
||||
|
||||
- true: 开启 Debug 模式;
|
||||
- false: 关闭 Debug 模式,不显示错误信息之外的日志信息。
|
||||
|
||||
## 获取 RegistrationID
|
||||
|
||||
### API - getRegistrationID
|
||||
### getRegistrationID
|
||||
|
||||
RegistrationID 定义:
|
||||
|
||||
@@ -361,7 +400,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
|
||||
|
||||
### event - jpush.openNotification
|
||||
|
||||
点击通知进入应用程序时会出发改事件。
|
||||
点击通知进入应用程序时触发。
|
||||
|
||||
#### 代码示例
|
||||
|
||||
@@ -378,8 +417,6 @@ document.addEventListener("jpush.openNotification", function (event) {
|
||||
}, false)
|
||||
```
|
||||
|
||||
> ps:点击通知后传递的 json object 保存在 window.JPush.openNotification,直接访问即可,字段示例,根据实际推送情况,可能略有差别,请注意。
|
||||
|
||||
- Android:
|
||||
|
||||
```json
|
||||
@@ -418,7 +455,7 @@ document.addEventListener("jpush.openNotification", function (event) {
|
||||
|
||||
### event - jpush.receiveNotification
|
||||
|
||||
收到通知时会触发该事件。
|
||||
收到通知时触发。
|
||||
|
||||
#### 代码示例
|
||||
|
||||
@@ -436,8 +473,6 @@ document.addEventListener("jpush.receiveNotification", function (event) {
|
||||
}, false)
|
||||
```
|
||||
|
||||
> ps:点击通知后传递的 json object 保存在 window.JPush.receiveNotification,直接访问即可,字段示例,根据实际推送情况,可能略有差别,请注意。
|
||||
|
||||
- Android:
|
||||
|
||||
```json
|
||||
@@ -476,7 +511,7 @@ document.addEventListener("jpush.receiveNotification", function (event) {
|
||||
|
||||
### event - jpush.receiveMessage
|
||||
|
||||
收到自定义消息时触发这个事件,推荐使用事件的方式传递。
|
||||
收到自定义消息时触发,推荐使用事件的方式传递。
|
||||
|
||||
但同时保留了 `receiveMessageIniOSCallback` 的回调函数,兼容以前的代码。
|
||||
|
||||
@@ -495,8 +530,6 @@ document.addEventListener("jpush.receiveMessage", function (event) {
|
||||
}, false)
|
||||
```
|
||||
|
||||
> ps:点击通知后传递的 json object 保存在 window.JPush.receiveMessage,直接访问即可,字段示例,根据实际推送情况,可能略有差别,请注意。
|
||||
|
||||
- Android:
|
||||
|
||||
```json
|
||||
@@ -545,4 +578,4 @@ window.JPush.getUserNotificationSettings(function(result) {
|
||||
} else if(result > 0) {
|
||||
// 系统设置中打开了应用推送。
|
||||
})
|
||||
```
|
||||
```
|
||||
|
||||
@@ -143,7 +143,7 @@ window.JPush.getRegistrationID(function(data) {
|
||||
|
||||
#### event - jpush.openNotification
|
||||
|
||||
点击通知启动或唤醒应用程序时会出发该事件
|
||||
点击通知(包括 localNotification 和 remoteNotification)启动或唤醒应用程序时会触发该事件
|
||||
|
||||
#### 代码示例
|
||||
|
||||
@@ -379,7 +379,7 @@ window.JPush.addLocalNotificationForIOS(delayTime, content, badge, notificationI
|
||||
|
||||
#### 参数说明
|
||||
|
||||
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可。
|
||||
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可,单位为秒。
|
||||
- content: 本地推送需要显示的内容。
|
||||
- badge: 角标的数字。如果不需要改变角标传-1。数值类型或纯数字的字符型均可。
|
||||
- notificationID: 本地推送标识符,字符串。
|
||||
@@ -433,6 +433,34 @@ window.JPush.clearAllLocalNotifications()
|
||||
|
||||
监听 `jpush.receiveLocalNotification` 事件获取,「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。
|
||||
|
||||
#### 代码示例
|
||||
|
||||
- 在你需要接收通知的的 js 文件中加入:
|
||||
|
||||
```js
|
||||
document.addEventListener("jpush.receiveLocalNotification", onLocalNotification, false)
|
||||
```
|
||||
|
||||
- onLocalNotification 需要这样写:
|
||||
|
||||
```js
|
||||
var onLocalNotification = function(event) {
|
||||
alert("receive Local Notification:" + JSON.stringify(event))
|
||||
}
|
||||
```
|
||||
|
||||
- event 举例
|
||||
|
||||
```json
|
||||
{
|
||||
badge = 1;
|
||||
content = "Hello JPush";
|
||||
extras = {
|
||||
"__JPUSHNotificationKey" = notificationIdentify_1;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
### iOS 10 收到本地通知
|
||||
|
||||
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
|
||||
@@ -716,10 +744,6 @@ window.JPush.getUserNotificationSettings(callback)
|
||||
|
||||
[iOS 7 以后后台收到远程通知](#后台收到推送)
|
||||
|
||||
### jpush.setTagsWithAlias
|
||||
|
||||
[设置标签别名回调](#返回值说明)
|
||||
|
||||
### jpush.receiveMessage
|
||||
|
||||
[获取自定义消息内容](#获取自定义消息内容)
|
||||
|
||||
@@ -9,7 +9,13 @@
|
||||
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
|
||||
<script type="text/javascript" src="cordova.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var onDeviceReady = function() {
|
||||
document.addEventListener("jpush.receiveRegistrationId", function (event) {
|
||||
alert("receiveRegistrationId" + JSON.stringify(event));
|
||||
$("#registrationId").html(event.registrationId);
|
||||
}, false)
|
||||
|
||||
initiateUI();
|
||||
};
|
||||
|
||||
@@ -88,13 +94,11 @@
|
||||
var initiateUI = function() {
|
||||
try {
|
||||
window.JPush.init();
|
||||
window.JPush.setDebugMode(true);
|
||||
window.setTimeout(getRegistrationID, 1000);
|
||||
|
||||
if (device.platform != "Android") {
|
||||
window.JPush.setDebugModeFromIos();
|
||||
window.JPush.setApplicationIconBadgeNumber(0);
|
||||
} else {
|
||||
window.JPush.setDebugMode(true);
|
||||
window.JPush.setStatisticsOpen(true);
|
||||
}
|
||||
} catch (exception) {
|
||||
console.log(exception);
|
||||
@@ -118,9 +122,9 @@
|
||||
}
|
||||
|
||||
window.JPush.setTags({ sequence: 1, tags: tags },
|
||||
(result) => {
|
||||
function (result) {
|
||||
$("#tagsResult").html(result.tags)
|
||||
}, (error) => {
|
||||
}, function (error) {
|
||||
alert(error.code)
|
||||
})
|
||||
} catch (exception) {
|
||||
@@ -130,19 +134,19 @@
|
||||
|
||||
$("#getAllTags").click(function (event) {
|
||||
window.JPush.getAllTags({ sequence: 2 },
|
||||
(result) => {
|
||||
function (result) {
|
||||
$("#tagsResult").html(result.tags)
|
||||
}, (error) => {
|
||||
}, function (error) {
|
||||
alert(error.code)
|
||||
})
|
||||
})
|
||||
|
||||
$("#cleanTags").click(function (event) {
|
||||
window.JPush.cleanTags({ sequence: 2 },
|
||||
(result) => {
|
||||
function (result) {
|
||||
alert(result.sequence)
|
||||
$("#tagsResult").html("")
|
||||
}, (error) => {
|
||||
}, function (error) {
|
||||
alert(error.code)
|
||||
})
|
||||
})
|
||||
@@ -150,27 +154,27 @@
|
||||
$("#setAlias").click(function (event) {
|
||||
var alias = $("#aliasText").val()
|
||||
window.JPush.setAlias({ sequence: 1, alias: alias },
|
||||
(result) => {
|
||||
function (result) {
|
||||
$("#aliasResult").html(result.alias)
|
||||
}, (error) => {
|
||||
}, function (error){
|
||||
alert(error.code)
|
||||
})
|
||||
})
|
||||
|
||||
$("#getAlias").click(function (event) {
|
||||
window.JPush.getAlias({ sequence: 2 },
|
||||
(result) => {
|
||||
function (result) {
|
||||
alert(JSON.stringify(result));
|
||||
}, (error) => {
|
||||
}, function (error) {
|
||||
alert(error.code)
|
||||
})
|
||||
});
|
||||
|
||||
$("#deleteAlias").click(function (event) {
|
||||
window.JPush.deleteAlias({ sequence: 3 },
|
||||
(result) => {
|
||||
function (result) {
|
||||
alert(JSON.stringify(result));
|
||||
}, (error) => {
|
||||
}, function (error) {
|
||||
alert(error.code)
|
||||
})
|
||||
});
|
||||
|
||||
BIN
example/js/.DS_Store
vendored
BIN
example/js/.DS_Store
vendored
Binary file not shown.
25
ionic/example/src/app/app.component.ts
Normal file
25
ionic/example/src/app/app.component.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Platform } from 'ionic-angular';
|
||||
import { StatusBar } from '@ionic-native/status-bar';
|
||||
import { SplashScreen } from '@ionic-native/splash-screen';
|
||||
import { JPush } from '@jiguang-ionic/jpush';
|
||||
|
||||
import { HomePage } from '../pages/home/home';
|
||||
@Component({
|
||||
templateUrl: 'app.html'
|
||||
})
|
||||
export class MyApp {
|
||||
rootPage:any = HomePage;
|
||||
|
||||
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, jpush: JPush) {
|
||||
platform.ready().then(() => {
|
||||
// Okay, so the platform is ready and our plugins are available.
|
||||
// Here you can do any higher level native things you might need.
|
||||
statusBar.styleDefault();
|
||||
splashScreen.hide();
|
||||
|
||||
jpush.init();
|
||||
jpush.setDebugMode(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
1
ionic/example/src/app/app.html
Normal file
1
ionic/example/src/app/app.html
Normal file
@@ -0,0 +1 @@
|
||||
<ion-nav [root]="rootPage"></ion-nav>
|
||||
34
ionic/example/src/app/app.module.ts
Normal file
34
ionic/example/src/app/app.module.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { ErrorHandler, NgModule } from '@angular/core';
|
||||
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
|
||||
import { SplashScreen } from '@ionic-native/splash-screen';
|
||||
import { StatusBar } from '@ionic-native/status-bar';
|
||||
import { Device } from '@ionic-native/device';
|
||||
import { JPush } from '@jiguang-ionic/jpush';
|
||||
|
||||
import { MyApp } from './app.component';
|
||||
import { HomePage } from '../pages/home/home';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
MyApp,
|
||||
HomePage
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
IonicModule.forRoot(MyApp)
|
||||
],
|
||||
bootstrap: [IonicApp],
|
||||
entryComponents: [
|
||||
MyApp,
|
||||
HomePage
|
||||
],
|
||||
providers: [
|
||||
StatusBar,
|
||||
SplashScreen,
|
||||
Device,
|
||||
JPush,
|
||||
{provide: ErrorHandler, useClass: IonicErrorHandler}
|
||||
]
|
||||
})
|
||||
export class AppModule {}
|
||||
36
ionic/example/src/pages/home/home.html
Normal file
36
ionic/example/src/pages/home/home.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<ion-header>
|
||||
<ion-navbar>
|
||||
<ion-title>
|
||||
JPush Ionic Example
|
||||
</ion-title>
|
||||
</ion-navbar>
|
||||
</ion-header>
|
||||
|
||||
<ion-content padding>
|
||||
|
||||
<ion-list>
|
||||
<ion-item>
|
||||
<div>Registration Id: {{registrationId}}</div>
|
||||
<button ion-button full (click)="getRegistrationID()">Get Registration Id</button>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<button ion-button full (click)="setTags()">Set tags - Tag1, Tag2</button>
|
||||
<button ion-button full (click)="addTags()">Add tags - Tag3, Tag4</button>
|
||||
<button ion-button full (click)="checkTagBindState()">Check tag bind state - Tag1</button>
|
||||
<button ion-button full (click)="deleteTags()">Delete tags - Tag4</button>
|
||||
<button ion-button full (click)="getAllTags()">Get all tags</button>
|
||||
<button ion-button full (click)="cleanTags()">Clean tags</button>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<button ion-button full (click)="setAlias()">Set Alias - TestAlias</button>
|
||||
<button ion-button full (click)="getAlias()">Get Alias</button>
|
||||
<button ion-button full (click)="deleteAlias()">Delete Alias</button>
|
||||
</ion-item>
|
||||
|
||||
<ion-item>
|
||||
<button ion-button full (click)="addLocalNotification()">Trigger local notification after 5 seconds</button>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
3
ionic/example/src/pages/home/home.scss
Normal file
3
ionic/example/src/pages/home/home.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
page-home {
|
||||
|
||||
}
|
||||
146
ionic/example/src/pages/home/home.ts
Normal file
146
ionic/example/src/pages/home/home.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { NavController } from 'ionic-angular';
|
||||
import { JPush } from '@jiguang-ionic/jpush';
|
||||
import { Device } from '@ionic-native/device';
|
||||
|
||||
@Component({
|
||||
selector: 'page-home',
|
||||
templateUrl: 'home.html'
|
||||
})
|
||||
export class HomePage {
|
||||
|
||||
public registrationId: string;
|
||||
|
||||
devicePlatform: string;
|
||||
sequence: number = 0;
|
||||
|
||||
tagResultHandler = function(result) {
|
||||
var sequence: number = result.sequence;
|
||||
var tags: Array<string> = result.tags == null ? [] : result.tags;
|
||||
alert('Success!' + '\nSequence: ' + sequence + '\nTags: ' + tags.toString());
|
||||
};
|
||||
|
||||
aliasResultHandler = function(result) {
|
||||
var sequence: number = result.sequence;
|
||||
var alias: string = result.alias;
|
||||
alert('Success!' + '\nSequence: ' + sequence + '\nAlias: ' + alias);
|
||||
};
|
||||
|
||||
errorHandler = function(err) {
|
||||
var sequence: number = err.sequence;
|
||||
var code = err.code;
|
||||
alert('Error!' + '\nSequence: ' + sequence + '\nCode: ' + code);
|
||||
};
|
||||
|
||||
constructor(public navCtrl: NavController, public jpush: JPush, device: Device) {
|
||||
|
||||
this.devicePlatform = device.platform;
|
||||
|
||||
document.addEventListener('jpush.receiveNotification', (event: any) => {
|
||||
var content;
|
||||
if (this.devicePlatform == 'Android') {
|
||||
content = event.alert;
|
||||
} else {
|
||||
content = event.aps.alert;
|
||||
}
|
||||
alert('Receive notification: ' + JSON.stringify(event));
|
||||
}, false);
|
||||
|
||||
document.addEventListener('jpush.openNotification', (event: any) => {
|
||||
var content;
|
||||
if (this.devicePlatform == 'Android') {
|
||||
content = event.alert;
|
||||
} else { // iOS
|
||||
if (event.aps == undefined) { // 本地通知
|
||||
content = event.content;
|
||||
} else { // APNS
|
||||
content = event.aps.alert;
|
||||
}
|
||||
}
|
||||
alert('open notification: ' + JSON.stringify(event));
|
||||
}, false);
|
||||
|
||||
document.addEventListener('jpush.receiveLocalNotification', (event: any) => {
|
||||
// iOS(*,9) Only , iOS(10,*) 将在 jpush.openNotification 和 jpush.receiveNotification 中触发。
|
||||
var content;
|
||||
if (this.devicePlatform == 'Android') {
|
||||
} else {
|
||||
content = event.content;
|
||||
}
|
||||
alert('receive local notification: ' + JSON.stringify(event));
|
||||
}, false);
|
||||
}
|
||||
|
||||
getRegistrationID() {
|
||||
this.jpush.getRegistrationID()
|
||||
.then(rId => {
|
||||
this.registrationId = rId;
|
||||
});
|
||||
}
|
||||
|
||||
setTags() {
|
||||
this.jpush.setTags({ sequence: this.sequence++, tags: ['Tag1', 'Tag2']})
|
||||
.then(this.tagResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
addTags() {
|
||||
this.jpush.addTags({ sequence: this.sequence++, tags: ['Tag3', 'Tag4']})
|
||||
.then(this.tagResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
checkTagBindState() {
|
||||
this.jpush.checkTagBindState({ sequence: this.sequence++, tag: 'Tag1' })
|
||||
.then(result => {
|
||||
var sequence = result.sequence;
|
||||
var tag = result.tag;
|
||||
var isBind = result.isBind;
|
||||
alert('Sequence: ' + sequence + '\nTag: ' + tag + '\nIsBind: ' + isBind);
|
||||
}).catch(this.errorHandler);
|
||||
}
|
||||
|
||||
deleteTags() {
|
||||
this.jpush.deleteTags({ sequence: this.sequence++, tags: ['Tag4']})
|
||||
.then(this.tagResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
getAllTags() {
|
||||
this.jpush.getAllTags({ sequence: this.sequence++ })
|
||||
.then(this.tagResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
cleanTags() {
|
||||
this.jpush.cleanTags({ sequence: this.sequence++ })
|
||||
.then(this.tagResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
setAlias() {
|
||||
this.jpush.setAlias({ sequence: this.sequence++, alias: 'TestAlias' })
|
||||
.then(this.aliasResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
getAlias() {
|
||||
this.jpush.getAlias({ sequence: this.sequence++ })
|
||||
.then(this.aliasResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
deleteAlias() {
|
||||
this.jpush.deleteAlias({ sequence: this.sequence++ })
|
||||
.then(this.aliasResultHandler)
|
||||
.catch(this.errorHandler);
|
||||
}
|
||||
|
||||
addLocalNotification() {
|
||||
if (this.devicePlatform == 'Android') {
|
||||
this.jpush.addLocalNotification(0, 'Hello JPush', 'JPush', 1, 5000);
|
||||
} else {
|
||||
this.jpush.addLocalNotificationForIOS(5, 'Hello JPush', 1, 'localNoti1');
|
||||
}
|
||||
}
|
||||
}
|
||||
171
ionic/index.ts
Normal file
171
ionic/index.ts
Normal file
@@ -0,0 +1,171 @@
|
||||
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
export interface TagOptions {
|
||||
sequence: number;
|
||||
tags?: Array<string>;
|
||||
}
|
||||
|
||||
export interface AliasOptions {
|
||||
sequence: number;
|
||||
alias?: string;
|
||||
}
|
||||
|
||||
@Plugin({
|
||||
pluginName: 'JPush',
|
||||
plugin: 'jpush-phonegap-plugin',
|
||||
pluginRef: 'plugins.jPushPlugin',
|
||||
repo: 'https://github.com/jpush/jpush-phonegap-plugin',
|
||||
install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
|
||||
installVariables: ['APP_KEY'],
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class JPush extends IonicNativePlugin {
|
||||
|
||||
@Cordova()
|
||||
init(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setDebugMode(enable: boolean): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
getRegistrationID(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
stopPush(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
resumePush(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
isPushStopped(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
addTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
deleteTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
cleanTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
getAllTags(params: TagOptions): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* @param params { sequence: number, tag: string }
|
||||
*/
|
||||
@Cordova()
|
||||
checkTagBindState(params: object): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setAlias(params: AliasOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
deleteAlias(params: AliasOptions): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
getAlias(params: AliasOptions): Promise<any> { return; }
|
||||
|
||||
/**
|
||||
* Determinate whether the application notification has been opened.
|
||||
*
|
||||
* iOS: 0: closed; >1: opened.
|
||||
* UIRemoteNotificationTypeNone = 0,
|
||||
* UIRemoteNotificationTypeBadge = 1 << 0,
|
||||
* UIRemoteNotificationTypeSound = 1 << 1,
|
||||
* UIRemoteNotificationTypeAlert = 1 << 2,
|
||||
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
|
||||
*
|
||||
* Android: 0: closed; 1: opened.
|
||||
*/
|
||||
@Cordova()
|
||||
getUserNotificationSettings(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
clearLocalNotifications(): Promise<any> { return; }
|
||||
|
||||
// iOS API - start
|
||||
|
||||
@Cordova()
|
||||
setBadge(badge: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
resetBadge(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setApplicationIconBadgeNumber(badge: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
getApplicationIconBadgeNumber(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
addDismissActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
addNotificationActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setLocation(latitude: number, longitude: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
startLogPageView(pageName: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
stopLogPageView(pageName: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
beginLogPageView(pageName: string, duration: number): Promise<any> { return; }
|
||||
|
||||
// iOS API - end
|
||||
|
||||
// Android API - start
|
||||
|
||||
@Cordova()
|
||||
getConnectionState(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setBasicPushNotificationBuilder(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setCustomPushNotificationBuilder(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
clearAllNotification(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
clearNotificationById(id: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setLatestNotificationNum(num: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
removeLocalNotification(notificationId: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
reportNotificationOpened(msgId: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
requestPermission(): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any> { return; }
|
||||
|
||||
@Cordova()
|
||||
setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any> { return; }
|
||||
|
||||
// Android API - end
|
||||
}
|
||||
67
ionic/jpush/index.d.ts
vendored
Normal file
67
ionic/jpush/index.d.ts
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { IonicNativePlugin } from '@ionic-native/core';
|
||||
export interface TagOptions {
|
||||
sequence: number;
|
||||
tags?: Array<string>;
|
||||
}
|
||||
export interface AliasOptions {
|
||||
sequence: number;
|
||||
alias?: string;
|
||||
}
|
||||
export declare class JPush extends IonicNativePlugin {
|
||||
init(): Promise<any>;
|
||||
setDebugMode(enable: boolean): Promise<any>;
|
||||
getRegistrationID(): Promise<any>;
|
||||
stopPush(): Promise<any>;
|
||||
resumePush(): Promise<any>;
|
||||
isPushStopped(): Promise<any>;
|
||||
setTags(params: TagOptions): Promise<any>;
|
||||
addTags(params: TagOptions): Promise<any>;
|
||||
deleteTags(params: TagOptions): Promise<any>;
|
||||
cleanTags(params: TagOptions): Promise<any>;
|
||||
getAllTags(params: TagOptions): Promise<any>;
|
||||
/**
|
||||
* @param params { sequence: number, tag: string }
|
||||
*/
|
||||
checkTagBindState(params: object): Promise<any>;
|
||||
setAlias(params: AliasOptions): Promise<any>;
|
||||
deleteAlias(params: AliasOptions): Promise<any>;
|
||||
getAlias(params: AliasOptions): Promise<any>;
|
||||
/**
|
||||
* Determinate whether the application notification has been opened.
|
||||
*
|
||||
* iOS: 0: closed; >1: opened.
|
||||
* UIRemoteNotificationTypeNone = 0,
|
||||
* UIRemoteNotificationTypeBadge = 1 << 0,
|
||||
* UIRemoteNotificationTypeSound = 1 << 1,
|
||||
* UIRemoteNotificationTypeAlert = 1 << 2,
|
||||
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
|
||||
*
|
||||
* Android: 0: closed; 1: opened.
|
||||
*/
|
||||
getUserNotificationSettings(): Promise<any>;
|
||||
clearLocalNotifications(): Promise<any>;
|
||||
setBadge(badge: number): Promise<any>;
|
||||
resetBadge(): Promise<any>;
|
||||
setApplicationIconBadgeNumber(badge: number): Promise<any>;
|
||||
getApplicationIconBadgeNumber(): Promise<any>;
|
||||
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise<any>;
|
||||
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any>;
|
||||
addDismissActions(actions: Array<object>, categoryId: string): Promise<any>;
|
||||
addNotificationActions(actions: Array<object>, categoryId: string): Promise<any>;
|
||||
setLocation(latitude: number, longitude: number): Promise<any>;
|
||||
startLogPageView(pageName: string): Promise<any>;
|
||||
stopLogPageView(pageName: string): Promise<any>;
|
||||
beginLogPageView(pageName: string, duration: number): Promise<any>;
|
||||
getConnectionState(): Promise<any>;
|
||||
setBasicPushNotificationBuilder(): Promise<any>;
|
||||
setCustomPushNotificationBuilder(): Promise<any>;
|
||||
clearAllNotification(): Promise<any>;
|
||||
clearNotificationById(id: number): Promise<any>;
|
||||
setLatestNotificationNum(num: number): Promise<any>;
|
||||
addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any>;
|
||||
removeLocalNotification(notificationId: number): Promise<any>;
|
||||
reportNotificationOpened(msgId: number): Promise<any>;
|
||||
requestPermission(): Promise<any>;
|
||||
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any>;
|
||||
setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any>;
|
||||
}
|
||||
352
ionic/jpush/index.js
Normal file
352
ionic/jpush/index.js
Normal file
@@ -0,0 +1,352 @@
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
||||
import { Injectable } from '@angular/core';
|
||||
var JPush = (function (_super) {
|
||||
__extends(JPush, _super);
|
||||
function JPush() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
JPush.prototype.init = function () { return; };
|
||||
JPush.prototype.setDebugMode = function (enable) { return; };
|
||||
JPush.prototype.getRegistrationID = function () { return; };
|
||||
JPush.prototype.stopPush = function () { return; };
|
||||
JPush.prototype.resumePush = function () { return; };
|
||||
JPush.prototype.isPushStopped = function () { return; };
|
||||
JPush.prototype.setTags = function (params) { return; };
|
||||
JPush.prototype.addTags = function (params) { return; };
|
||||
JPush.prototype.deleteTags = function (params) { return; };
|
||||
JPush.prototype.cleanTags = function (params) { return; };
|
||||
JPush.prototype.getAllTags = function (params) { return; };
|
||||
/**
|
||||
* @param params { sequence: number, tag: string }
|
||||
*/
|
||||
JPush.prototype.checkTagBindState = function (params) { return; };
|
||||
JPush.prototype.setAlias = function (params) { return; };
|
||||
JPush.prototype.deleteAlias = function (params) { return; };
|
||||
JPush.prototype.getAlias = function (params) { return; };
|
||||
/**
|
||||
* Determinate whether the application notification has been opened.
|
||||
*
|
||||
* iOS: 0: closed; >1: opened.
|
||||
* UIRemoteNotificationTypeNone = 0,
|
||||
* UIRemoteNotificationTypeBadge = 1 << 0,
|
||||
* UIRemoteNotificationTypeSound = 1 << 1,
|
||||
* UIRemoteNotificationTypeAlert = 1 << 2,
|
||||
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
|
||||
*
|
||||
* Android: 0: closed; 1: opened.
|
||||
*/
|
||||
JPush.prototype.getUserNotificationSettings = function () { return; };
|
||||
JPush.prototype.clearLocalNotifications = function () { return; };
|
||||
// iOS API - start
|
||||
JPush.prototype.setBadge = function (badge) { return; };
|
||||
JPush.prototype.resetBadge = function () { return; };
|
||||
JPush.prototype.setApplicationIconBadgeNumber = function (badge) { return; };
|
||||
JPush.prototype.getApplicationIconBadgeNumber = function () { return; };
|
||||
JPush.prototype.addLocalNotificationForIOS = function (delayTime, content, badge, identifierKey, extras) { return; };
|
||||
JPush.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (identifierKey) { return; };
|
||||
JPush.prototype.addDismissActions = function (actions, categoryId) { return; };
|
||||
JPush.prototype.addNotificationActions = function (actions, categoryId) { return; };
|
||||
JPush.prototype.setLocation = function (latitude, longitude) { return; };
|
||||
JPush.prototype.startLogPageView = function (pageName) { return; };
|
||||
JPush.prototype.stopLogPageView = function (pageName) { return; };
|
||||
JPush.prototype.beginLogPageView = function (pageName, duration) { return; };
|
||||
// iOS API - end
|
||||
// Android API - start
|
||||
JPush.prototype.getConnectionState = function () { return; };
|
||||
JPush.prototype.setBasicPushNotificationBuilder = function () { return; };
|
||||
JPush.prototype.setCustomPushNotificationBuilder = function () { return; };
|
||||
JPush.prototype.clearAllNotification = function () { return; };
|
||||
JPush.prototype.clearNotificationById = function (id) { return; };
|
||||
JPush.prototype.setLatestNotificationNum = function (num) { return; };
|
||||
JPush.prototype.addLocalNotification = function (builderId, content, title, notificationId, broadcastTime, extras) { return; };
|
||||
JPush.prototype.removeLocalNotification = function (notificationId) { return; };
|
||||
JPush.prototype.reportNotificationOpened = function (msgId) { return; };
|
||||
JPush.prototype.requestPermission = function () { return; };
|
||||
JPush.prototype.setSilenceTime = function (startHour, startMinute, endHour, endMinute) { return; };
|
||||
JPush.prototype.setPushTime = function (weekdays, startHour, endHour) { return; };
|
||||
// Android API - end
|
||||
JPush.decorators = [
|
||||
{ type: Injectable },
|
||||
];
|
||||
/** @nocollapse */
|
||||
JPush.ctorParameters = function () { return []; };
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "init", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Boolean]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setDebugMode", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getRegistrationID", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "stopPush", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "resumePush", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "isPushStopped", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setTags", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "addTags", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "deleteTags", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "cleanTags", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getAllTags", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "checkTagBindState", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setAlias", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "deleteAlias", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getAlias", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getUserNotificationSettings", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "clearLocalNotifications", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setBadge", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "resetBadge", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setApplicationIconBadgeNumber", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getApplicationIconBadgeNumber", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, String, Number, String, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "addLocalNotificationForIOS", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "deleteLocalNotificationWithIdentifierKeyInIOS", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Array, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "addDismissActions", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Array, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "addNotificationActions", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setLocation", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "startLogPageView", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "stopLogPageView", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "beginLogPageView", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "getConnectionState", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setBasicPushNotificationBuilder", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setCustomPushNotificationBuilder", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "clearAllNotification", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "clearNotificationById", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setLatestNotificationNum", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, String, String, Number, Number, String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "addLocalNotification", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "removeLocalNotification", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "reportNotificationOpened", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "requestPermission", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, Number, Number, Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setSilenceTime", null);
|
||||
__decorate([
|
||||
Cordova(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Array, Number, Number]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], JPush.prototype, "setPushTime", null);
|
||||
JPush = __decorate([
|
||||
Plugin({
|
||||
pluginName: 'JPush',
|
||||
plugin: 'jpush-phonegap-plugin',
|
||||
pluginRef: 'plugins.jPushPlugin',
|
||||
repo: 'https://github.com/jpush/jpush-phonegap-plugin',
|
||||
install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
|
||||
installVariables: ['APP_KEY'],
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
], JPush);
|
||||
return JPush;
|
||||
}(IonicNativePlugin));
|
||||
export { JPush };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
ionic/jpush/index.js.map
Normal file
1
ionic/jpush/index.js.map
Normal file
File diff suppressed because one or more lines are too long
1
ionic/jpush/index.metadata.json
Normal file
1
ionic/jpush/index.metadata.json
Normal file
File diff suppressed because one or more lines are too long
18
ionic/jpush/package.json
Normal file
18
ionic/jpush/package.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "@jiguang-ionic/jpush",
|
||||
"version": "1.0.2",
|
||||
"description": "JPush support for ionic-native",
|
||||
"module": "index.js",
|
||||
"typings": "index.d.ts",
|
||||
"author": "hevin",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"@ionic-native/core": "^4.2.0",
|
||||
"@angular/core": "*",
|
||||
"rxjs": "^5.0.1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jpush/jpush-phonegap-plugin"
|
||||
}
|
||||
}
|
||||
35
issue_template.md
Normal file
35
issue_template.md
Normal file
@@ -0,0 +1,35 @@
|
||||
**WARNING: 如果不按照这个表格,我们将无法帮助你,并将忽略你的问题。**
|
||||
|
||||
## 你的运行环境
|
||||
|
||||
* 插件版本:
|
||||
* 平台(Android / iOS):
|
||||
* Cordova version (```cordova -v```):
|
||||
* Cordova platform version (```cordova platform ls```):
|
||||
* Ionic Version (if using Ionic)
|
||||
|
||||
## 期望效果
|
||||
|
||||
告诉我们你希望达到什么效果。
|
||||
|
||||
## 实际效果
|
||||
|
||||
告诉我们实际是什么效果。
|
||||
|
||||
## 重现步骤
|
||||
|
||||
1. ...
|
||||
2. ...
|
||||
3. ...
|
||||
4. ...
|
||||
|
||||
## 背景
|
||||
|
||||
你尝试做过些什么?
|
||||
|
||||
## Debug logs
|
||||
|
||||
包括 Android 或 iOS 的日志:
|
||||
|
||||
* iOS: XCode logs
|
||||
* Android: $ adb logcat / Android Studio logcat
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jpush-phonegap-plugin",
|
||||
"version": "3.2.7",
|
||||
"version": "3.3.2",
|
||||
"description": "JPush for cordova plugin",
|
||||
"cordova": {
|
||||
"id": "jpush-phonegap-plugin",
|
||||
|
||||
25
plugin.xml
25
plugin.xml
@@ -2,7 +2,7 @@
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="jpush-phonegap-plugin"
|
||||
version="3.2.7">
|
||||
version="3.3.2">
|
||||
|
||||
<name>JPush</name>
|
||||
<description>JPush for cordova plugin</description>
|
||||
@@ -38,7 +38,7 @@
|
||||
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
|
||||
|
||||
<header-file src="src/ios/lib/JPUSHService.h" />
|
||||
<source-file src="src/ios/lib/jpush-ios-3.0.6.a" framework="true" />
|
||||
<source-file src="src/ios/lib/jpush-ios-3.0.7.a" framework="true" />
|
||||
<resource-file src="src/ios/JPushConfig.plist" />
|
||||
|
||||
<framework src="CFNetwork.framework" weak="true" />
|
||||
@@ -161,25 +161,14 @@
|
||||
|
||||
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||
<receiver
|
||||
android:name="cn.jiguang.cordova.push.MyReceiver"
|
||||
android:name="cn.jiguang.cordova.push.JPushReceiver"
|
||||
android:enabled="true">
|
||||
<intent-filter android:priority="1000">
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
|
||||
<!-- Required 显示通知栏 -->
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.REGISTRATION" />
|
||||
<!-- Required 用户注册SDK的intent -->
|
||||
<action android:name="cn.jpush.android.intent.UNREGISTRATION" />
|
||||
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
|
||||
<!-- Required 用户接收SDK消息的intent -->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
||||
<!-- Required 用户接收SDK通知栏信息的intent -->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
||||
<!-- Required 用户打开自定义通知栏的intent -->
|
||||
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
|
||||
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
|
||||
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
@@ -198,7 +187,7 @@
|
||||
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||
<category android:name="$PACKAGE_NAME"></category>
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
@@ -207,9 +196,9 @@
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/libs/jpush-android-3.0.9.jar" target-dir="libs" />
|
||||
<source-file src="src/android/libs/jpush-android-3.1.1.jar" target-dir="libs" />
|
||||
|
||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushEventReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
callback.success(resultJson);
|
||||
|
||||
} else {
|
||||
try {
|
||||
@@ -103,7 +104,6 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
callback.error(resultJson);
|
||||
}
|
||||
|
||||
|
||||
@@ -527,24 +527,6 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
eventCallbackMap.put(sequence, callbackContext);
|
||||
}
|
||||
|
||||
void setTagsWithAlias(JSONArray data, CallbackContext callbackContext) {
|
||||
HashSet<String> tags = new HashSet<String>();
|
||||
String alias;
|
||||
try {
|
||||
alias = data.getString(0);
|
||||
JSONArray tagsArray = data.getJSONArray(1);
|
||||
for (int i = 0; i < tagsArray.length(); i++) {
|
||||
tags.add(tagsArray.getString(i));
|
||||
}
|
||||
JPushInterface.setAliasAndTags(mContext,
|
||||
alias, tags, mTagWithAliasCallback);
|
||||
callbackContext.success();
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
callbackContext.error("Error reading tagAlias JSON");
|
||||
}
|
||||
}
|
||||
|
||||
void getConnectionState(JSONArray data, CallbackContext callback) {
|
||||
boolean isConnected = JPushInterface.getConnectionState(cordovaActivity.getApplicationContext());
|
||||
callback.success(String.valueOf(isConnected));
|
||||
@@ -553,8 +535,7 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
/**
|
||||
* 自定义通知行为,声音、震动、呼吸灯等。
|
||||
*/
|
||||
void setBasicPushNotificationBuilder(JSONArray data,
|
||||
CallbackContext callbackContext) {
|
||||
void setBasicPushNotificationBuilder(JSONArray data, CallbackContext callbackContext) {
|
||||
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
||||
this.cordova.getActivity());
|
||||
builder.developerArg0 = "Basic builder 1";
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class MyReceiver extends BroadcastReceiver {
|
||||
public class JPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final List<String> IGNORED_EXTRAS_KEYS =
|
||||
Arrays.asList(
|
||||
@@ -56,17 +56,14 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
||||
context.getPackageName());
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(launch);
|
||||
if (launch != null) {
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(launch);
|
||||
}
|
||||
}
|
||||
|
||||
private void handlingNotificationReceive(Context context, Intent intent) {
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
||||
context.getPackageName());
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
|
||||
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||
JPushPlugin.notificationTitle = title;
|
||||
|
||||
Binary file not shown.
BIN
src/android/libs/jpush-android-3.1.1.jar
Executable file
BIN
src/android/libs/jpush-android-3.1.1.jar
Executable file
Binary file not shown.
@@ -28,25 +28,24 @@
|
||||
return [self init_plus];
|
||||
}
|
||||
|
||||
-(void)fireOpenNotification:(NSTimer*)timer{
|
||||
if (SharedJPushPlugin) {
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[timer.userInfo toJsonString]];
|
||||
[timer invalidate];
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *_launchOptions;
|
||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil];
|
||||
if (!_jpushEventCache) {
|
||||
_jpushEventCache = @{}.mutableCopy;
|
||||
}
|
||||
|
||||
[JPUSHService registrationIDCompletionHandler:^(int resCode, NSString *registrationID) {
|
||||
NSDictionary *event = @{@"registrationId": registrationID?:@""};
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
|
||||
}];
|
||||
|
||||
if (notification) {
|
||||
if (notification.userInfo) {
|
||||
|
||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:)
|
||||
userInfo:[notification.userInfo
|
||||
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] repeats:YES];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification
|
||||
jsString:[[self jpushFormatAPNSDic: notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]] toJsonString]];
|
||||
}
|
||||
|
||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
||||
@@ -56,7 +55,7 @@ NSDictionary *_launchOptions;
|
||||
@"badge": @(localNotification.applicationIconBadgeNumber),
|
||||
@"extras":localNotification.userInfo,
|
||||
};
|
||||
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:localNotificationEvent repeats:YES];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +83,23 @@ NSDictionary *_launchOptions;
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary *)jpushFormatAPNSDic:(NSDictionary *)dic {
|
||||
NSMutableDictionary *extras = @{}.mutableCopy;
|
||||
for (NSString *key in dic) {
|
||||
if([key isEqualToString:@"_j_business"] ||
|
||||
[key isEqualToString:@"_j_msgid"] ||
|
||||
[key isEqualToString:@"_j_uid"] ||
|
||||
[key isEqualToString:@"actionIdentifier"] ||
|
||||
[key isEqualToString:@"aps"]) {
|
||||
continue;
|
||||
}
|
||||
extras[key] = dic[key];
|
||||
}
|
||||
NSMutableDictionary *formatDic = dic.mutableCopy;
|
||||
formatDic[@"extras"] = extras;
|
||||
return formatDic;
|
||||
}
|
||||
|
||||
-(void)registerForRemoteNotification{
|
||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
||||
@@ -132,30 +148,63 @@ NSDictionary *_launchOptions;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
[JPushPlugin fireDocumentEvent:eventName jsString:[userInfo toJsonString]];
|
||||
|
||||
[JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
completionHandler(UIBackgroundFetchResultNewData);
|
||||
});
|
||||
}
|
||||
|
||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||
NSMutableDictionary *userInfo = @{}.mutableCopy;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body,
|
||||
@"badge": content.badge,
|
||||
@"extras": content.userInfo
|
||||
}];
|
||||
userInfo[@"identifier"] = notification.request.identifier;
|
||||
}
|
||||
|
||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||
|
||||
if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件
|
||||
return;
|
||||
}
|
||||
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
||||
|
||||
}
|
||||
|
||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
||||
@try {
|
||||
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
||||
} @catch (NSException *exception) { }
|
||||
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler();
|
||||
UNNotification *notification = response.notification;
|
||||
NSMutableDictionary *userInfo = nil;
|
||||
|
||||
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||
} else {
|
||||
UNNotificationContent *content = notification.request.content;
|
||||
userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body,
|
||||
@"badge": content.badge,
|
||||
@"extras": content.userInfo
|
||||
}];
|
||||
userInfo[@"identifier"] = notification.request.identifier;
|
||||
}
|
||||
|
||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
||||
completionHandler();
|
||||
}
|
||||
|
||||
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:notification.userInfo];
|
||||
NSDictionary* localNotificationEvent = @{@"content":notification.alertBody,
|
||||
@"badge": @(notification.applicationIconBadgeNumber),
|
||||
@"extras":notification.userInfo,
|
||||
};
|
||||
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:localNotificationEvent];
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
|
||||
@@ -1,103 +1,102 @@
|
||||
//
|
||||
// PushTalkPlugin.h
|
||||
// PushTalk
|
||||
//
|
||||
// Created by zhangqinghe on 13-12-13.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
@interface JPushPlugin : CDVPlugin{
|
||||
|
||||
}
|
||||
|
||||
//注册通知服务并启动 SDK
|
||||
-(void)startJPushSDK:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//以下为js中可调用接口
|
||||
//设置标签、别名
|
||||
-(void)setTagsWithAlias:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)addTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)cleanTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getAllTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)checkTagBindState:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getAlias:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//获取 RegistrationID
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//页面统计
|
||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
-(void)beginLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//设置角标到服务器,服务器下一次发消息时,会设置成这个值
|
||||
//本接口不会改变应用本地的角标值.
|
||||
-(void)setBadge:(CDVInvokedUrlCommand*)command;
|
||||
//相当于 [setBadge:0]
|
||||
-(void)resetBadge:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//应用本地的角标值设置/获取
|
||||
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//停止与恢复推送
|
||||
-(void)stopPush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)resumePush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)isPushStopped:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//开关日志
|
||||
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setLogOFF:(CDVInvokedUrlCommand*)command;
|
||||
-(void)crashLogON:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//本地推送
|
||||
-(void)setLocalNotification:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command;
|
||||
-(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//地理位置上报 [latitude,longitude]
|
||||
-(void)setLocation:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//检查用户的推送设置情况
|
||||
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//ios 10 APIs
|
||||
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
|
||||
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
/*
|
||||
* 以下为js中可监听到的事件
|
||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||
* jpush.setTagsWithAlias 设置标签、别名完成
|
||||
* jpush.receiveMessage 收到自定义消息
|
||||
* jpush.receiveNotification 前台收到推送
|
||||
* jpush.backgroundNotification 后台收到推送
|
||||
*/
|
||||
|
||||
# pragma mark - private
|
||||
|
||||
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
|
||||
|
||||
+(void)setupJPushSDK:(NSDictionary*)userInfo;
|
||||
|
||||
@end
|
||||
|
||||
JPushPlugin *SharedJPushPlugin;
|
||||
|
||||
@interface NSDictionary (JPush)
|
||||
-(NSString*)toJsonString;
|
||||
@end
|
||||
|
||||
@interface NSString (JPush)
|
||||
-(NSDictionary*)toDictionary;
|
||||
@end
|
||||
|
||||
|
||||
//
|
||||
// PushTalkPlugin.h
|
||||
// PushTalk
|
||||
//
|
||||
// Created by zhangqinghe on 13-12-13.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Cordova/CDV.h>
|
||||
|
||||
static NSMutableDictionary *_jpushEventCache;
|
||||
|
||||
@interface JPushPlugin : CDVPlugin{
|
||||
|
||||
}
|
||||
|
||||
//注册通知服务并启动 SDK
|
||||
-(void)startJPushSDK:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//以下为js中可调用接口
|
||||
//设置标签、别名
|
||||
-(void)setTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)addTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)cleanTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getAllTags:(CDVInvokedUrlCommand*)command;
|
||||
-(void)checkTagBindState:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
-(void)setAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteAlias:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getAlias:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//获取 RegistrationID
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//页面统计
|
||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
-(void)beginLogPageView:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//设置角标到服务器,服务器下一次发消息时,会设置成这个值
|
||||
//本接口不会改变应用本地的角标值.
|
||||
-(void)setBadge:(CDVInvokedUrlCommand*)command;
|
||||
//相当于 [setBadge:0]
|
||||
-(void)resetBadge:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//应用本地的角标值设置/获取
|
||||
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
|
||||
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//停止与恢复推送
|
||||
-(void)stopPush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)resumePush:(CDVInvokedUrlCommand*)command;
|
||||
-(void)isPushStopped:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//开关日志
|
||||
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
|
||||
-(void)setLogOFF:(CDVInvokedUrlCommand*)command;
|
||||
-(void)crashLogON:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//本地推送
|
||||
-(void)setLocalNotification:(CDVInvokedUrlCommand*)command;
|
||||
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command;
|
||||
-(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//地理位置上报 [latitude,longitude]
|
||||
-(void)setLocation:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//检查用户的推送设置情况
|
||||
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//ios 10 APIs
|
||||
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
|
||||
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
/*
|
||||
* 以下为js中可监听到的事件
|
||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||
* jpush.receiveMessage 收到自定义消息
|
||||
* jpush.receiveNotification 前台收到推送
|
||||
* jpush.backgroundNotification 后台收到推送
|
||||
*/
|
||||
|
||||
# pragma mark - private
|
||||
|
||||
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
|
||||
|
||||
+(void)setupJPushSDK:(NSDictionary*)userInfo;
|
||||
|
||||
@end
|
||||
|
||||
static JPushPlugin *SharedJPushPlugin;
|
||||
|
||||
@interface NSDictionary (JPush)
|
||||
-(NSString*)toJsonString;
|
||||
@end
|
||||
|
||||
@interface NSString (JPush)
|
||||
-(NSDictionary*)toDictionary;
|
||||
@end
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
||||
* Copyright (c) 2011 ~ 2017 Shenzhen HXHG. All rights reserved.
|
||||
*/
|
||||
|
||||
#define JPUSH_VERSION_NUMBER 3.0.6
|
||||
#define JPUSH_VERSION_NUMBER 3.0.7
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
||||
Binary file not shown.
@@ -70,20 +70,6 @@ JPushPlugin.prototype.clearLocalNotifications = function () {
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setTagsWithAlias = function (tags, alias, successCallback, errorCallback) {
|
||||
if (tags == null) {
|
||||
this.setAlias(alias)
|
||||
return
|
||||
}
|
||||
if (alias == null) {
|
||||
this.setTags(tags)
|
||||
return
|
||||
}
|
||||
var arrayTagWithAlias = [tags]
|
||||
arrayTagWithAlias.unshift(alias)
|
||||
this.callNative('setTagsWithAlias', arrayTagWithAlias, successCallback, errorCallback)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置标签。
|
||||
* 注意:该接口是覆盖逻辑,而不是增量逻辑。即新的调用会覆盖之前的设置。
|
||||
|
||||
Reference in New Issue
Block a user