mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-03-03 21:32:51 +08:00
Merge branch 'dev'
This commit is contained in:
commit
c2bf4db67a
19
README.md
19
README.md
@ -63,14 +63,14 @@ JPush-PhoneGap-Plugin 支持 iOS, Android 的推送插件。
|
||||
window.plugins.jPushPlugin.init();
|
||||
|
||||
|
||||
### Android 手工安装
|
||||
### Android 手动安装
|
||||
|
||||
[Android 手工安装文档地址](document/Android_handle_install.md)
|
||||
[Android 手动安装文档地址](document/Android_handle_install.md)
|
||||
|
||||
|
||||
### iOS 手工安装
|
||||
### iOS 手动安装
|
||||
|
||||
[IOS手工安装文档地址](document/iOS_handle_install.md)
|
||||
[IOS手动安装文档地址](document/iOS_handle_install.md)
|
||||
|
||||
|
||||
###示例
|
||||
@ -118,6 +118,8 @@ iOS:
|
||||
window.plugins.jPushPlugin.setTags(tags)
|
||||
window.plugins.jPushPlugin.setAlias(alias)
|
||||
|
||||
event - jpush.setTagsWithAlias //三个方法都是触发该回调事件
|
||||
|
||||
+ 获取点击通知内容
|
||||
|
||||
event - jpush.openNotification
|
||||
@ -137,10 +139,11 @@ iOS:
|
||||
|
||||
+ 获取自定义消息推送内容
|
||||
|
||||
event - jpush.receiveMessage
|
||||
//推荐使用事件的方式传递,但同时保留了 receiveMessageIniOSCallback 的回调函数,兼容以前的代码
|
||||
window.plugins.jPushPlugin.receiveMessageIniOSCallback(data)
|
||||
|
||||
event - jpush.receiveMessage
|
||||
|
||||
+ 页面的统计
|
||||
|
||||
window.plugins.jPushPlugin.startLogPageView(pageName)
|
||||
@ -156,7 +159,8 @@ iOS:
|
||||
|
||||
+ 本地通知
|
||||
|
||||
window.plugins.JPushPlugin.addLocalNotificationForIOS(delayTime, content, badge, notificationID, extras)
|
||||
window.plugins.JPushPlugin.addLocalNotificationForIOS(delayTime, content,
|
||||
badge, notificationID, extras)
|
||||
window.plugins.JPushPlugin.deleteLocalNotificationWithIdentifierKeyInIOS()
|
||||
window.plugins.JPushPlugin.clearAllLocalNotifications()
|
||||
|
||||
@ -231,6 +235,5 @@ iOS:
|
||||
IsProduction: 是否生产环境(暂未启用)
|
||||
|
||||
|
||||
|
||||
###更多
|
||||
[ JPush 官网文档](http://docs.jpush.io/)
|
||||
[JPush 官网文档](http://docs.jpush.io/)
|
||||
|
@ -1,12 +1,36 @@
|
||||
## Android API简介
|
||||
|
||||
|
||||
### 接收通知时获得通知的信息
|
||||
|
||||
- 内容
|
||||
window.plugins.jPushPlugin.receiveNotification.alert;
|
||||
- 标题
|
||||
window.plugins.jPushPlugin.receiveNotification.title;
|
||||
- 附加字段
|
||||
window.plugins.jPushPlugin.receiveNotification.extras.yourKey;
|
||||
|
||||
### 打开通知时获得通知的信息
|
||||
|
||||
- 内容
|
||||
window.plugins.jPushPlugin.openNotification.alert;
|
||||
- 标题
|
||||
window.plugins.jPushPlugin.openNotification.title;
|
||||
- 附加字段
|
||||
window.plugins.jPushPlugin.openNotification.extras.yourKey;
|
||||
|
||||
### 收到自定义消息时获得通知的信息
|
||||
|
||||
- 内容
|
||||
window.plugins.jPushPlugin.openNotification.message;
|
||||
- 附加字段
|
||||
window.plugins.jPushPlugin.openNotification.extras.yourKey;
|
||||
|
||||
### 获取集成日志
|
||||
|
||||
#### API - setDebugMode
|
||||
|
||||
用于开启调试模式,可以查看集成 JPush 过程中的 Log,如果集成失败,可方便定位问题所在
|
||||
用于开启调试模式,可以查看集成 JPush 过程中的 Log,如果集成失败,可方便定位问题所在。
|
||||
|
||||
##### 接口定义
|
||||
|
||||
@ -23,27 +47,28 @@
|
||||
### 接收消息和点击通知事件
|
||||
#### API - receiveMessageInAndroidCallback
|
||||
|
||||
用于 Android 收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用
|
||||
用于 Android 收到应用内消息的回调函数(请注意和通知的区别),该函数不需要主动调用。
|
||||
|
||||
##### 接口定义
|
||||
|
||||
window.plugins.jPushPlugin.receiveMessageInAndroidCallback = function(data)
|
||||
|
||||
##### 参数说明
|
||||
- data 接收到的 js 字符串,包含的 key:value 请进入该函数体查看
|
||||
|
||||
- data 接收到的 js 字符串,包含的 key:value 请进入该函数体查看。
|
||||
|
||||
##### 代码示例
|
||||
|
||||
#### API - openNotificationInAndroidCallback
|
||||
|
||||
当点击 Android 手机的通知栏进入应用程序时,会调用这个函数,这个函数不需要主动调用,是作为回调函数来用的
|
||||
|
||||
当点击 Android 手机的通知栏进入应用程序时,会调用这个函数,这个函数不需要主动调用,是作为回调函数来用的。
|
||||
|
||||
##### 接口定义
|
||||
|
||||
window.plugins.jPushPlugin.openNotificationInAndroidCallback = function(data)
|
||||
|
||||
##### 参数说明
|
||||
|
||||
- data js字符串
|
||||
|
||||
##### 代码示例
|
||||
@ -51,18 +76,20 @@
|
||||
### 统计分析 API
|
||||
|
||||
#### API - onResume / onPause
|
||||
这是一个 android local api,不是 js 的 API,请注意
|
||||
本 API 用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器,在 Portal 上展示给开发者。
|
||||
|
||||
这是一个 Android Local API,不是 js 的 API,请注意
|
||||
本 API 用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器,在 Portal 上展示给开发者。
|
||||
|
||||
|
||||
####接口定义
|
||||
|
||||
public static void onResume(final Activity activity)
|
||||
public static void onPause(final Activity activity)
|
||||
|
||||
####参数说明
|
||||
|
||||
+ Activity activity 当前所在的 Activity。
|
||||
+ Activity 当前所在的 Activity。
|
||||
|
||||
####调用说明
|
||||
|
||||
应在所有的 Activity 的 onResume / onPause 方法里调用。
|
||||
@ -74,6 +101,7 @@
|
||||
super.onResume();
|
||||
JPushInterface.onResume(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
@ -90,22 +118,22 @@
|
||||
window.plugins.jPushPlugin.setStatisticsOpen(boolean)
|
||||
|
||||
#### 参数说明
|
||||
|
||||
- boolean
|
||||
-true : 打开统计分析功能
|
||||
-false: 关闭统计分析功能
|
||||
- true : 打开统计分析功能
|
||||
- false: 关闭统计分析功能
|
||||
|
||||
#### API - reportNotificationOpened
|
||||
|
||||
用于上报用户的通知栏被打开,或者用于上报用户自定义消息被展示等客户端需要统计的事件。
|
||||
|
||||
|
||||
##### 接口定义
|
||||
|
||||
window.plugins.jPushPlugin.reportNotificationOpened(msgID)
|
||||
|
||||
##### 参数说明
|
||||
- msgID
|
||||
-收到的通知或者自定义消息的 id
|
||||
- 收到的通知或者自定义消息的 id
|
||||
|
||||
|
||||
### 清除通知 API
|
||||
@ -114,7 +142,7 @@
|
||||
|
||||
推送通知到客户端时,由 JPush SDK 展现通知到通知栏上。
|
||||
|
||||
此 API 提供清除通知的功能,包括:清除所有 JPush 展现的通知(不包括非 JPush SDK 展现的)
|
||||
此 API 提供清除通知的功能,包括:清除所有 JPush 展现的通知(不包括非 JPush SDK 展现的)。
|
||||
|
||||
|
||||
##### 接口定义
|
||||
@ -131,9 +159,9 @@
|
||||
极光 Push SDK 提供了 2 个用于定制通知栏样式的构建类:
|
||||
|
||||
- setBasicPushNotificationBuilder
|
||||
- Basic 用于定制 Android Notification 里的 defaults / flags / icon 等基础样式(行为)
|
||||
- Basic 用于定制 Android Notification 里的 defaults / flags / icon 等基础样式(行为)。
|
||||
- setCustomPushNotificationBuilder
|
||||
- 继承 Basic 进一步让开发者定制 Notification Layout
|
||||
- 继承 Basic 进一步让开发者定制 Notification Layout。
|
||||
|
||||
如果不调用此方法定制,则极光 Push SDK 默认的通知栏样式是:Android 标准的通知栏提示。
|
||||
|
||||
@ -166,14 +194,14 @@
|
||||
#### API - addLocalNotification,removeLocalNotification,clearLocalNotifications
|
||||
|
||||
|
||||
本地通知 API 不依赖于网络,无网条件下依旧可以触发
|
||||
本地通知 API 不依赖于网络,无网条件下依旧可以触发。
|
||||
|
||||
本地通知与网络推送的通知是相互独立的,不受保留最近通知条数上限的限制
|
||||
本地通知与网络推送的通知是相互独立的,不受保留最近通知条数上限的限制。
|
||||
|
||||
本地通知的定时时间是自发送时算起的,不受中间关机等操作的影响
|
||||
本地通知的定时时间是自发送时算起的,不受中间关机等操作的影响。
|
||||
|
||||
|
||||
三个接口的功能分别为:添加一个本地通知,删除一个本地通知,删除所有的本地通知
|
||||
三个接口的功能分别为:添加一个本地通知,删除一个本地通知,删除所有的本地通知。
|
||||
|
||||
#####接口定义
|
||||
|
||||
@ -184,9 +212,9 @@
|
||||
|
||||
##### 参数说明
|
||||
|
||||
- builderId 设置本地通知样式
|
||||
- content 设置本地通知的 content
|
||||
- title 设置本地通知的 title
|
||||
- notificaitonID 设置本地通知的 ID
|
||||
- broadcastTime 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒
|
||||
- extras 设置额外的数据信息 extras 为 json 字符串
|
||||
- builderId 设置本地通知样式。
|
||||
- content 设置本地通知的 content。
|
||||
- title 设置本地通知的 title。
|
||||
- notificaitonID 设置本地通知的 ID。
|
||||
- broadcastTime 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
|
||||
- extras 设置额外的数据信息 extras 为 json 字符串。
|
||||
|
@ -1,13 +1,21 @@
|
||||
#Android 手工安装
|
||||
#Android 手动安装
|
||||
|
||||
下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
|
||||
|
||||
1. 复制:`$JPUSH_PLUGIN_DIR`/src/android/*.java 到 cn/jpush/phonega/ 目录下(即:cn.jpush.phonegap 的包下)
|
||||
2. 复制:`$JPUSH_PLUGIN_DIR`/src/android/armeabi/libjpush.so 到 lib/armeabi/
|
||||
3. 复制:`$JPUSH_PLUGIN_DIR`/src/android/jpush-sdk-release2.0.6.jar 到 lib/
|
||||
4. 复制:`$JPUSH_PLUGIN_DIR`/src/android/test_notification_layout.xml 到 res/layout/
|
||||
5. 复制:`$JPUSH_PLUGIN_DIR`/src/android/jpush_notification_icon.png 到 res/drawable/
|
||||
6. 修改 AndroidManifest.xml 在 manifest 节点下添加以下权限
|
||||
1. 复制:$JPUSH_PLUGIN_DIR/src/android/*.java 到 cn/jpush/phonega/ 目录下(即:cn.jpush.phonegap 的包下)
|
||||
2. 复制:$JPUSH_PLUGIN_DIR/src/android/armeabi/libjpush.so 到 lib/armeabi/
|
||||
3. 复制:$JPUSH_PLUGIN_DIR/src/android/jpush-sdk-release2.0.6.jar 到 lib/
|
||||
4. 复制:$JPUSH_PLUGIN_DIR/src/android/test_notification_layout.xml 到 res/layout/
|
||||
5. 复制:$JPUSH_PLUGIN_DIR/src/android/jpush_notification_icon.png 到 res/drawable/
|
||||
6. 复制:$JPUSH_PLUGIN_DIR/www/JPushPlugin.js 到 assets/www/plugins/cn.jpush.phonegap.JPushPlugin.www/
|
||||
和 platform_www/plugins/cn.jpush.phonegap.JPushPlugin/www/
|
||||
并在 JPushPlugin.js 文件的代码外添加:
|
||||
|
||||
cordova.define("cn.jpush.phonegap.JPushPlugin.JPushPlugin", function(require, exports, module) {
|
||||
// 代码
|
||||
});
|
||||
|
||||
7. 修改 AndroidManifest.xml 在 manifest 节点下添加以下权限
|
||||
|
||||
<!-- Required 一些系统要求的权限,如访问网络等-->
|
||||
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"/>
|
||||
|
@ -1,4 +1,4 @@
|
||||
### iOS手工安装
|
||||
### iOS手动安装
|
||||
|
||||
下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
|
||||
|
||||
|
@ -3,49 +3,47 @@
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Phonegap Sample App</title>
|
||||
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css"/>
|
||||
<title>JPush Phonegap Simple Demo</title>
|
||||
<link href="css/jquery.mobile-1.1.1.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="js/jquery.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">
|
||||
var onDeviceReady = function () {
|
||||
var onDeviceReady = function() {
|
||||
console.log("JPushPlugin:Device ready!");
|
||||
initiateUI();
|
||||
};
|
||||
|
||||
function getRegistrationID() {
|
||||
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
||||
}
|
||||
var getRegistrationID = function() {
|
||||
window.plugins.jPushPlugin.getRegistrationID(onGetRegistrationID);
|
||||
};
|
||||
|
||||
var onGetRegistradionID = function (data) {
|
||||
var onGetRegistrationID = function(data) {
|
||||
try {
|
||||
|
||||
console.log("JPushPlugin:registrationID is " + data);
|
||||
|
||||
if (data.length == 0) {
|
||||
var t1 = window.setTimeout(getRegistrationID, 1000);
|
||||
}
|
||||
$("#registrationid").html(data);
|
||||
}
|
||||
catch (exception) {
|
||||
$("#registrationId").html(data);
|
||||
} catch (exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
};
|
||||
|
||||
var onTagsWithAlias = function (event) {
|
||||
var onTagsWithAlias = function(event) {
|
||||
try {
|
||||
console.log("onTagsWithAlias");
|
||||
var result = "result code:" + event.resultCode + " ";
|
||||
result += "tags:" + event.tags + " ";
|
||||
result += "alias:" + event.alias + " ";
|
||||
$("#tagAliasResult").html(result);
|
||||
}
|
||||
catch (exception) {
|
||||
} catch (exception) {
|
||||
console.log(exception)
|
||||
}
|
||||
};
|
||||
var onOpenNotification = function (event) {
|
||||
|
||||
var onOpenNotification = function(event) {
|
||||
try {
|
||||
var alertContent;
|
||||
if (device.platform == "Android") {
|
||||
@ -53,14 +51,13 @@
|
||||
} else {
|
||||
alertContent = event.aps.alert;
|
||||
}
|
||||
alert("open Notificaiton:" + alertContent);
|
||||
|
||||
}
|
||||
catch (exception) {
|
||||
alert("open Notification:" + alertContent);
|
||||
} catch (exception) {
|
||||
console.log("JPushPlugin:onOpenNotification" + exception);
|
||||
}
|
||||
};
|
||||
var onReceiveNotification = function (event) {
|
||||
|
||||
var onReceiveNotification = function(event) {
|
||||
try {
|
||||
var alertContent;
|
||||
if (device.platform == "Android") {
|
||||
@ -69,36 +66,29 @@
|
||||
alertContent = event.aps.alert;
|
||||
}
|
||||
$("#notificationResult").html(alertContent);
|
||||
|
||||
}
|
||||
catch (exeption) {
|
||||
} catch (exception) {
|
||||
console.log(exception)
|
||||
}
|
||||
};
|
||||
var onReceiveMessage = function (event) {
|
||||
try {
|
||||
|
||||
var onReceiveMessage = function(event) {
|
||||
try {
|
||||
var message;
|
||||
if (device.platform == "Android") {
|
||||
message = window.plugins.jPushPlugin.receiveMessage.message;
|
||||
} else {
|
||||
message = event.content;
|
||||
}
|
||||
//var extras = window.plugins.jPushPlugin.extras
|
||||
|
||||
$("#messageResult").html(message);
|
||||
|
||||
}
|
||||
catch (exception) {
|
||||
} catch (exception) {
|
||||
console.log("JPushPlugin:onReceiveMessage-->" + exception);
|
||||
}
|
||||
};
|
||||
|
||||
var initiateUI = function () {
|
||||
var initiateUI = function() {
|
||||
try {
|
||||
window.plugins.jPushPlugin.init();
|
||||
getRegistrationID();
|
||||
|
||||
if (device.platform != "Android") {
|
||||
window.plugins.jPushPlugin.setDebugModeFromIos();
|
||||
window.plugins.jPushPlugin.setApplicationIconBadgeNumber(0);
|
||||
@ -106,117 +96,103 @@
|
||||
window.plugins.jPushPlugin.setDebugMode(true);
|
||||
window.plugins.jPushPlugin.setStatisticsOpen(true);
|
||||
}
|
||||
}
|
||||
catch (exception) {
|
||||
} catch (exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
$("#setTagWithAliasButton").click(function (ev) {
|
||||
|
||||
// window.plugins.jPushPlugin.getApplicationIconBadgeNumber(function(data){
|
||||
// console.log(data);
|
||||
// });
|
||||
|
||||
$("#setTagWithAliasButton").click(function(ev) {
|
||||
try {
|
||||
var tag1 = $("#tagText1").attr("value");
|
||||
var tag2 = $("#tagText2").attr("value");
|
||||
var tag3 = $("#tagText3").attr("value");
|
||||
var alias = $("#aliasText").attr("value");
|
||||
var dd = [];
|
||||
var tags = [];
|
||||
|
||||
if (tag1 == "" && tag2 == "" && tag3 == "") {
|
||||
if (tag1 != "") {
|
||||
tags.push(tag1);
|
||||
}
|
||||
else {
|
||||
if (tag1 != "") {
|
||||
dd.push(tag1);
|
||||
}
|
||||
if (tag2 != "") {
|
||||
dd.push(tag2);
|
||||
}
|
||||
if (tag3 != "") {
|
||||
dd.push(tag3);
|
||||
}
|
||||
if (tag2 != "") {
|
||||
tags.push(tag2);
|
||||
}
|
||||
window.plugins.jPushPlugin.setTagsWithAlias(dd, alias);
|
||||
|
||||
}
|
||||
catch (exception) {
|
||||
if (tag3 != "") {
|
||||
tags.push(tag3);
|
||||
}
|
||||
window.plugins.jPushPlugin.setTagsWithAlias(tags, alias);
|
||||
} catch (exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
document.addEventListener("jpush.setTagsWithAlias", onTagsWithAlias, false);
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
document.addEventListener("jpush.openNotification", onOpenNotification, false);
|
||||
document.addEventListener("jpush.receiveNotification", onReceiveNotification, false);
|
||||
document.addEventListener("jpush.receiveMessage", onReceiveMessage, false);
|
||||
|
||||
|
||||
//jpush.receiveMessage
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div data-role="page" id="page">
|
||||
|
||||
<div data-role="content">
|
||||
<form>
|
||||
<div class="ui-body ui-body-b">
|
||||
|
||||
<div data-role="fieldcontain">
|
||||
<center><h3>JPushPlugin Example</h3></center>
|
||||
<span name="alias" id="alias"></span>
|
||||
<hr/>
|
||||
<label>RegistrationID: </label>
|
||||
<label id="registrationid">null</label>
|
||||
<div data-role="page" id="page">
|
||||
<div data-role="content">
|
||||
<form>
|
||||
<div class="ui-body ui-body-b">
|
||||
<div data-role="fieldcontain">
|
||||
<center>
|
||||
<h3>JPushPlugin Example</h3>
|
||||
</center>
|
||||
<span name="alias" id="alias"></span>
|
||||
<hr/>
|
||||
<label>RegistrationID: </label>
|
||||
<label id="registrationId">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label>Tags: </label>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText1" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText2" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText3" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<label>Alias: </label>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="aliasText" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<input type="button" id="setTagWithAliasButton"
|
||||
value="Add tag and alias" />
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="tagAliasPrompt">设置tag/alias结果:</label>
|
||||
<label id="tagAliasResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="notificationPrompt">接受的通知内容:</label>
|
||||
<label id="notificationResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="messagePrompt">接受的自定义消息:</label>
|
||||
<label id="messageResult">null</label>
|
||||
</div>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label>Tags: </label>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText1"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText2"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="tagText3">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<label>Alias: </label>
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="text" id="aliasText">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<input type="button" id="setTagWithAliasButton" value="Add tag and alias"/>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="tagAliasPrompt">设置tag/alias结果: </label>
|
||||
<label id="tagAliasResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="notificationPrompt">接受的通知内容:</label>
|
||||
<label id="notificationResult">null</label>
|
||||
</div>
|
||||
<div data-role="fieldcontain">
|
||||
<label id="messagePrompt">接受的自定义消息:</label>
|
||||
<label id="messageResult">null</label>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
12
plugin.xml
12
plugin.xml
@ -163,12 +163,12 @@
|
||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="$API_KEY"/>
|
||||
</config-file>
|
||||
<source-file src="src/android/jpush-android-2.1.0.jar" target-dir="libs"/>
|
||||
<source-file src="src/android/armeabi/libjpush210.so" target-dir="libs/armeabi"/>
|
||||
<source-file src="src/android/armeabi-v7a/libjpush210.so" target-dir="libs/armeabi-v7a"/>
|
||||
<source-file src="src/android/arm64-v8a/libjpush210.so" target-dir="libs/arm64-v8a"/>
|
||||
<source-file src="src/android/x86/libjpush210.so" target-dir="libs/x86"/>
|
||||
<source-file src="src/android/x86_64/libjpush210.so" target-dir="libs/x86_64"/>
|
||||
<source-file src="src/android/jpush-android-2.1.3.jar" target-dir="libs"/>
|
||||
<source-file src="src/android/armeabi/libjpush213.so" target-dir="libs/armeabi"/>
|
||||
<source-file src="src/android/armeabi-v7a/libjpush213.so" target-dir="libs/armeabi-v7a"/>
|
||||
<source-file src="src/android/arm64-v8a/libjpush213.so" target-dir="libs/arm64-v8a"/>
|
||||
<source-file src="src/android/x86/libjpush213.so" target-dir="libs/x86"/>
|
||||
<source-file src="src/android/x86_64/libjpush213.so" target-dir="libs/x86_64"/>
|
||||
|
||||
<!--<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>-->
|
||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
||||
|
@ -37,30 +37,32 @@ import cn.jpush.android.data.JPushLocalNotification;
|
||||
public class JPushPlugin extends CordovaPlugin {
|
||||
private final static List<String> methodList =
|
||||
Arrays.asList(
|
||||
"getRegistrationID",
|
||||
"setTags",
|
||||
"setTagsWithAlias",
|
||||
"setAlias",
|
||||
"getNotification",
|
||||
"setBasicPushNotificationBuilder",
|
||||
"setCustomPushNotificationBuilder",
|
||||
"setPushTime",
|
||||
"init",
|
||||
"setDebugMode",
|
||||
"stopPush",
|
||||
"resumePush",
|
||||
"isPushStopped",
|
||||
"setLatestNotificationNum",
|
||||
"setPushTime",
|
||||
"clearAllNotification",
|
||||
"clearNotificationById",
|
||||
"addLocalNotification",
|
||||
"removeLocalNotification",
|
||||
"clearLocalNotifications",
|
||||
"onResume",
|
||||
"onPause",
|
||||
"reportNotificationOpened",
|
||||
"setStatisticsOpen");
|
||||
"addLocalNotification",
|
||||
"clearAllNotification",
|
||||
"clearLocalNotifications",
|
||||
"clearNotificationById",
|
||||
"getNotification",
|
||||
"getRegistrationID",
|
||||
"init",
|
||||
"isPushStopped",
|
||||
"onPause",
|
||||
"onResume",
|
||||
"requestPermission",
|
||||
"removeLocalNotification",
|
||||
"reportNotificationOpened",
|
||||
"resumePush",
|
||||
"setAlias",
|
||||
"setBasicPushNotificationBuilder",
|
||||
"setCustomPushNotificationBuilder",
|
||||
"setDebugMode",
|
||||
"setLatestNotificationNum",
|
||||
"setPushTime",
|
||||
"setTags",
|
||||
"setTagsWithAlias",
|
||||
"setSilenceTime",
|
||||
"setStatisticsOpen",
|
||||
"stopPush"
|
||||
);
|
||||
|
||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||
private static JPushPlugin instance;
|
||||
@ -70,8 +72,11 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
private static boolean shouldCacheMsg = false;
|
||||
private static boolean isStatisticsOpened = false; // 是否开启统计分析功能
|
||||
|
||||
public static String notificationTitle;
|
||||
public static String notificationAlert;
|
||||
public static Map<String, Object> notificationExtras = new HashMap<String, Object>();
|
||||
|
||||
public static String openNotificationTitle;
|
||||
public static String openNotificationAlert;
|
||||
public static Map<String, Object> openNotificationExtras = new HashMap<String, Object>();
|
||||
|
||||
@ -83,24 +88,22 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
|
||||
Log.i(TAG, "---------------- initialize" + "-"
|
||||
+ JPushPlugin.openNotificationAlert + "-"
|
||||
+ JPushPlugin.notificationAlert);
|
||||
Log.i(TAG, "---------------- initialize" + "-" + openNotificationAlert
|
||||
+ "-" + notificationAlert);
|
||||
|
||||
cordovaActivity = this.cordova.getActivity();
|
||||
|
||||
//如果同时缓存了打开事件openNotificationAlert 和 消息事件notificationAlert,只向UI 发 打开事件。
|
||||
//这样做是为了和iOS 统一
|
||||
if (JPushPlugin.openNotificationAlert != null) {
|
||||
JPushPlugin.notificationAlert = null;
|
||||
JPushPlugin.transmitOpen(JPushPlugin.openNotificationAlert,
|
||||
JPushPlugin.openNotificationExtras);
|
||||
//如果同时缓存了打开事件 openNotificationAlert 和 消息事件 notificationAlert,只向 UI 发打开事件。
|
||||
//这样做是为了和 iOS 统一。
|
||||
if (openNotificationAlert != null) {
|
||||
notificationAlert = null;
|
||||
transmitNotificationOpen(openNotificationTitle, openNotificationAlert,
|
||||
openNotificationExtras);
|
||||
}
|
||||
if (JPushPlugin.notificationAlert != null) {
|
||||
JPushPlugin.transmitReceive(JPushPlugin.notificationAlert,
|
||||
JPushPlugin.notificationExtras);
|
||||
if (notificationAlert != null) {
|
||||
transmitNotificationReceive(notificationTitle, notificationAlert,
|
||||
notificationExtras);
|
||||
}
|
||||
//JPushInterface.init(cordova.getActivity().getApplicationContext());
|
||||
}
|
||||
|
||||
public void onPause(boolean multitasking) {
|
||||
@ -113,24 +116,23 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
public void onResume(boolean multitasking) {
|
||||
shouldCacheMsg = false;
|
||||
Log.i(TAG, "---------------- onResume" + "-"
|
||||
+ JPushPlugin.openNotificationAlert + "-"
|
||||
+ JPushPlugin.notificationAlert);
|
||||
Log.i(TAG, "---------------- onResume" + "-" + openNotificationAlert
|
||||
+ "-" + notificationAlert);
|
||||
if (isStatisticsOpened && multitasking) {
|
||||
JPushInterface.onResume(cordovaActivity);
|
||||
}
|
||||
if (JPushPlugin.openNotificationAlert != null) {
|
||||
JPushPlugin.notificationAlert = null;
|
||||
JPushPlugin.transmitOpen(JPushPlugin.openNotificationAlert,
|
||||
JPushPlugin.openNotificationExtras);
|
||||
if (openNotificationAlert != null) {
|
||||
notificationAlert = null;
|
||||
transmitNotificationOpen(openNotificationTitle, openNotificationAlert,
|
||||
openNotificationExtras);
|
||||
}
|
||||
if (JPushPlugin.notificationAlert != null) {
|
||||
JPushPlugin.transmitReceive(JPushPlugin.notificationAlert,
|
||||
JPushPlugin.notificationExtras);
|
||||
if (notificationAlert != null) {
|
||||
transmitNotificationReceive(notificationTitle, notificationAlert,
|
||||
notificationExtras);
|
||||
}
|
||||
}
|
||||
|
||||
private static JSONObject notificationObject(String message,
|
||||
private static JSONObject getMessageObject(String message,
|
||||
Map<String, Object> extras) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
@ -139,6 +141,12 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
for (Entry<String, Object> entry : extras.entrySet()) {
|
||||
if (entry.getKey().equals("cn.jpush.android.EXTRA")) {
|
||||
JSONObject jo = new JSONObject((String) entry.getValue());
|
||||
String key;
|
||||
Iterator keys = jo.keys();
|
||||
while(keys.hasNext()) {
|
||||
key = keys.next().toString();
|
||||
jExtras.put(key, jo.getString(key));
|
||||
}
|
||||
jExtras.put("cn.jpush.android.EXTRA", jo);
|
||||
} else {
|
||||
jExtras.put(entry.getKey(), entry.getValue());
|
||||
@ -153,15 +161,22 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
return data;
|
||||
}
|
||||
|
||||
private static JSONObject openNotificationObject(String alert,
|
||||
Map<String, Object> extras) {
|
||||
private static JSONObject getNotificationObject(String title,
|
||||
String alert, Map<String, Object> extras) {
|
||||
JSONObject data = new JSONObject();
|
||||
try {
|
||||
data.put("title", title);
|
||||
data.put("alert", alert);
|
||||
JSONObject jExtras = new JSONObject();
|
||||
for (Entry<String, Object> entry : extras.entrySet()) {
|
||||
if (entry.getKey().equals("cn.jpush.android.EXTRA")) {
|
||||
JSONObject jo = new JSONObject((String) entry.getValue());
|
||||
String key;
|
||||
Iterator keys = jo.keys();
|
||||
while(keys.hasNext()) {
|
||||
key = keys.next().toString();
|
||||
jExtras.put(key, jo.getString(key));
|
||||
}
|
||||
jExtras.put("cn.jpush.android.EXTRA", jo);
|
||||
} else {
|
||||
jExtras.put(entry.getKey(), entry.getValue());
|
||||
@ -176,11 +191,11 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
return data;
|
||||
}
|
||||
|
||||
static void transmitPush(String message, Map<String, Object> extras) {
|
||||
static void transmitMessageReceive(String message, Map<String, Object> extras) {
|
||||
if (instance == null) {
|
||||
return;
|
||||
}
|
||||
JSONObject data = notificationObject(message, extras);
|
||||
JSONObject data = getMessageObject(message, extras);
|
||||
String format = "window.plugins.jPushPlugin.receiveMessageInAndroidCallback(%s);";
|
||||
final String js = String.format(format, data.toString());
|
||||
cordovaActivity.runOnUiThread(new Runnable() {
|
||||
@ -191,14 +206,12 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
});
|
||||
}
|
||||
|
||||
static void transmitOpen(String alert, Map<String, Object> extras) {
|
||||
static void transmitNotificationOpen(String title, String alert,
|
||||
Map<String, Object> extras) {
|
||||
if (instance == null) {
|
||||
return;
|
||||
}
|
||||
if (JPushPlugin.shouldCacheMsg) {
|
||||
return;
|
||||
}
|
||||
JSONObject data = openNotificationObject(alert, extras);
|
||||
JSONObject data = getNotificationObject(title, alert, extras);
|
||||
String format = "window.plugins.jPushPlugin.openNotificationInAndroidCallback(%s);";
|
||||
final String js = String.format(format, data.toString());
|
||||
cordovaActivity.runOnUiThread(new Runnable() {
|
||||
@ -207,14 +220,16 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
instance.webView.loadUrl("javascript:" + js);
|
||||
}
|
||||
});
|
||||
JPushPlugin.openNotificationTitle = null;
|
||||
JPushPlugin.openNotificationAlert = null;
|
||||
}
|
||||
|
||||
static void transmitReceive(String alert, Map<String, Object> extras) {
|
||||
static void transmitNotificationReceive(String title, String alert,
|
||||
Map<String, Object> extras) {
|
||||
if (instance == null) {
|
||||
return;
|
||||
}
|
||||
JSONObject data = openNotificationObject(alert, extras);
|
||||
JSONObject data = getNotificationObject(title, alert, extras);
|
||||
String format = "window.plugins.jPushPlugin.receiveNotificationInAndroidCallback(%s);";
|
||||
final String js = String.format(format, data.toString());
|
||||
cordovaActivity.runOnUiThread(new Runnable() {
|
||||
@ -223,6 +238,7 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
instance.webView.loadUrl("javascript:" + js);
|
||||
}
|
||||
});
|
||||
JPushPlugin.notificationTitle = null;
|
||||
JPushPlugin.notificationAlert = null;
|
||||
}
|
||||
|
||||
@ -249,7 +265,6 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
void init(JSONArray data, CallbackContext callbackContext) {
|
||||
JPushInterface.init(cordovaActivity.getApplicationContext());
|
||||
//callbackContext.success();
|
||||
}
|
||||
|
||||
void setDebugMode(JSONArray data, CallbackContext callbackContext) {
|
||||
@ -393,24 +408,6 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// void getNotification(JSONArray data, CallbackContext callBackContext) {
|
||||
// String alert = JPushPlugin.notificationAlert;
|
||||
// Map<String, String> extras = JPushPlugin.notificationExtras;
|
||||
//
|
||||
// JSONObject jsonData = new JSONObject();
|
||||
// try {
|
||||
// jsonData.put("message", alert);
|
||||
// jsonData.put("extras", new JSONObject(extras));
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// callBackContext.success(jsonData);
|
||||
//
|
||||
// JPushPlugin.notificationAlert = "";
|
||||
// JPushPlugin.notificationExtras = new HashMap<String, Obl>();
|
||||
// }
|
||||
|
||||
void setBasicPushNotificationBuilder(JSONArray data,
|
||||
CallbackContext callbackContext) {
|
||||
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
||||
@ -423,7 +420,6 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//callbackContext.success(obj);
|
||||
}
|
||||
|
||||
void setCustomPushNotificationBuilder(JSONArray data,
|
||||
@ -440,12 +436,10 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//callbackContext.success(obj);
|
||||
}
|
||||
|
||||
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
||||
JPushInterface.clearAllNotifications(cordovaActivity);
|
||||
//callbackContext.success();
|
||||
}
|
||||
|
||||
void clearNotificationById(JSONArray data, CallbackContext callbackContext) {
|
||||
@ -499,8 +493,6 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
|
||||
/**
|
||||
* 决定是否启用统计分析功能。
|
||||
* @param data
|
||||
* @param callbackContext
|
||||
*/
|
||||
void setStatisticsOpen(JSONArray data, CallbackContext callbackContext) {
|
||||
try {
|
||||
@ -510,6 +502,48 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置通知静默时间
|
||||
* http://docs.jpush.io/client/android_api/#api_5
|
||||
*/
|
||||
void setSilenceTime(JSONArray data, CallbackContext callbackContext) {
|
||||
try {
|
||||
int startHour = data.getInt(0);
|
||||
int startMinute = data.getInt(1);
|
||||
int endHour = data.getInt(2);
|
||||
int endMinute = data.getInt(3);
|
||||
if (!isValidHour(startHour) || !isValidMinute(startMinute)) {
|
||||
callbackContext.error("开始时间数值错误");
|
||||
return;
|
||||
}
|
||||
if(!isValidHour(endHour) || !isValidMinute(endMinute)) {
|
||||
callbackContext.error("结束时间数值错误");
|
||||
return;
|
||||
}
|
||||
JPushInterface.setSilenceTime(cordovaActivity, startHour, startMinute,
|
||||
endHour, endMinute);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
callbackContext.error("error: reading json data.");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isValidHour(int hour) {
|
||||
return !(hour < 0 || hour > 23);
|
||||
}
|
||||
|
||||
private boolean isValidMinute(int minute) {
|
||||
return !(minute < 0 || minute > 59);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于 Android 6.0 以上系统申请权限,具体可参考:
|
||||
* http://docs.Push.io/client/android_api/#android-60
|
||||
*/
|
||||
void requestPermission(JSONArray data, CallbackContext callbackContext) {
|
||||
JPushInterface.requestPermission(cordovaActivity);
|
||||
}
|
||||
|
||||
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
|
||||
@Override
|
||||
public void gotResult(int code, String alias, Set<String> tags) {
|
||||
|
@ -25,7 +25,7 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(action)) {
|
||||
handlingReceivedMessage(intent);
|
||||
handlingMessageReceive(intent);
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(action)) {
|
||||
handlingNotificationReceive(context, intent);
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(action)) {
|
||||
@ -35,22 +35,25 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
}
|
||||
}
|
||||
|
||||
private void handlingReceivedMessage(Intent intent) {
|
||||
private void handlingMessageReceive(Intent intent) {
|
||||
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
|
||||
Map<String, Object> extras = getNotificationExtras(intent);
|
||||
JPushPlugin.transmitPush(msg, extras);
|
||||
JPushPlugin.transmitMessageReceive(msg, extras);
|
||||
}
|
||||
|
||||
private void handlingNotificationOpen(Context context, Intent intent) {
|
||||
Log.i(TAG, "---------------- handlingNotificationOpen");
|
||||
|
||||
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
|
||||
JPushPlugin.openNotificationTitle = title;
|
||||
|
||||
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
||||
JPushPlugin.openNotificationAlert = alert;
|
||||
|
||||
Map<String, Object> extras = getNotificationExtras(intent);
|
||||
JPushPlugin.openNotificationExtras = extras;
|
||||
|
||||
JPushPlugin.transmitOpen(alert, extras);
|
||||
JPushPlugin.transmitNotificationOpen(title, alert, extras);
|
||||
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
||||
context.getPackageName());
|
||||
@ -62,24 +65,27 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
private void handlingNotificationReceive(Context context, Intent intent) {
|
||||
Log.i(TAG, "---------------- handlingNotificationReceive");
|
||||
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
|
||||
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;
|
||||
|
||||
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
|
||||
JPushPlugin.notificationAlert = alert;
|
||||
|
||||
Map<String, Object> extras = getNotificationExtras(intent);
|
||||
JPushPlugin.notificationExtras = extras;
|
||||
|
||||
JPushPlugin.transmitReceive(alert, extras);
|
||||
JPushPlugin.transmitNotificationReceive(title, alert, extras);
|
||||
}
|
||||
|
||||
private Map<String, Object> getNotificationExtras(Intent intent) {
|
||||
Map<String, Object> extrasMap = new HashMap<String, Object>();
|
||||
for (String key : intent.getExtras().keySet()) {
|
||||
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
|
||||
Log.e("key", "key:" + key);
|
||||
if (key.equals(JPushInterface.EXTRA_NOTIFICATION_ID)) {
|
||||
extrasMap.put(key, intent.getIntExtra(key, 0));
|
||||
} else {
|
||||
|
Binary file not shown.
BIN
src/android/arm64-v8a/libjpush213.so
Normal file
BIN
src/android/arm64-v8a/libjpush213.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/armeabi-v7a/libjpush213.so
Normal file
BIN
src/android/armeabi-v7a/libjpush213.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/armeabi/libjpush213.so
Normal file
BIN
src/android/armeabi/libjpush213.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/jpush-android-2.1.3.jar
Normal file
BIN
src/android/jpush-android-2.1.3.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/x86/libjpush213.so
Normal file
BIN
src/android/x86/libjpush213.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/x86_64/libjpush213.so
Normal file
BIN
src/android/x86_64/libjpush213.so
Normal file
Binary file not shown.
@ -27,38 +27,42 @@ JPushPlugin.prototype.call_native = function(name, args, callback) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
//public plugin function
|
||||
|
||||
JPushPlugin.prototype.startLogPageView = function(pageName) {
|
||||
// public methods
|
||||
JPushPlugin.prototype.init = function() {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("startLogPageView", [pageName], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.stopLogPageView = function(pageName) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("stopLogPageView", [pageName], null);
|
||||
var data = [];
|
||||
this.call_native("initial", data, null);
|
||||
} else {
|
||||
data = [];
|
||||
this.call_native("init", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.beginLogPageView = function(pageName, duration) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("beginLogPageView", [pageName, duration], null);
|
||||
JPushPlugin.prototype.getRegistrationID = function(callback) {
|
||||
try {
|
||||
var data = [];
|
||||
this.call_native("getRegistrationID", [data], callback);
|
||||
} catch(exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("setApplicationIconBadgeNumber", [badge], null);
|
||||
}
|
||||
JPushPlugin.prototype.stopPush = function() {
|
||||
data = [];
|
||||
this.call_native("stopPush", data, null);
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("getApplicationIconBadgeNumber", [], callback);
|
||||
}
|
||||
JPushPlugin.prototype.resumePush = function() {
|
||||
data = [];
|
||||
this.call_native("resumePush", data, null);
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.isPushStopped = function(callback) {
|
||||
data = [];
|
||||
this.call_native("isPushStopped", data, callback);
|
||||
}
|
||||
|
||||
// iOS methods
|
||||
JPushPlugin.prototype.setTagsWithAlias = function(tags, alias) {
|
||||
try {
|
||||
if(tags == null) {
|
||||
@ -93,15 +97,6 @@ JPushPlugin.prototype.setAlias = function(alias) {
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.getRegistrationID = function(callback) {
|
||||
try {
|
||||
var data = [];
|
||||
this.call_native("getRegistrationID", [data], callback);
|
||||
} catch(exception) {
|
||||
console.log(exception);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setBadge = function(value) {
|
||||
if(this.isPlatformIOS()) {
|
||||
try {
|
||||
@ -185,6 +180,57 @@ JPushPlugin.prototype.receiveMessageIniOSCallback = function(data) {
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.startLogPageView = function(pageName) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("startLogPageView", [pageName], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.stopLogPageView = function(pageName) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("stopLogPageView", [pageName], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.beginLogPageView = function(pageName, duration) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("beginLogPageView", [pageName, duration], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("setApplicationIconBadgeNumber", [badge], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("getApplicationIconBadgeNumber", [], callback);
|
||||
}
|
||||
}
|
||||
|
||||
// Android methods
|
||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
||||
if(device.platform == "Android") {
|
||||
this.call_native("setDebugMode", [mode], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setBasicPushNotificationBuilder = function() {
|
||||
if(device.platform == "Android") {
|
||||
data = [];
|
||||
this.call_native("setBasicPushNotificationBuilder", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setCustomPushNotificationBuilder = function() {
|
||||
if(device.platform == "Android") {
|
||||
data = [];
|
||||
this.call_native("setCustomPushNotificationBuilder", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data) {
|
||||
try {
|
||||
console.log("JPushPlugin:receiveMessageInAndroidCallback");
|
||||
@ -221,38 +267,6 @@ JPushPlugin.prototype.receiveNotificationInAndroidCallback = function(data) {
|
||||
}
|
||||
}
|
||||
|
||||
//android single
|
||||
|
||||
JPushPlugin.prototype.setBasicPushNotificationBuilder = function() {
|
||||
if(device.platform == "Android") {
|
||||
data = [];
|
||||
this.call_native("setBasicPushNotificationBuilder", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setCustomPushNotificationBuilder = function() {
|
||||
if(device.platform == "Android") {
|
||||
data = [];
|
||||
this.call_native("setCustomPushNotificationBuilder", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.stopPush = function() {
|
||||
data = [];
|
||||
this.call_native("stopPush", data, null);
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.resumePush = function() {
|
||||
data = [];
|
||||
this.call_native("resumePush", data, null);
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
||||
if(device.platform == "Android") {
|
||||
this.call_native("setDebugMode", [mode], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.clearAllNotification = function() {
|
||||
if(device.platform == "Android") {
|
||||
data = [];
|
||||
@ -273,21 +287,6 @@ JPushPlugin.prototype.setLatestNotificationNum = function(num) {
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.isPushStopped = function(callback) {
|
||||
data = [];
|
||||
this.call_native("isPushStopped", data, callback);
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.init = function() {
|
||||
if(this.isPlatformIOS()) {
|
||||
var data = [];
|
||||
this.call_native("initial", data, null);
|
||||
} else {
|
||||
data = [];
|
||||
this.call_native("init", data, null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
||||
if(device.platform == "Android") {
|
||||
this.call_native("setDebugMode", [mode], null);
|
||||
@ -295,9 +294,9 @@ JPushPlugin.prototype.setDebugMode = function(mode) {
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.addLocalNotification = function(builderId, content, title,
|
||||
notificaitonID, broadcastTime, extras) {
|
||||
notificationID, broadcastTime, extras) {
|
||||
if(device.platform == "Android") {
|
||||
data = [builderId, content, title, notificaitonID, broadcastTime, extras];
|
||||
data = [builderId, content, title, notificationID, broadcastTime, extras];
|
||||
this.call_native("addLocalNotification", data, null);
|
||||
}
|
||||
}
|
||||
@ -324,14 +323,26 @@ JPushPlugin.prototype.reportNotificationOpened = function(msgID) {
|
||||
/**
|
||||
*是否开启统计分析功能,用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器上,
|
||||
*在 Portal 上展示给开发者。
|
||||
**/
|
||||
*/
|
||||
JPushPlugin.prototype.setStatisticsOpen = function(mode) {
|
||||
if(device.platform == "Android") {
|
||||
this.call_native("setStatisticsOpen", [mode], null);
|
||||
}
|
||||
}
|
||||
|
||||
//iOS single
|
||||
/**
|
||||
* 用于在 Android 6.0 及以上系统,申请一些权限
|
||||
* 具体可看:http://docs.jpush.io/client/android_api/#android-60
|
||||
*/
|
||||
JPushPlugin.prototype.requestPermission = function() {
|
||||
if(device.platform == "Android") {
|
||||
this.call_native("requestPermission", [], null);
|
||||
}
|
||||
}
|
||||
|
||||
JPushPlugin.prototype.setSilenceTime = function() {
|
||||
|
||||
}
|
||||
|
||||
if(!window.plugins) {
|
||||
window.plugins = {};
|
||||
|
Loading…
Reference in New Issue
Block a user