mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
Compare commits
40 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 |
+30
@@ -36,4 +36,34 @@ Network Trash Folder
|
|||||||
Temporary Items
|
Temporary Items
|
||||||
.apdisk
|
.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
|
# End of https://www.gitignore.io/api/macos,apachecordova
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# JPush PhoneGap / Cordova Plugin
|
# JPush PhoneGap / Cordova Plugin
|
||||||
|
|
||||||
[](https://travis-ci.org/jpush/jpush-phonegap-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)
|
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[](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-jsms](https://github.com/jpush/cordova-plugin-jsms)
|
||||||
- 如需要统计分析功能插件,可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics)
|
- 如需要统计分析功能插件,可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics)
|
||||||
|
|
||||||
|
注意:目前插件暂未支持 cordova-android 7.0.0,因此在添加 android platform 时,请指定 7.0.0 以下版本,例如 6.4.0。
|
||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
|
> 注意:
|
||||||
|
>
|
||||||
|
> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
|
||||||
|
> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
|
||||||
|
|
||||||
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:
|
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
@@ -31,7 +38,28 @@
|
|||||||
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
|
## Usage
|
||||||
|
|
||||||
@@ -72,14 +100,13 @@
|
|||||||
Android 因为各 Rom 的高度定制化,不像 iOS 一样能有一个统一的管理,如果在 Android 中想自定义通知铃声,推荐通过 JPush 推送自定义
|
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) 插件保证应用的后台运行。
|
消息,之后在 `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)
|
[#267](https://github.com/jpush/jpush-phonegap-plugin/issues/267)
|
||||||
|
|
||||||
#### 关闭 App 后收不到通知
|
#### 关闭 App 后收不到通知
|
||||||
|
|
||||||
Android 的推送通过长连接的方式实现,只有在连接保持的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动,也就是
|
Android 的推送通过长连接的方式实现,只有在保持连接的情况下才能收到通知。而有的第三方 ROM 会限制一般应用服务的自启动,也就是在退出应用后,应用的所有服务均被杀死,且无法自启动,所以就会收不到通知。
|
||||||
在退出应用后,应用的所有服务均被杀死,且无法自启动,所以就会收不到通知。
|
|
||||||
|
|
||||||
目前 JPush 是做了应用互相拉起机制的,也就是当用户打开其他集成了 JPush 的应用时,你的应用也能同时收到推送消息。
|
目前 JPush 是做了应用互相拉起机制的,也就是当用户打开其他集成了 JPush 的应用时,你的应用也能同时收到推送消息。
|
||||||
|
|
||||||
@@ -98,10 +125,6 @@ Android 的推送通过长连接的方式实现,只有在连接保持的情况
|
|||||||
cordova platform update ios
|
cordova platform update ios
|
||||||
```
|
```
|
||||||
|
|
||||||
#### ionic 2 如何调用 API?
|
|
||||||
|
|
||||||
[issue 179](https://github.com/jpush/jpush-phonegap-plugin/issues/179)
|
|
||||||
|
|
||||||
#### PushConfig.plist 文件中的字段都是什么意思?
|
#### PushConfig.plist 文件中的字段都是什么意思?
|
||||||
|
|
||||||
- Appkey:应用标识。
|
- Appkey:应用标识。
|
||||||
|
|||||||
+30
-2
@@ -143,7 +143,7 @@ window.JPush.getRegistrationID(function(data) {
|
|||||||
|
|
||||||
#### event - jpush.openNotification
|
#### event - jpush.openNotification
|
||||||
|
|
||||||
点击通知启动或唤醒应用程序时会触发该事件
|
点击通知(包括 localNotification 和 remoteNotification)启动或唤醒应用程序时会触发该事件
|
||||||
|
|
||||||
#### 代码示例
|
#### 代码示例
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ window.JPush.addLocalNotificationForIOS(delayTime, content, badge, notificationI
|
|||||||
|
|
||||||
#### 参数说明
|
#### 参数说明
|
||||||
|
|
||||||
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可。
|
- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可,单位为秒。
|
||||||
- content: 本地推送需要显示的内容。
|
- content: 本地推送需要显示的内容。
|
||||||
- badge: 角标的数字。如果不需要改变角标传-1。数值类型或纯数字的字符型均可。
|
- badge: 角标的数字。如果不需要改变角标传-1。数值类型或纯数字的字符型均可。
|
||||||
- notificationID: 本地推送标识符,字符串。
|
- notificationID: 本地推送标识符,字符串。
|
||||||
@@ -433,6 +433,34 @@ window.JPush.clearAllLocalNotifications()
|
|||||||
|
|
||||||
监听 `jpush.receiveLocalNotification` 事件获取,「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。
|
监听 `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 收到本地通知
|
### iOS 10 收到本地通知
|
||||||
|
|
||||||
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
|
监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。
|
||||||
|
|||||||
+20
-16
@@ -9,7 +9,13 @@
|
|||||||
<script type="text/javascript" src="js/jquery.mobile-1.1.1.js"></script>
|
<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" src="cordova.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var onDeviceReady = function() {
|
var onDeviceReady = function() {
|
||||||
|
document.addEventListener("jpush.receiveRegistrationId", function (event) {
|
||||||
|
alert("receiveRegistrationId" + JSON.stringify(event));
|
||||||
|
$("#registrationId").html(event.registrationId);
|
||||||
|
}, false)
|
||||||
|
|
||||||
initiateUI();
|
initiateUI();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -88,13 +94,11 @@
|
|||||||
var initiateUI = function() {
|
var initiateUI = function() {
|
||||||
try {
|
try {
|
||||||
window.JPush.init();
|
window.JPush.init();
|
||||||
|
window.JPush.setDebugMode(true);
|
||||||
window.setTimeout(getRegistrationID, 1000);
|
window.setTimeout(getRegistrationID, 1000);
|
||||||
|
|
||||||
if (device.platform != "Android") {
|
if (device.platform != "Android") {
|
||||||
window.JPush.setDebugModeFromIos();
|
|
||||||
window.JPush.setApplicationIconBadgeNumber(0);
|
window.JPush.setApplicationIconBadgeNumber(0);
|
||||||
} else {
|
|
||||||
window.JPush.setDebugMode(true);
|
|
||||||
window.JPush.setStatisticsOpen(true);
|
|
||||||
}
|
}
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
console.log(exception);
|
console.log(exception);
|
||||||
@@ -118,9 +122,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
window.JPush.setTags({ sequence: 1, tags: tags },
|
window.JPush.setTags({ sequence: 1, tags: tags },
|
||||||
(result) => {
|
function (result) {
|
||||||
$("#tagsResult").html(result.tags)
|
$("#tagsResult").html(result.tags)
|
||||||
}, (error) => {
|
}, function (error) {
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
} catch (exception) {
|
} catch (exception) {
|
||||||
@@ -130,19 +134,19 @@
|
|||||||
|
|
||||||
$("#getAllTags").click(function (event) {
|
$("#getAllTags").click(function (event) {
|
||||||
window.JPush.getAllTags({ sequence: 2 },
|
window.JPush.getAllTags({ sequence: 2 },
|
||||||
(result) => {
|
function (result) {
|
||||||
$("#tagsResult").html(result.tags)
|
$("#tagsResult").html(result.tags)
|
||||||
}, (error) => {
|
}, function (error) {
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#cleanTags").click(function (event) {
|
$("#cleanTags").click(function (event) {
|
||||||
window.JPush.cleanTags({ sequence: 2 },
|
window.JPush.cleanTags({ sequence: 2 },
|
||||||
(result) => {
|
function (result) {
|
||||||
alert(result.sequence)
|
alert(result.sequence)
|
||||||
$("#tagsResult").html("")
|
$("#tagsResult").html("")
|
||||||
}, (error) => {
|
}, function (error) {
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -150,27 +154,27 @@
|
|||||||
$("#setAlias").click(function (event) {
|
$("#setAlias").click(function (event) {
|
||||||
var alias = $("#aliasText").val()
|
var alias = $("#aliasText").val()
|
||||||
window.JPush.setAlias({ sequence: 1, alias: alias },
|
window.JPush.setAlias({ sequence: 1, alias: alias },
|
||||||
(result) => {
|
function (result) {
|
||||||
$("#aliasResult").html(result.alias)
|
$("#aliasResult").html(result.alias)
|
||||||
}, (error) => {
|
}, function (error){
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
$("#getAlias").click(function (event) {
|
$("#getAlias").click(function (event) {
|
||||||
window.JPush.getAlias({ sequence: 2 },
|
window.JPush.getAlias({ sequence: 2 },
|
||||||
(result) => {
|
function (result) {
|
||||||
alert(JSON.stringify(result));
|
alert(JSON.stringify(result));
|
||||||
}, (error) => {
|
}, function (error) {
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#deleteAlias").click(function (event) {
|
$("#deleteAlias").click(function (event) {
|
||||||
window.JPush.deleteAlias({ sequence: 3 },
|
window.JPush.deleteAlias({ sequence: 3 },
|
||||||
(result) => {
|
function (result) {
|
||||||
alert(JSON.stringify(result));
|
alert(JSON.stringify(result));
|
||||||
}, (error) => {
|
}, function (error) {
|
||||||
alert(error.code)
|
alert(error.code)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
@@ -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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<ion-nav [root]="rootPage"></ion-nav>
|
||||||
@@ -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 {}
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
page-home {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
@@ -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
|
||||||
|
}
|
||||||
Vendored
+67
@@ -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>;
|
||||||
|
}
|
||||||
@@ -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
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "3.2.12",
|
"version": "3.3.2",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
|||||||
+6
-17
@@ -2,7 +2,7 @@
|
|||||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
id="jpush-phonegap-plugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="3.2.12">
|
version="3.3.2">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
@@ -161,25 +161,14 @@
|
|||||||
|
|
||||||
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||||
<receiver
|
<receiver
|
||||||
android:name="cn.jiguang.cordova.push.MyReceiver"
|
android:name="cn.jiguang.cordova.push.JPushReceiver"
|
||||||
android:enabled="true">
|
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>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.intent.REGISTRATION" />
|
<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" />
|
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
|
||||||
<!-- Required 用户接收SDK消息的intent -->
|
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
||||||
<!-- Required 用户接收SDK通知栏信息的intent -->
|
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
||||||
<!-- Required 用户打开自定义通知栏的intent -->
|
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
||||||
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
|
|
||||||
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
|
|
||||||
<category android:name="$PACKAGE_NAME" />
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
@@ -198,7 +187,7 @@
|
|||||||
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||||
<category android:name="$PACKAGE_NAME"></category>
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
@@ -207,9 +196,9 @@
|
|||||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
||||||
</config-file>
|
</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/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||||
<source-file src="src/android/JPushEventReceiver.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) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
callback.success(resultJson);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@@ -103,7 +104,6 @@ public class JPushEventReceiver extends JPushMessageReceiver {
|
|||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.error(resultJson);
|
callback.error(resultJson);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
|
|
||||||
public class MyReceiver extends BroadcastReceiver {
|
public class JPushReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
private static final List<String> IGNORED_EXTRAS_KEYS =
|
private static final List<String> IGNORED_EXTRAS_KEYS =
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@@ -56,17 +56,14 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
||||||
context.getPackageName());
|
context.getPackageName());
|
||||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
if (launch != null) {
|
||||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||||
context.startActivity(launch);
|
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
context.startActivity(launch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlingNotificationReceive(Context context, Intent intent) {
|
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);
|
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||||
JPushPlugin.notificationTitle = title;
|
JPushPlugin.notificationTitle = title;
|
||||||
|
|
||||||
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -44,7 +44,8 @@ NSDictionary *_launchOptions;
|
|||||||
if (notification.userInfo) {
|
if (notification.userInfo) {
|
||||||
|
|
||||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[notification.userInfo toJsonString]];
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification
|
||||||
|
jsString:[[self jpushFormatAPNSDic: notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]] toJsonString]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
|
||||||
@@ -82,6 +83,23 @@ NSDictionary *_launchOptions;
|
|||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
|
[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{
|
-(void)registerForRemoteNotification{
|
||||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||||
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
||||||
@@ -130,26 +148,54 @@ NSDictionary *_launchOptions;
|
|||||||
default:
|
default:
|
||||||
break;
|
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(), ^{
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||||
completionHandler(UIBackgroundFetchResultNewData);
|
completionHandler(UIBackgroundFetchResultNewData);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
NSMutableDictionary *userInfo = @{}.mutableCopy;
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
|
|
||||||
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
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{
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||||
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
UNNotification *notification = response.notification;
|
||||||
@try {
|
NSMutableDictionary *userInfo = nil;
|
||||||
[userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"];
|
|
||||||
} @catch (NSException *exception) { }
|
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
|
||||||
[userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"];
|
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
|
||||||
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]];
|
} else {
|
||||||
completionHandler();
|
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 {
|
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
|
||||||
|
|||||||
@@ -241,7 +241,7 @@
|
|||||||
CDVPluginResult* result;
|
CDVPluginResult* result;
|
||||||
|
|
||||||
if (iResCode == 0) {
|
if (iResCode == 0) {
|
||||||
[dic setObject:[iTags allObjects] forKey:@"tags"];
|
dic[@"tag"] = tag;
|
||||||
[dic setObject:[NSNumber numberWithBool:isBind] forKey:@"isBind"];
|
[dic setObject:[NSNumber numberWithBool:isBind] forKey:@"isBind"];
|
||||||
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic];
|
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic];
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user