mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
Compare commits
90 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4f8288107e | |||
| 0342577830 | |||
| 116ac90492 | |||
| a525ddc7df | |||
| 149083b8f4 | |||
| be7b9aa8ac | |||
| 714a811ef2 | |||
| 13120cb88e | |||
| a365c632d4 | |||
| 1d1d7bbec8 | |||
| abac27de1a | |||
| 9cc27db799 | |||
| 0c6450231b | |||
| c3171e716a | |||
| e24d15db97 | |||
| 3101dcdd8e | |||
| a46da92fa1 | |||
| 5547d5716e | |||
| 7da0a25db0 | |||
| 0c74ff328d | |||
| 2065ad44ce | |||
| cbe8e511f2 | |||
| 9a47c88873 | |||
| 684039b044 | |||
| 356de48d31 | |||
| d412b10d3e | |||
| 44345d9753 | |||
| 5f93fc3f49 | |||
| 673a402c51 | |||
| 09e0d62360 | |||
| b4830d4ef7 | |||
| 2c3bf53792 | |||
| 78ebe0e787 | |||
| 54f87adde2 | |||
| c101552938 | |||
| c918efb99a | |||
| 9be760e65e | |||
| cea1eb85fa | |||
| f8c56b5aa1 | |||
| 0bb6838477 | |||
| c6b8a6f2f6 | |||
| 42fbe62d19 | |||
| d3ea41f513 | |||
| 5ff7d14bec | |||
| 1c41e96f42 | |||
| 48adf59ec8 | |||
| 3369072687 | |||
| 8e7e957884 | |||
| c615f8255e | |||
| 7ffec241fa | |||
| de32f4a057 | |||
| 1cd7ecf3e5 | |||
| b01b4bf259 | |||
| f8efb4f010 | |||
| 870fc12c0d | |||
| dc2cdda00c | |||
| 1c96487869 | |||
| 8d24ce7c48 | |||
| 280846779d | |||
| 1ba048ee1b | |||
| e4500dd513 | |||
| a511072101 | |||
| 851ff1f23b | |||
| 5cf5bd39d1 | |||
| 07bb05f337 | |||
| ceeb2fc7cf | |||
| 1eccd58059 | |||
| a82382eddf | |||
| be6dbf4fe6 | |||
| e898c7933c | |||
| bce5b4df68 | |||
| 3810209ca6 | |||
| 39155bf63c | |||
| 93989a7ad1 | |||
| 8c6044b6a6 | |||
| 9c0c2c0bd1 | |||
| 380c09283d | |||
| 730b93d82a | |||
| 39d65d61c8 | |||
| 4ed844e0c5 | |||
| 1f2499a893 | |||
| bca6853a4e | |||
| 0015cd23e4 | |||
| 8b5efdcdcc | |||
| 4bc24e66d4 | |||
| 53dcfa0087 | |||
| c9755d4f64 | |||
| 6409ce4934 | |||
| aa3a4a218c | |||
| 79fb3b76ca |
@@ -1,62 +0,0 @@
|
|||||||
### iOS 手动安装
|
|
||||||
|
|
||||||
- 下载 JPush PhoneGap 插件,并解压缩,标记插件目录为:`$JPUSH_PLUGIN_DIR`
|
|
||||||
|
|
||||||
- 用 xcode 打开 iOS 工程 将 `$JPUSH_PLUGIN_DIR`/src/ios/Plugins/ 拖到 project 中
|
|
||||||
|
|
||||||
- 将 `$JPUSH_PLUGIN_DIR`/src/ios/lib/ 拖到 project 中
|
|
||||||
|
|
||||||
- 添加以下框架,打开 xcode,点击 project,选择(Target -> Build Phases -> Link Binary With Libraries)
|
|
||||||
|
|
||||||
CFNetwork.framework
|
|
||||||
CoreFoundation.framework
|
|
||||||
CoreTelephony.framework
|
|
||||||
SystemConfiguration.framework
|
|
||||||
CoreGraphics.framework
|
|
||||||
Foundation.framework
|
|
||||||
UIKit.framework
|
|
||||||
|
|
||||||
|
|
||||||
- 在你的工程中创建一个新的 Property List 文件
|
|
||||||
|
|
||||||
并将其命名为 PushConfig.plist,填入 Portal 为你的应用提供的 APP_KEY 等参数
|
|
||||||
|
|
||||||
- 在 AppDelegate.m 中包含头文件
|
|
||||||
|
|
||||||
#import "JPUSHService.h"
|
|
||||||
#import "JPushPlugin.h"
|
|
||||||
|
|
||||||
- 在 AppDelegate.m 中的下列方法中添加代码,如果方法不存在则增加相应方法与内容
|
|
||||||
|
|
||||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
|
|
||||||
//原内容保持不变
|
|
||||||
//Required add
|
|
||||||
[JPushPlugin setLaunchOptions:launchOptions];
|
|
||||||
return YES;
|
|
||||||
}
|
|
||||||
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
|
|
||||||
//原内容保持不变
|
|
||||||
// Required add
|
|
||||||
[JPUSHService registerDeviceToken:deviceToken];
|
|
||||||
}
|
|
||||||
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
|
|
||||||
//原内容保持不变
|
|
||||||
// Required add
|
|
||||||
[JPUSHService handleRemoteNotification:userInfo];
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification object:userInfo];
|
|
||||||
}
|
|
||||||
|
|
||||||
- 修改 phonegap config.xml 文件用来包含 Plugin/ 内的插件
|
|
||||||
|
|
||||||
|
|
||||||
<feature name="JPushPlugin">
|
|
||||||
<param name="ios-package" value="JPushPlugin" />
|
|
||||||
<param name="onload" value="true" />
|
|
||||||
</feature>
|
|
||||||
|
|
||||||
|
|
||||||
- 复制 `$JPUSH_PLUGIN_DIR`/www/JPushPlugin.js 到工程的 www 目录下面
|
|
||||||
|
|
||||||
- 在需要使用插件处加入
|
|
||||||
|
|
||||||
<script type="text/javascript" src="JPushPlugin.js"></script>
|
|
||||||
@@ -1,138 +1,74 @@
|
|||||||
# 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://gitter.im/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-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)
|
||||||
|
|
||||||
支持 iOS, Android 的 Cordova 推送插件。
|
支持 iOS, Android 的 Cordova 推送插件。
|
||||||
|
> 如需要 IM 功能的插件,可关注 [JMessage PhoneGap Plugin](https://github.com/jpush/jmessage-phonegap-plugin)。
|
||||||
|
|
||||||
## 功能特性
|
> 如需要短信验证码功能的插件,可关注 [JSMS Cordova Plugin](https://github.com/jpush/cordova-plugin-jsms)。
|
||||||
+ 发送推送通知。
|
|
||||||
+ 发送推送自定义消息。
|
|
||||||
+ 设置推送标签和别名。
|
|
||||||
+ 设置角标(iOS)。
|
|
||||||
|
|
||||||
*如需要 IM 功能插件,请关注 [jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)*。
|
> QQ 交流群:413602425。
|
||||||
|
|
||||||
## 安装
|
## Install
|
||||||
### 准备工作
|
|
||||||
|
|
||||||
1. cordova create 文件夹名字 包名 应用名字
|
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:
|
||||||
|
|
||||||
cordova create Myproj com.myproj.jpush MyTestProj
|
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
|
||||||
|
|
||||||
2. 添加平台:
|
- 或直接通过 url 安装:
|
||||||
|
|
||||||
cd Myproj
|
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
|
||||||
cordova platform add android
|
|
||||||
cordova platform add ios
|
|
||||||
|
|
||||||
ps: 这里请注意iOS平台,必须先执行 cordova platform add ios,
|
- 或下载到本地安装:
|
||||||
然后再执行 cordova plugin add xxxxx 命令,不然有一些必须要的链接库需要手动添加。
|
|
||||||
|
cordova plugin add Your_Plugin_Path --variable API_KEY=your_jpush_appkey
|
||||||
|
|
||||||
|
|
||||||
### 安装插件(Android & iOS)
|
## Usage
|
||||||
|
### API
|
||||||
|
- [公共 API](/doc/Common_detail_api.md)
|
||||||
|
- [iOS API](/doc/iOS_API.md)
|
||||||
|
- [Android API](/doc/Android_detail_api.md)
|
||||||
|
|
||||||
#### 1.安装 JPush PhoneGap Plugin
|
### Demo
|
||||||
安装 JPush PhoneGap Plugin 有两种方法:
|
插件项目中包含一个简单的 Demo。若想参考,可以在 */example* 文件夹内找到并拷贝以下文件:
|
||||||
|
|
||||||
方法一:在线安装
|
example/index.html -> www/index.html
|
||||||
|
example/css/* -> www/css
|
||||||
|
example/js/* -> www/js
|
||||||
|
|
||||||
通过 cordova plugins 安装,要求 phonegap/cordova CLI 5.0+:
|
### 关于 PhoneGap build 云服务
|
||||||
|
该项目基于 Cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
|
||||||
|
|
||||||
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
|
## FAQ
|
||||||
|
> 如果遇到了疑问,请优先参考 Demo 和 API 文档。若还无法解决,可访问[极光社区](http://community.jiguang.cn/)或 [Issues](https://github.com/jpush/jpush-phonegap-plugin/issues) 提问。
|
||||||
|
|
||||||
直接通过 url 安装:
|
### Android
|
||||||
|
#### 在 Eclipse 中 import 工程之后出现:*Type CallbackContext cannot be resolved to a type*。
|
||||||
|
右键单击工程名 -> Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
|
||||||
|
|
||||||
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
|
### iOS
|
||||||
|
#### PushConfig.plist 文件中的字段都是什么意思?
|
||||||
|
- APP_KEY:应用标识。
|
||||||
|
- CHANNEL:渠道标识。
|
||||||
|
- IsProduction:是否生产环境。
|
||||||
|
- IsIDFA:是否使用 IDFA 启动 SDK。
|
||||||
|
|
||||||
方法二:下载到本地再安装
|
#### 收不到推送了。
|
||||||
|
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
||||||
使用 git 命令将 JPush PhoneGap 插件下载的本地,目录标记为 $JPUSH_PLUGIN_DIR。
|
|
||||||
|
|
||||||
git clone https://github.com/jpush/jpush-phonegap-plugin.git
|
|
||||||
cordova plugin add $JPUSH_PLUGIN_DIR --variable API_KEY=your_jpush_appkey
|
|
||||||
|
|
||||||
[Android 手动安装文档地址](API/Android_handle_install.md)
|
|
||||||
|
|
||||||
[IOS 手动安装文档地址](API/iOS_install.md)
|
|
||||||
|
|
||||||
|
|
||||||
#### 2.安装 org.apache.cordova.device 插件
|
## Support
|
||||||
|
- QQ 群:413602425
|
||||||
|
- [JPush 官网文档](http://docs.jpush.io/)
|
||||||
|
- [极光社区](http://community.jiguang.cn/)
|
||||||
|
|
||||||
cordova plugin add org.apache.cordova.device
|
## Contribute
|
||||||
|
Please contribute! [Look at the issues](https://github.com/jpush/jpush-phonegap-plugin/issues).
|
||||||
|
|
||||||
|
## License
|
||||||
#### 3.在 js 中调用函数,初始化 JPush
|
MIT © [JiGuang](/license)
|
||||||
|
|
||||||
//由于 PhoneGap 插件采用了 Lazy load 的特性,所以建议在 js 文件能执行的最开始就添加
|
|
||||||
window.plugins.jPushPlugin.init();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Demo
|
|
||||||
插件中包含示例 Demo。若想参考,可以在 $JPUSH_PLUGIN_DIR/example 文件夹内找到并拷贝以下文件:
|
|
||||||
|
|
||||||
src/example/index.html -> www/index.html
|
|
||||||
src/example/css/* -> www/css
|
|
||||||
src/example/js/* -> www/js
|
|
||||||
|
|
||||||
## 关于 PhoneGap build 云服务
|
|
||||||
|
|
||||||
该项目基于 cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
|
|
||||||
|
|
||||||
## API 说明
|
|
||||||
|
|
||||||
插件的 API 集中在 JPushPlugin.js 文件中,该文件的具体位置如下:
|
|
||||||
|
|
||||||
Android:
|
|
||||||
|
|
||||||
[Project]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
|
|
||||||
|
|
||||||
iOS:
|
|
||||||
|
|
||||||
[Project]/www/plugins/cn.jpush.phonegap.JPushPlugin/www
|
|
||||||
|
|
||||||
### 具体的 API 请参考:
|
|
||||||
|
|
||||||
- [公共 API](https://github.com/jpush/jpush-phonegap-plugin/blob/dev/API/Common_detail_api.md)
|
|
||||||
|
|
||||||
- [iOS API](https://github.com/jpush/jpush-phonegap-plugin/blob/dev/API/iOS%20API.md)
|
|
||||||
|
|
||||||
- [Android API](https://github.com/jpush/jpush-phonegap-plugin/blob/dev/API/Android_detail_api.md)
|
|
||||||
|
|
||||||
|
|
||||||
## 常见问题
|
|
||||||
|
|
||||||
若要使用 CLI 来编译项目,注意使用 cordova compile 而不是 cordova build,因为 cordova build 会清除对插件文件的修改。
|
|
||||||
具体 cordova CLI 用法可参考[cordova CLI 官方文档](https://cordova.apache.org/docs/en/latest/reference/cordova-cli/index.html)。
|
|
||||||
|
|
||||||
### 1. Android
|
|
||||||
|
|
||||||
eclipse 中 import PhoneGap 工程之后出现:`Type CallbackContext cannot be resolved to a type`。
|
|
||||||
|
|
||||||
解决方案:eclipse 中右键单击工程名,Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
|
|
||||||
|
|
||||||
### 2. iOS
|
|
||||||
|
|
||||||
- 设置 / 修改 APP_KEY:
|
|
||||||
|
|
||||||
在 PushConfig.plist 中修改。
|
|
||||||
PushConfig.plist 中其他值说明:
|
|
||||||
|
|
||||||
- CHANNEL: 渠道标识。
|
|
||||||
- IsProduction: 是否生产环境(暂未启用)。
|
|
||||||
|
|
||||||
|
|
||||||
- 收不到推送:
|
|
||||||
|
|
||||||
请首先按照正确方式再次配置证书、描述文件
|
|
||||||
[iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
|
||||||
|
|
||||||
|
|
||||||
## 更多
|
|
||||||
[JPush 官网文档](http://docs.jpush.io/)
|
|
||||||
|
|
||||||
如有问题可访问[极光社区](http://community.jpush.cn/)
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
- [通知栏样式定制](#通知栏样式定制)
|
- [通知栏样式定制](#通知栏样式定制)
|
||||||
- [设置保留最近通知条数](#设置保留最近通知条数)
|
- [设置保留最近通知条数](#设置保留最近通知条数)
|
||||||
- [本地通知](#本地通知)
|
- [本地通知](#本地通知)
|
||||||
|
- [富媒体页面 JavaScript 回调 API](#富媒体页面-javascript-回调-api)
|
||||||
|
|
||||||
## 接收通知时获得通知的内容
|
## 接收通知时获得通知的内容
|
||||||
|
|
||||||
@@ -261,3 +261,64 @@ JPush SDK 提供了 2 个用于定制通知栏样式的构建类:
|
|||||||
- notificaitonID: 设置本地通知的 ID。
|
- notificaitonID: 设置本地通知的 ID。
|
||||||
- broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
|
- broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
|
||||||
- extras: 设置额外的数据信息 extras 为 json 字符串。
|
- extras: 设置额外的数据信息 extras 为 json 字符串。
|
||||||
|
|
||||||
|
|
||||||
|
## 富媒体页面 JavaScript 回调 API
|
||||||
|
富媒体推送通知时,用户可以用自定义的Javascript 函数来控制页面,如关闭当前页面,点击按钮跳转到指定的 Activity,通知应用程序做一些指定的动作等。
|
||||||
|
|
||||||
|
此 API 提供的回调函数包括:关闭当前页面、打开应用的主 Activity、根据 Activity 名字打开对应的 Activity、以广播的形式传递页面参数到应用程序等功能。
|
||||||
|
|
||||||
|
### API - 关闭当前页面
|
||||||
|
|
||||||
|
JPushWeb.close(); // 在富文本 HTML 页面中调用后会关闭当前页面。
|
||||||
|
|
||||||
|
### API - 打开主 Activity
|
||||||
|
|
||||||
|
JPushWeb.startMainActivity(String params);
|
||||||
|
|
||||||
|
在HTML中调用此函数后,会打开程序的主Activity, 并在对应的 Intent 传入参数 ”params“ ,Key 为 JPushInterface.EXTRA_EXTRA。
|
||||||
|
|
||||||
|
对应 Activity 获取 params 示例代码:
|
||||||
|
|
||||||
|
Intent intent = getIntent();
|
||||||
|
if (null != intent ) {
|
||||||
|
String params = intent.getStringExtra(JPushInterface.EXTRA_EXTRA);
|
||||||
|
}
|
||||||
|
|
||||||
|
### API - 触发应用中的操作
|
||||||
|
|
||||||
|
JPushWeb.triggerNativeAction(String params);
|
||||||
|
|
||||||
|
调用了该方法后需要在 MyReceiver.java 中实现后面的业务逻辑:
|
||||||
|
|
||||||
|
if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(intent.getAction())) {
|
||||||
|
Log.d(TAG, "用户收到到RICH PUSH CALLBACK: " + bundle.getString(JPushInterface.EXTRA_EXTRA));
|
||||||
|
//在这里根据 JPushInterface.EXTRA_EXTRA 的内容触发客户端动作,比如打开新的Activity 、打开一个网页等。
|
||||||
|
}
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>JPush Webview Test</title>
|
||||||
|
<script>
|
||||||
|
function clickButton() {
|
||||||
|
JPushWeb.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function openUrl() {
|
||||||
|
var json = "{'action':'open', 'url':'www.jpush.cn'}";
|
||||||
|
JPushWeb.triggerNativeAction(json);
|
||||||
|
JPushWeb.close(); //客服端在广播中收到json 后,可以打开对应的URL。
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button onclick="javascript:clickButton(this);return false;">Close</button>
|
||||||
|
<button onclick="javascript:JPushWeb.startMainActivity('test - startMainActivity');return false;">StartMainActivity</button>
|
||||||
|
<button onclick="javascript:JPushWeb.triggerNativeAction('test - triggerNativeAction');Javascript:JPushWeb.close();">triggerNativeAction and Close current webwiew</button>
|
||||||
|
<button onclick="javascript:JPushWeb.startActivityByName('com.example.jpushdemo.TestActivity','test - startActivityByName');">startActivityByName</button>
|
||||||
|
<button onclick="javascript:openUrl();">open a url</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
- [获取点击通知内容](#获取点击通知内容)
|
- [获取点击通知内容](#获取点击通知内容)
|
||||||
- [获取通知内容](#获取通知内容)
|
- [获取通知内容](#获取通知内容)
|
||||||
- [获取自定义消息推送内容](#获取自定义消息推送内容)
|
- [获取自定义消息推送内容](#获取自定义消息推送内容)
|
||||||
|
- [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送)
|
||||||
|
|
||||||
## 停止与恢复推送服务
|
## 停止与恢复推送服务
|
||||||
### API - init
|
### API - init
|
||||||
@@ -86,14 +86,13 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
|
|||||||
|
|
||||||
#### 代码示例
|
#### 代码示例
|
||||||
|
|
||||||
window.plugins.jPushPlugin.resumePush(callback)
|
window.plugins.jPushPlugin.isPushStopped(function (result) {
|
||||||
var onCallback = function(data) {
|
if (result == 0) {
|
||||||
if(data > 0) {
|
|
||||||
// 开启
|
// 开启
|
||||||
} else {
|
} else {
|
||||||
// 关闭
|
// 关闭
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
|
||||||
## 获取 RegistrationID
|
## 获取 RegistrationID
|
||||||
@@ -226,7 +225,7 @@ JPush SDK 会以广播的形式发送 RegistrationID 到应用程序。
|
|||||||
|
|
||||||
var alertContent;
|
var alertContent;
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
alertContent = window.plugins.jPushPlugin.openNotification.alert;
|
alertContent = event.alert;
|
||||||
} else {
|
} else {
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
@@ -280,7 +279,7 @@ ps:点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.o
|
|||||||
|
|
||||||
var alertContent;
|
var alertContent;
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
|
alertContent = event.alert;
|
||||||
} else {
|
} else {
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
@@ -339,7 +338,7 @@ ps:点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.r
|
|||||||
try{
|
try{
|
||||||
var message
|
var message
|
||||||
if(device.platform == "Android") {
|
if(device.platform == "Android") {
|
||||||
message = window.plugins.jPushPlugin.receiveMessage.message;
|
message = event.message;
|
||||||
} else {
|
} else {
|
||||||
message = event.content;
|
message = event.content;
|
||||||
}
|
}
|
||||||
@@ -370,3 +369,28 @@ ps:点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.r
|
|||||||
"content":"今天去哪儿",
|
"content":"今天去哪儿",
|
||||||
"extras":{"key":"不填写没有"}
|
"extras":{"key":"不填写没有"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
## 判断系统设置中是否允许当前应用推送
|
||||||
|
### API - getUserNotificationSettings
|
||||||
|
判断系统设置中是否允许当前应用推送。
|
||||||
|
|
||||||
|
在 Android 中,返回值为 0 时,代表系统设置中关闭了推送;为 1 时,代表打开了推送(目前仅适用于Android 4.4+)。
|
||||||
|
|
||||||
|
在 iOS 中,返回值为 0 时,代表系统设置中关闭了推送;大于 0 时,代表打开了推送,且能够根据返回值判断具体通知形式:
|
||||||
|
|
||||||
|
UIRemoteNotificationTypeNone = 0, // 0
|
||||||
|
UIRemoteNotificationTypeBadge = 1 << 0, // 1
|
||||||
|
UIRemoteNotificationTypeSound = 1 << 1, // 2
|
||||||
|
UIRemoteNotificationTypeAlert = 1 << 2, // 4
|
||||||
|
UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3 // 8
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
window.plugins.jPushPlugin.getUserNotificationSettings(function(result) {
|
||||||
|
if(result == 0) {
|
||||||
|
// 系统设置中已关闭应用推送。
|
||||||
|
} else if(result > 0) {
|
||||||
|
// 系统设置中打开了应用推送。
|
||||||
|
}
|
||||||
|
});
|
||||||
@@ -57,7 +57,7 @@ JPush SDK 会恢复正常的默认行为。(因为保存在本地的状态数
|
|||||||
|
|
||||||
### API - isPushStopped
|
### API - isPushStopped
|
||||||
|
|
||||||
iOS平台,检查推送服务是否注册。
|
iOS平台,检查推送服务是否停止。
|
||||||
|
|
||||||
#### 接口定义
|
#### 接口定义
|
||||||
|
|
||||||
@@ -69,12 +69,12 @@ iOS平台,检查推送服务是否注册。
|
|||||||
- callback 回调函数,用来通知 JPush 的推送服务是否开启。
|
- callback 回调函数,用来通知 JPush 的推送服务是否开启。
|
||||||
|
|
||||||
#### 代码示例
|
#### 代码示例
|
||||||
window.plugins.jPushPlugin.resumePush(callback)
|
window.plugins.jPushPlugin.isPushStopped(callback)
|
||||||
var onCallback = function(data) {
|
var callback = function(data) {
|
||||||
if(data > 0) {
|
if(data > 0) {
|
||||||
// 开启
|
// 已关闭
|
||||||
} else {
|
} else {
|
||||||
// 关闭
|
// 已开启
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
## iOS 手动安装
|
||||||
|
|
||||||
|
- 下载 JPush PhoneGap Plugin 插件,并解压
|
||||||
|
|
||||||
|
- 将 [/src/ios](/src/ios) 文件夹及内容在 xcode 中拖到你的工程里,并配置 [/src/ios/PushConfig.plist](/src/ios/PushConfig.plist) 中相应参数:
|
||||||
|
|
||||||
|
APP_KEY: 应用标识
|
||||||
|
CHANNEL: 渠道标识
|
||||||
|
IsProduction:是否生产环境
|
||||||
|
IsIDFA: 是否使用 IDFA 启动 sdk
|
||||||
|
|
||||||
|
- 打开 xcode,点击工程目录中顶部的 工程,选择(Target -> Build Phases -> Link Binary With Libraries),添加以下框架:
|
||||||
|
|
||||||
|
CFNetwork.framework
|
||||||
|
CoreFoundation.framework
|
||||||
|
CoreTelephony.framework
|
||||||
|
SystemConfiguration.framework
|
||||||
|
CoreGraphics.framework
|
||||||
|
Foundation.framework
|
||||||
|
UIKit.framework
|
||||||
|
AdSupport.framework
|
||||||
|
libz.tbd(若存在 libz.dylib 则替换为 libz.tbd)
|
||||||
|
|
||||||
|
- 修改 phonegap config.xml 文件以添加 JPushPlugin 插件
|
||||||
|
|
||||||
|
<feature name="JPushPlugin">
|
||||||
|
<param name="ios-package" value="JPushPlugin" />
|
||||||
|
<param name="onload" value="true" />
|
||||||
|
</feature>
|
||||||
|
|
||||||
|
- 将 [/www/JPushPlugin.js](/www/JPushPlugin.js) 在 xcode 中拖到工程的 www 目录下面
|
||||||
|
|
||||||
|
- 在需要使用插件处加入以下代码,并根据 [iOS API](/doc/iOS_API.md) 文档说明调用相应接口
|
||||||
|
|
||||||
|
<script type="text/javascript" src="JPushPlugin.js"></script>
|
||||||
Vendored
BIN
Binary file not shown.
+3
-3
@@ -47,7 +47,7 @@
|
|||||||
try {
|
try {
|
||||||
var alertContent;
|
var alertContent;
|
||||||
if (device.platform == "Android") {
|
if (device.platform == "Android") {
|
||||||
alertContent = window.plugins.jPushPlugin.openNotification.alert;
|
alertContent = event.alert;
|
||||||
} else {
|
} else {
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@
|
|||||||
try {
|
try {
|
||||||
var alertContent;
|
var alertContent;
|
||||||
if (device.platform == "Android") {
|
if (device.platform == "Android") {
|
||||||
alertContent = window.plugins.jPushPlugin.receiveNotification.alert;
|
alertContent = event.alert;
|
||||||
} else {
|
} else {
|
||||||
alertContent = event.aps.alert;
|
alertContent = event.aps.alert;
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
try {
|
try {
|
||||||
var message;
|
var message;
|
||||||
if (device.platform == "Android") {
|
if (device.platform == "Android") {
|
||||||
message = window.plugins.jPushPlugin.receiveMessage.message;
|
message = event.message;
|
||||||
} else {
|
} else {
|
||||||
message = event.content;
|
message = event.content;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) JiGuang <support@jpush.cn> (jiguang.cn)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
+8
-4
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "2.1.6",
|
"version": "2.2.6",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "cn.jpush.phonegap.JPushPlugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
"platforms": [
|
"platforms": [
|
||||||
"ios",
|
"ios",
|
||||||
"android"
|
"android"
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"JPush",
|
"JPush",
|
||||||
"push",
|
"push",
|
||||||
|
"Push",
|
||||||
"ecosystem:cordova",
|
"ecosystem:cordova",
|
||||||
"cordova-ios",
|
"cordova-ios",
|
||||||
"cordova-android"
|
"cordova-android"
|
||||||
@@ -26,8 +27,11 @@
|
|||||||
"version": ">=3.0"
|
"version": ">=3.0"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"author": "jpush",
|
"peerDependencies": {
|
||||||
"license": "Apache 2.0 License",
|
"cordova-plugin-device": ">=1.0.0"
|
||||||
|
},
|
||||||
|
"author": "JiGuang",
|
||||||
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/jpush/jpush-phonegap-plugin/issues"
|
"url": "https://github.com/jpush/jpush-phonegap-plugin/issues"
|
||||||
},
|
},
|
||||||
|
|||||||
+120
-108
@@ -1,180 +1,192 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<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="cn.jpush.phonegap.JPushPlugin"
|
id="jpush-phonegap-plugin"
|
||||||
version="2.1.6">
|
version="2.2.5">
|
||||||
|
|
||||||
<name>JPush Plugin</name>
|
<name>JPush Plugin</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
<author>JPush</author>
|
<author>JPush</author>
|
||||||
<keywords>JPush,push</keywords>
|
<keywords>JPush,push</keywords>
|
||||||
<license>Apache 2.0 License</license>
|
<license>MIT License</license>
|
||||||
|
|
||||||
<preference name="API_KEY" />
|
<preference name="API_KEY" />
|
||||||
|
|
||||||
<engines>
|
<engines>
|
||||||
<engine name="cordova" version=">=3.0"/>
|
<engine name="cordova" version=">=3.0" />
|
||||||
</engines>
|
</engines>
|
||||||
|
|
||||||
|
<!-- dependencies -->
|
||||||
|
<dependency id="cordova-plugin-device" />
|
||||||
|
|
||||||
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
||||||
<clobbers target="jPushPlugin"/>
|
<clobbers target="JPush" />
|
||||||
</js-module>
|
</js-module>
|
||||||
|
|
||||||
<platform name="ios">
|
<platform name="ios">
|
||||||
<config-file target="config.xml" parent="/*">
|
<config-file target="config.xml" parent="/*">
|
||||||
<feature name="JPushPlugin">
|
<feature name="JPushPlugin">
|
||||||
<param name="ios-package" value="JPushPlugin"/>
|
<param name="ios-package" value="JPushPlugin" />
|
||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<header-file src="src/ios/Plugins/JPushPlugin.h"/>
|
<header-file src="src/ios/Plugins/JPushPlugin.h" />
|
||||||
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
<source-file src="src/ios/Plugins/JPushPlugin.m" />
|
||||||
|
|
||||||
<header-file src="src/ios/lib/JPUSHService.h" />
|
<header-file src="src/ios/lib/JPUSHService.h" />
|
||||||
<source-file src="src/ios/lib/jpush-ios-2.1.0.a" framework="true" />
|
<source-file src="src/ios/lib/jpush-ios-2.1.9.a" framework="true" />
|
||||||
<header-file src="src/ios/Plugins/AppDelegate+JPush.h"/>
|
<header-file src="src/ios/Plugins/AppDelegate+JPush.h" />
|
||||||
<source-file src="src/ios/Plugins/AppDelegate+JPush.m"/>
|
<source-file src="src/ios/Plugins/AppDelegate+JPush.m" />
|
||||||
<resource-file src="src/ios/PushConfig.plist" />
|
<resource-file src="src/ios/PushConfig.plist" />
|
||||||
<framework src="CFNetwork.framework" weak="true" />
|
<framework src="CFNetwork.framework" weak="true" />
|
||||||
<framework src="CoreFoundation.framework" weak="true" />
|
<framework src="CoreFoundation.framework" weak="true" />
|
||||||
<framework src="CoreTelephony.framework" weak="true" />
|
<framework src="CoreTelephony.framework" weak="true" />
|
||||||
<framework src="SystemConfiguration.framework" weak="true" />
|
<framework src="SystemConfiguration.framework" weak="true" />
|
||||||
<framework src="CoreGraphics.framework" weak="true" />
|
<framework src="CoreGraphics.framework" weak="true" />
|
||||||
<framework src="Foundation.framework" weak="true" />
|
<framework src="Foundation.framework" weak="true" />
|
||||||
<framework src="UIKit.framework" weak="true" />
|
<framework src="UIKit.framework" weak="true" />
|
||||||
<framework src="Security.framework" weak="true" />
|
<framework src="Security.framework" weak="true" />
|
||||||
<framework src="libz.dylib" weak="true" />
|
<framework src="libz.tbd" weak="true" />
|
||||||
|
<framework src="AdSupport.framework" weak="true" />
|
||||||
|
<framework src="UserNotifications.framework" weak="true" />
|
||||||
|
|
||||||
<config-file target="*PushConfig.plist" parent="APP_KEY">
|
|
||||||
<string>$API_KEY</string>
|
|
||||||
</config-file>
|
|
||||||
</platform>
|
|
||||||
|
|
||||||
<!-- android -->
|
<config-file target="*PushConfig.plist" parent="APP_KEY">
|
||||||
|
<string>$API_KEY</string>
|
||||||
|
</config-file>
|
||||||
|
</platform>
|
||||||
|
|
||||||
<platform name="android">
|
<platform name="android">
|
||||||
<hook type="after_plugin_add" src="scripts/android-install.js" />
|
|
||||||
<hook type="after_plugin_install" src="scripts/android-install.js" />
|
|
||||||
<hook type="before_plugin_rm" src="scripts/android-install.js" />
|
|
||||||
<hook type="before_plugin_uninstall" src="scripts/android-install.js" />
|
|
||||||
|
|
||||||
<config-file target="res/xml/config.xml" parent="/*">
|
<config-file target="res/xml/config.xml" parent="/*">
|
||||||
<feature name="JPushPlugin">
|
<feature name="JPushPlugin">
|
||||||
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin"/>
|
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin" />
|
||||||
</feature>
|
</feature>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
|
||||||
<config-file target="AndroidManifest.xml" parent="/manifest">
|
<config-file target="AndroidManifest.xml" parent="/manifest">
|
||||||
<!-- Required 一些系统要求的权限,如访问网络等-->
|
<!-- Required 一些系统要求的权限,如访问网络等-->
|
||||||
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"/>
|
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT"/>
|
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.VIBRATE"/>
|
<uses-permission android:name="android.permission.VIBRATE" />
|
||||||
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
|
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
|
||||||
<permission
|
<permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE" android:protectionLevel="signature" />
|
||||||
android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"
|
|
||||||
android:protectionLevel="signature"/>
|
|
||||||
</config-file>
|
</config-file>
|
||||||
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
<config-file target="AndroidManifest.xml" parent="/manifest/application">
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<activity
|
<activity android:name="cn.jpush.android.ui.PushActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="orientation|keyboardHidden">
|
||||||
android:name="cn.jpush.android.ui.PushActivity"
|
|
||||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
|
||||||
android:configChanges="orientation|keyboardHidden">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.ui.PushActivity"/>
|
<action android:name="cn.jpush.android.ui.PushActivity" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<category android:name="$PACKAGE_NAME"/>
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Rich push 核心功能 since 2.0.6-->
|
||||||
|
<activity android:name="cn.jpush.android.ui.PopWinActivity" android:theme="@style/MyDialogStyle" android:exported="false">
|
||||||
|
</activity>
|
||||||
|
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<service
|
<service android:name="cn.jpush.android.service.DownloadService"
|
||||||
android:name="cn.jpush.android.service.DownloadService"
|
android:enabled="true"
|
||||||
android:enabled="true"
|
android:exported="false">
|
||||||
android:exported="false">
|
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Required SDK 核心功能-->
|
<!-- Required SDK 核心功能-->
|
||||||
<service
|
<service android:name="cn.jpush.android.service.PushService"
|
||||||
android:name="cn.jpush.android.service.PushService"
|
android:enabled="true"
|
||||||
android:enabled="true"
|
android:exported="false">
|
||||||
android:exported="false">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="cn.jpush.android.intent.REGISTER"/>
|
<action android:name="cn.jpush.android.intent.REGISTER" />
|
||||||
<action android:name="cn.jpush.android.intent.REPORT"/>
|
<action android:name="cn.jpush.android.intent.REPORT" />
|
||||||
<action android:name="cn.jpush.android.intent.PushService"/>
|
<action android:name="cn.jpush.android.intent.PushService" />
|
||||||
<action android:name="cn.jpush.android.intent.PUSH_TIME"/>
|
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<receiver
|
<receiver android:name="cn.jpush.android.service.PushReceiver"
|
||||||
android:name="cn.jpush.android.service.PushReceiver"
|
android:enabled="true">
|
||||||
android:enabled="true">
|
|
||||||
<intent-filter android:priority="1000">
|
<intent-filter android:priority="1000">
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
|
||||||
<!--Required 显示通知栏 -->
|
<!--Required 显示通知栏 -->
|
||||||
<category android:name="$PACKAGE_NAME"/>
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.USER_PRESENT"/>
|
<action android:name="android.intent.action.USER_PRESENT" />
|
||||||
<action android:name="android.net.conn.CONNECTIVITY_CHANGE"/>
|
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<!-- Optional -->
|
<!-- Optional -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.PACKAGE_ADDED"/>
|
<action android:name="android.intent.action.PACKAGE_ADDED" />
|
||||||
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
<action android:name="android.intent.action.PACKAGE_REMOVED" />
|
||||||
<data android:scheme="package"/>
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 -->
|
||||||
|
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
|
||||||
|
<service android:name="cn.jpush.android.service.DaemonService" android:enabled="true" android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="cn.jpush.android.intent.DaemonService" />
|
||||||
|
<category android:name="$PACKAGE_NAME" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||||
<receiver
|
<receiver android:name="cn.jpush.phonegap.MyReceiver" android:enabled="true">
|
||||||
android:name="cn.jpush.phonegap.MyReceiver"
|
|
||||||
android:enabled="true">
|
|
||||||
<intent-filter android:priority="1000">
|
<intent-filter android:priority="1000">
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY"/>
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
|
||||||
<!-- Required 显示通知栏 -->
|
<!-- Required 显示通知栏 -->
|
||||||
<category android:name="$PACKAGE_NAME"/>
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</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 -->
|
<!-- Required 用户注册SDK的intent -->
|
||||||
<action android:name="cn.jpush.android.intent.UNREGISTRATION"/>
|
<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 -->
|
<!-- Required 用户接收SDK消息的intent -->
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED"/>
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
||||||
<!-- Required 用户接收SDK通知栏信息的intent -->
|
<!-- Required 用户接收SDK通知栏信息的intent -->
|
||||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED"/>
|
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
||||||
<!-- Required 用户打开自定义通知栏的intent -->
|
<!-- Required 用户打开自定义通知栏的intent -->
|
||||||
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK"/>
|
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
|
||||||
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
|
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
|
||||||
<category android:name="$PACKAGE_NAME"/>
|
<category android:name="$PACKAGE_NAME" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
<!-- Required SDK核心功能-->
|
<!-- Required SDK核心功能-->
|
||||||
<receiver android:name="cn.jpush.android.service.AlarmReceiver"/>
|
<receiver android:name="cn.jpush.android.service.AlarmReceiver" />
|
||||||
<!-- Required . Enable it you can get statistics data with channel -->
|
<!-- Required. Enable it you can get statistics data with channel -->
|
||||||
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default"/>
|
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" />
|
||||||
<meta-data android:name="JPUSH_APPKEY" android:value="$API_KEY"/>
|
<meta-data android:name="JPUSH_APPKEY" android:value="$API_KEY" />
|
||||||
</config-file>
|
</config-file>
|
||||||
<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/jpush-android-2.1.9.jar" target-dir="libs" />
|
||||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
<source-file src="src/android/armeabi/libjpush219.so" target-dir="libs/armeabi" />
|
||||||
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
<source-file src="src/android/armeabi-v7a/libjpush219.so" target-dir="libs/armeabi-v7a" />
|
||||||
<source-file src="src/android/jpush_notification_icon.png" target-dir="res/drawable"/>
|
<source-file src="src/android/arm64-v8a/libjpush219.so" target-dir="libs/arm64-v8a" />
|
||||||
|
<source-file src="src/android/x86/libjpush219.so" target-dir="libs/x86" />
|
||||||
|
<source-file src="src/android/x86_64/libjpush219.so" target-dir="libs/x86_64" />
|
||||||
|
|
||||||
|
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap" />
|
||||||
|
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap" />
|
||||||
|
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout" />
|
||||||
|
<source-file src="src/android/jpush_notification_icon.png" target-dir="res/drawable" />
|
||||||
|
|
||||||
|
<!-- Rich Push resources -->
|
||||||
|
<source-file src="src/android/ic_richpush_actionbar_back.png" target-dir="res/drawable" />
|
||||||
|
<source-file src="src/android/ic_richpush_actionbar_divider.png" target-dir="res/drawable" />
|
||||||
|
<source-file src="src/android/richpush_btn_selector.xml" target-dir="res/drawable" />
|
||||||
|
<source-file src="src/android/jpush_popwin_layout.xml" target-dir="res/layout" />
|
||||||
|
<source-file src="src/android/jpush_webview_layout.xml" target-dir="res/layout" />
|
||||||
|
<source-file src="src/android/jpush_style.xml" target-dir="res/values" />
|
||||||
|
|
||||||
</platform>
|
</platform>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@@ -1,49 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
module.exports = function (context) {
|
|
||||||
var path = context.requireCordovaModule('path'),
|
|
||||||
fs = context.requireCordovaModule('fs'),
|
|
||||||
shell = context.requireCordovaModule('shelljs'),
|
|
||||||
projectRoot = context.opts.projectRoot,
|
|
||||||
ConfigParser = context.requireCordovaModule('cordova-lib/src/configparser/ConfigParser'),
|
|
||||||
config = new ConfigParser(path.join(context.opts.projectRoot, "config.xml")),
|
|
||||||
packageName = config.android_packageName() || config.packageName();
|
|
||||||
|
|
||||||
console.info("Running android-install.Hook: " + context.hook
|
|
||||||
+ ", Package: " + packageName + ", Path: " + projectRoot + ".");
|
|
||||||
|
|
||||||
if (!packageName) {
|
|
||||||
console.error("Package name could not be found!");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// android platform available?
|
|
||||||
if (context.opts.cordova.platforms.indexOf("android") === -1) {
|
|
||||||
console.info("Android platform has not been added.");
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
var targetDir = path.join(projectRoot, "platforms", "android", "src", "cn", "jpush", "phonegap");
|
|
||||||
targetFile = path.join(targetDir, "JPushPlugin.java");
|
|
||||||
console.log(targetDir);
|
|
||||||
|
|
||||||
if (['after_plugin_add', 'after_plugin_install', 'after_platform_add'].indexOf(context.hook) === -1) {
|
|
||||||
// remove it?
|
|
||||||
try {
|
|
||||||
fs.unlinkSync(targetFile);
|
|
||||||
} catch (err) {}
|
|
||||||
} else {
|
|
||||||
// create directory
|
|
||||||
shell.mkdir('-p', targetDir);
|
|
||||||
|
|
||||||
// sync the content
|
|
||||||
fs.readFile(path.join(context.opts.plugin.dir, 'src', 'android', 'JPushPlugin.java'),
|
|
||||||
{encoding: 'utf-8'}, function (err, data) {
|
|
||||||
if (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
data = data.replace(/^import __PACKAGE_NAME__.R;/m, 'import ' + packageName + '.R;');
|
|
||||||
fs.writeFileSync(targetFile, data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,12 +1,14 @@
|
|||||||
package cn.jpush.phonegap;
|
package cn.jpush.phonegap;
|
||||||
|
|
||||||
|
import android.annotation.TargetApi;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.AppOpsManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import __PACKAGE_NAME__.R;
|
|
||||||
|
|
||||||
import org.apache.cordova.CallbackContext;
|
import org.apache.cordova.CallbackContext;
|
||||||
import org.apache.cordova.CordovaInterface;
|
import org.apache.cordova.CordovaInterface;
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
@@ -15,6 +17,8 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -28,7 +32,6 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
||||||
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
|
||||||
import cn.jpush.android.api.JPushInterface;
|
import cn.jpush.android.api.JPushInterface;
|
||||||
import cn.jpush.android.api.TagAliasCallback;
|
import cn.jpush.android.api.TagAliasCallback;
|
||||||
import cn.jpush.android.data.JPushLocalNotification;
|
import cn.jpush.android.data.JPushLocalNotification;
|
||||||
@@ -37,6 +40,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
private final static List<String> methodList =
|
private final static List<String> methodList =
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"addLocalNotification",
|
"addLocalNotification",
|
||||||
|
"areNotificationEnabled",
|
||||||
"clearAllNotification",
|
"clearAllNotification",
|
||||||
"clearLocalNotifications",
|
"clearLocalNotifications",
|
||||||
"clearNotificationById",
|
"clearNotificationById",
|
||||||
@@ -85,10 +89,10 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||||
super.initialize(cordova, webView);
|
Log.i(TAG, "JPush initialize.");
|
||||||
|
|
||||||
Log.i(TAG, "---------------- initialize" + "-" + openNotificationAlert
|
super.initialize(cordova, webView);
|
||||||
+ "-" + notificationAlert);
|
JPushInterface.init(cordova.getActivity().getApplicationContext());
|
||||||
|
|
||||||
cordovaActivity = cordova.getActivity();
|
cordovaActivity = cordova.getActivity();
|
||||||
|
|
||||||
@@ -139,7 +143,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static JSONObject getMessageObject(String message,
|
private static JSONObject getMessageObject(String message,
|
||||||
Map<String, Object> extras) {
|
Map<String, Object> extras) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
data.put("message", message);
|
data.put("message", message);
|
||||||
@@ -173,7 +177,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static JSONObject getNotificationObject(String title,
|
private static JSONObject getNotificationObject(String title,
|
||||||
String alert, Map<String, Object> extras) {
|
String alert, Map<String, Object> extras) {
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
try {
|
try {
|
||||||
data.put("title", title);
|
data.put("title", title);
|
||||||
@@ -181,7 +185,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
JSONObject jExtras = new JSONObject();
|
JSONObject jExtras = new JSONObject();
|
||||||
for (Entry<String, Object> entry : extras.entrySet()) {
|
for (Entry<String, Object> entry : extras.entrySet()) {
|
||||||
if (entry.getKey().equals("cn.jpush.android.EXTRA")) {
|
if (entry.getKey().equals("cn.jpush.android.EXTRA")) {
|
||||||
JSONObject jo = null;
|
JSONObject jo;
|
||||||
if (TextUtils.isEmpty((String) entry.getValue())) {
|
if (TextUtils.isEmpty((String) entry.getValue())) {
|
||||||
jo = new JSONObject();
|
jo = new JSONObject();
|
||||||
} else {
|
} else {
|
||||||
@@ -223,7 +227,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void transmitNotificationOpen(String title, String alert,
|
static void transmitNotificationOpen(String title, String alert,
|
||||||
Map<String, Object> extras) {
|
Map<String, Object> extras) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -241,7 +245,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void transmitNotificationReceive(String title, String alert,
|
static void transmitNotificationReceive(String title, String alert,
|
||||||
Map<String, Object> extras) {
|
Map<String, Object> extras) {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -260,7 +264,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final String action, final JSONArray data,
|
public boolean execute(final String action, final JSONArray data,
|
||||||
final CallbackContext callbackContext) throws JSONException {
|
final CallbackContext callbackContext) throws JSONException {
|
||||||
if (!methodList.contains(action)) {
|
if (!methodList.contains(action)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -314,6 +318,16 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void areNotificationEnabled(JSONArray data, final CallbackContext callback) {
|
||||||
|
int isEnabled;
|
||||||
|
if (hasPermission("OP_POST_NOTIFICATION")) {
|
||||||
|
isEnabled = 1;
|
||||||
|
} else {
|
||||||
|
isEnabled = 0;
|
||||||
|
}
|
||||||
|
callback.success(isEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
|
void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
|
||||||
int num = -1;
|
int num = -1;
|
||||||
try {
|
try {
|
||||||
@@ -425,7 +439,7 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setBasicPushNotificationBuilder(JSONArray data,
|
void setBasicPushNotificationBuilder(JSONArray data,
|
||||||
CallbackContext callbackContext) {
|
CallbackContext callbackContext) {
|
||||||
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
BasicPushNotificationBuilder builder = new BasicPushNotificationBuilder(
|
||||||
this.cordova.getActivity());
|
this.cordova.getActivity());
|
||||||
builder.developerArg0 = "Basic builder 1";
|
builder.developerArg0 = "Basic builder 1";
|
||||||
@@ -438,19 +452,17 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义推送通知栏样式,需要自己实现具体代码。
|
||||||
|
* http://docs.jiguang.cn/client/android_tutorials/#_11
|
||||||
|
*/
|
||||||
void setCustomPushNotificationBuilder(JSONArray data,
|
void setCustomPushNotificationBuilder(JSONArray data,
|
||||||
CallbackContext callbackContext) {
|
CallbackContext callbackContext) {
|
||||||
CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
// CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
||||||
this.cordova.getActivity(), R.layout.test_notification_layout,
|
// this.cordova.getActivity(), R.layout.test_notification_layout,
|
||||||
R.id.icon, R.id.title, R.id.text);
|
// R.id.icon, R.id.title, R.id.text);
|
||||||
builder.developerArg0 = "Custom Builder 1";
|
// JPushInterface.setPushNotificationBuilder(2, builder);
|
||||||
JPushInterface.setPushNotificationBuilder(2, builder);
|
// JPushInterface.setDefaultPushNotificationBuilder(builder);
|
||||||
JSONObject obj = new JSONObject();
|
|
||||||
try {
|
|
||||||
obj.put("id", 2);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
||||||
@@ -585,4 +597,37 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||||
|
private boolean hasPermission(String appOpsServiceId) {
|
||||||
|
Context context = cordova.getActivity().getApplicationContext();
|
||||||
|
AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
|
||||||
|
ApplicationInfo appInfo = context.getApplicationInfo();
|
||||||
|
|
||||||
|
String pkg = context.getPackageName();
|
||||||
|
int uid = appInfo.uid;
|
||||||
|
Class appOpsClazz = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
appOpsClazz = Class.forName(AppOpsManager.class.getName());
|
||||||
|
Method checkOpNoThrowMethod = appOpsClazz.getMethod("checkOpNoThrow",
|
||||||
|
Integer.TYPE, Integer.TYPE, String.class);
|
||||||
|
Field opValue = appOpsClazz.getDeclaredField(appOpsServiceId);
|
||||||
|
int value = opValue.getInt(Integer.class);
|
||||||
|
Object result = checkOpNoThrowMethod.invoke(mAppOps, value, uid, pkg);
|
||||||
|
|
||||||
|
return Integer.parseInt(result.toString()) == AppOpsManager.MODE_ALLOWED;
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public class MyReceiver extends BroadcastReceiver {
|
|||||||
handlingNotificationReceive(context, intent);
|
handlingNotificationReceive(context, intent);
|
||||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(action)) {
|
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(action)) {
|
||||||
handlingNotificationOpen(context, intent);
|
handlingNotificationOpen(context, intent);
|
||||||
|
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(action)) {
|
||||||
|
// 当在 HTML 页面中调用 JPushWeb.triggerNativeAction(String params) 方法时触发此方法,
|
||||||
|
// 再进行相关的操作。
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.d(TAG, "Unhandled intent - " + action);
|
Log.d(TAG, "Unhandled intent - " + action);
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 695 B |
Binary file not shown.
|
After Width: | Height: | Size: 181 B |
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/popLayoutId"
|
||||||
|
style="@style/MyDialogStyle"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="280dp"
|
||||||
|
android:layout_height="250dp" >
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/wvPopwin"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<style name="MyDialogStyle">
|
||||||
|
<item name="android:windowBackground">@android:color/transparent</item>
|
||||||
|
<item name="android:windowFrame">@null</item>
|
||||||
|
<item name="android:windowNoTitle">true</item>
|
||||||
|
<item name="android:windowIsFloating">true</item>
|
||||||
|
<item name="android:windowIsTranslucent">true</item>
|
||||||
|
<item name="android:windowContentOverlay">@null</item>
|
||||||
|
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
|
||||||
|
<item name="android:backgroundDimEnabled">true</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<cn.jpush.android.ui.FullScreenView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/actionbarLayoutId"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/rlRichpushTitleBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40.0dp"
|
||||||
|
android:background="#29313a">
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/imgRichpushBtnBack"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="9dp"
|
||||||
|
android:layout_marginRight="10dp"
|
||||||
|
android:background="@drawable/richpush_btn_selector" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/imgView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toRightOf="@id/imgRichpushBtnBack"
|
||||||
|
android:clickable="false"
|
||||||
|
android:src="@drawable/ic_richpush_actionbar_divider" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvRichpushTitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginLeft="7dp"
|
||||||
|
android:layout_toRightOf="@id/imgView"
|
||||||
|
android:clickable="false"
|
||||||
|
android:text=" "
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="#ffffff" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<WebView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:id="@+id/fullWebView"
|
||||||
|
android:background="#000000" />
|
||||||
|
|
||||||
|
</cn.jpush.android.ui.FullScreenView>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<!-- 获得焦点但未按下时的背景图片 -->
|
||||||
|
<item
|
||||||
|
android:state_focused="true"
|
||||||
|
android:state_enabled="true"
|
||||||
|
android:state_pressed="false"
|
||||||
|
android:drawable="@drawable/ic_richpush_actionbar_back" />
|
||||||
|
<!-- 按下时的背景图片 -->
|
||||||
|
<item
|
||||||
|
android:state_enabled="true"
|
||||||
|
android:state_pressed="true"
|
||||||
|
android:drawable="@android:color/darker_gray" />
|
||||||
|
<!-- 按下时的背景图片 -->
|
||||||
|
<item
|
||||||
|
android:state_enabled="true"
|
||||||
|
android:state_checked="true"
|
||||||
|
android:drawable="@android:color/darker_gray" />
|
||||||
|
<!-- 默认时的背景图片 -->
|
||||||
|
<item android:drawable="@drawable/ic_richpush_actionbar_back" />
|
||||||
|
</selector>
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -7,7 +7,9 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#import "AppDelegate.h"
|
#import "AppDelegate.h"
|
||||||
|
#import <UserNotifications/UserNotifications.h>
|
||||||
|
#import "JPUSHService.h"
|
||||||
|
|
||||||
@interface AppDelegate (JPush)
|
@interface AppDelegate (JPush) <JPUSHRegisterDelegate>
|
||||||
|
-(void)registerForIos10RemoteNotification;
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -8,8 +8,11 @@
|
|||||||
|
|
||||||
#import "AppDelegate+JPush.h"
|
#import "AppDelegate+JPush.h"
|
||||||
#import "JPushPlugin.h"
|
#import "JPushPlugin.h"
|
||||||
#import "JPUSHService.h"
|
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
|
#import <AdSupport/AdSupport.h>
|
||||||
|
#import <UserNotifications/UserNotifications.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@implementation AppDelegate (JPush)
|
@implementation AppDelegate (JPush)
|
||||||
|
|
||||||
@@ -24,12 +27,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(instancetype)init_plus{
|
-(instancetype)init_plus{
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidLaunch:) name:@"UIApplicationDidFinishLaunchingNotification" object:nil];
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidLaunch:) name:UIApplicationDidFinishLaunchingNotification object:nil];
|
||||||
return [self init_plus];
|
return [self init_plus];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)applicationDidLaunch:(NSNotification *)notification{
|
-(void)applicationDidLaunch:(NSNotification *)notification{
|
||||||
if (notification) {
|
if (notification) {
|
||||||
|
[self registerForIos10RemoteNotification];
|
||||||
[JPushPlugin setLaunchOptions:notification.userInfo];
|
[JPushPlugin setLaunchOptions:notification.userInfo];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -62,4 +66,33 @@
|
|||||||
// [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
// [[UIApplication sharedApplication] setApplicationIconBadgeNumber:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
|
||||||
|
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo];
|
||||||
|
|
||||||
|
[userInfo setValue:kJPushPluginiOS10ForegroundReceiveNotification forKey:@"JPushNotificationType"];
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginiOS10ForegroundReceiveNotification object:userInfo];
|
||||||
|
|
||||||
|
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{
|
||||||
|
NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo];
|
||||||
|
[userInfo setValue:kJPushPluginiOS10ClickNotification forKey:@"JPushNotificationType"];
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginiOS10ClickNotification object:userInfo];
|
||||||
|
|
||||||
|
completionHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
-(void)registerForIos10RemoteNotification{
|
||||||
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||||
|
#ifdef NSFoundationVersionNumber_iOS_9_x_Max
|
||||||
|
JPUSHRegisterEntity * entity = [[JPUSHRegisterEntity alloc] init];
|
||||||
|
entity.types = UNAuthorizationOptionAlert|UNAuthorizationOptionBadge|UNAuthorizationOptionSound;
|
||||||
|
[JPUSHService registerForRemoteNotificationConfig:entity delegate:self];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -9,6 +9,9 @@
|
|||||||
#import <Cordova/CDV.h>
|
#import <Cordova/CDV.h>
|
||||||
|
|
||||||
#define kJPushPluginReceiveNotification @"JPushPluginReceiveNofication"
|
#define kJPushPluginReceiveNotification @"JPushPluginReceiveNofication"
|
||||||
|
#define kJPushPluginiOS10ForegroundReceiveNotification @"kJPushPluginiOS10ForegroundReceiveNotification"
|
||||||
|
#define kJPushPluginiOS10ClickNotification @"kJPushPluginiOS10ClickNotification"
|
||||||
|
|
||||||
|
|
||||||
@interface JPushPlugin : CDVPlugin{
|
@interface JPushPlugin : CDVPlugin{
|
||||||
|
|
||||||
@@ -58,13 +61,16 @@
|
|||||||
//地理位置上报 [latitude,longitude]
|
//地理位置上报 [latitude,longitude]
|
||||||
-(void)setLocation:(CDVInvokedUrlCommand*)command;
|
-(void)setLocation:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
|
//检查用户的推送设置情况
|
||||||
|
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 以下为js中可监听到的事件
|
* 以下为js中可监听到的事件
|
||||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||||
* jpush.setTagsWithAlias 设置标签、别名完成
|
* jpush.setTagsWithAlias 设置标签、别名完成
|
||||||
* jpush.receiveMessage 收到自定义消息
|
* jpush.receiveMessage 收到自定义消息
|
||||||
* jpush.receiveNotification 前台收到推送
|
* jpush.receiveNotification 前台收到推送
|
||||||
* jpush.backgoundNotification 后台收到推送
|
* jpush.backgroundNotification 后台收到推送
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
+128
-70
@@ -9,12 +9,40 @@
|
|||||||
#import "JPushPlugin.h"
|
#import "JPushPlugin.h"
|
||||||
#import "JPUSHService.h"
|
#import "JPUSHService.h"
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
#import <AdSupport/AdSupport.h>
|
||||||
|
#import <UserNotifications/UserNotifications.h>
|
||||||
|
#import "AppDelegate+JPush.h"
|
||||||
|
|
||||||
static NSString *const JM_APP_KEY = @"APP_KEY";
|
static NSString *const JP_APP_KEY = @"APP_KEY";
|
||||||
static NSString *const JM_APP_CHANNEL = @"CHANNEL";
|
static NSString *const JP_APP_CHANNEL = @"CHANNEL";
|
||||||
static NSString *const JM_APP_ISPRODUCTION = @"IsProduction";
|
static NSString *const JP_APP_ISPRODUCTION = @"IsProduction";
|
||||||
|
static NSString *const JP_APP_ISIDFA = @"IsIDFA";
|
||||||
static NSString *const JPushConfigFileName = @"PushConfig";
|
static NSString *const JPushConfigFileName = @"PushConfig";
|
||||||
static NSDictionary *_luanchOptions = nil;
|
static NSDictionary *_launchOptions = nil;
|
||||||
|
|
||||||
|
#define WEAK_SELF(weakSelf) __weak __typeof(&*self)weakSelf = self;
|
||||||
|
|
||||||
|
@implementation NSDictionary (JPush)
|
||||||
|
-(NSString*)toJsonString{
|
||||||
|
NSError *error;
|
||||||
|
NSData *data = [NSJSONSerialization dataWithJSONObject:self options:0 error:&error];
|
||||||
|
NSString *jsonString = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
|
||||||
|
return jsonString;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation NSString (JPush)
|
||||||
|
-(NSDictionary*)toDictionary{
|
||||||
|
NSError *error;
|
||||||
|
NSData *jsonData = [self dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
NSDictionary *dict = [NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface JPushPlugin()
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation JPushPlugin
|
@implementation JPushPlugin
|
||||||
|
|
||||||
@@ -27,22 +55,6 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
[JPushPlugin registerForRemoteNotification];
|
[JPushPlugin registerForRemoteNotification];
|
||||||
}
|
}
|
||||||
|
|
||||||
+(void)registerForRemoteNotification{
|
|
||||||
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
|
|
||||||
//可以添加自定义categories
|
|
||||||
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
|
|
||||||
UIUserNotificationTypeSound |
|
|
||||||
UIUserNotificationTypeAlert)
|
|
||||||
categories:nil];
|
|
||||||
} else {
|
|
||||||
//categories 必须为nil
|
|
||||||
[JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
|
|
||||||
UIRemoteNotificationTypeSound |
|
|
||||||
UIRemoteNotificationTypeAlert)
|
|
||||||
categories:nil];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
-(void)isPushStopped:(CDVInvokedUrlCommand*)command{
|
-(void)isPushStopped:(CDVInvokedUrlCommand*)command{
|
||||||
NSNumber *result;
|
NSNumber *result;
|
||||||
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {
|
if ([[UIApplication sharedApplication] isRegisteredForRemoteNotifications]) {
|
||||||
@@ -50,7 +62,7 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
}else{
|
}else{
|
||||||
result = @(1);
|
result = @(1);
|
||||||
}
|
}
|
||||||
[self hanleResultWithValue:result command:command];
|
[self handleResultWithValue:result command:command];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)initial:(CDVInvokedUrlCommand*)command{
|
-(void)initial:(CDVInvokedUrlCommand*)command{
|
||||||
@@ -90,19 +102,23 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
name:kJPushPluginReceiveNotification
|
name:kJPushPluginReceiveNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
if (_luanchOptions) {
|
[defaultCenter addObserver:self
|
||||||
NSDictionary *userInfo = [_luanchOptions
|
selector:@selector(networkDidReceiveNotification:)
|
||||||
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
name:kJPushPluginiOS10ForegroundReceiveNotification
|
||||||
if ([userInfo count] >0) {
|
object:nil];
|
||||||
NSError *error;
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
||||||
if (!error) {
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",jsonString]];
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
[defaultCenter addObserver:self
|
||||||
|
selector:@selector(networkDidReceiveNotification:)
|
||||||
|
name:kJPushPluginiOS10ClickNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
|
||||||
|
if (_launchOptions) {
|
||||||
|
NSDictionary *userInfo = [_launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
||||||
|
if ([userInfo count] >0) {
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.openNotification',%@)",[userInfo toJsonString]]];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -151,7 +167,7 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||||
NSString* registrationID = [JPUSHService registrationID];
|
NSString* registrationID = [JPUSHService registrationID];
|
||||||
NSLog(@"### getRegistrationID %@",registrationID);
|
NSLog(@"### getRegistrationID %@",registrationID);
|
||||||
[self hanleResultWithValue:registrationID command:command];
|
[self handleResultWithValue:registrationID command:command];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
|
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
|
||||||
@@ -220,7 +236,7 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
|
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
|
||||||
NSInteger num = [UIApplication sharedApplication].applicationIconBadgeNumber;
|
NSInteger num = [UIApplication sharedApplication].applicationIconBadgeNumber;
|
||||||
NSNumber *number = [NSNumber numberWithInteger:num];
|
NSNumber *number = [NSNumber numberWithInteger:num];
|
||||||
[self hanleResultWithValue:number command:command];
|
[self handleResultWithValue:number command:command];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
|
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
|
||||||
@@ -246,7 +262,14 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{
|
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{
|
||||||
[JPUSHService deleteLocalNotificationWithIdentifierKey:(NSString*)command.arguments[0]];
|
NSString *identifier = [command argumentAtIndex:0];
|
||||||
|
if ([UIDevice currentDevice].systemVersion.floatValue >= 10.0) {
|
||||||
|
JPushNotificationIdentifier *jpid = [JPushNotificationIdentifier new];
|
||||||
|
jpid.identifiers = @[identifier];
|
||||||
|
[JPUSHService removeNotification:jpid];
|
||||||
|
}else{
|
||||||
|
[JPUSHService deleteLocalNotificationWithIdentifierKey:identifier];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command{
|
-(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command{
|
||||||
@@ -257,9 +280,37 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
[JPUSHService setLatitude:[((NSString*)command.arguments[0]) doubleValue] longitude:[((NSString*)command.arguments[1]) doubleValue]];
|
[JPUSHService setLatitude:[((NSString*)command.arguments[0]) doubleValue] longitude:[((NSString*)command.arguments[1]) doubleValue]];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark- 内部方法
|
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command{
|
||||||
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) {
|
||||||
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
||||||
|
WEAK_SELF(weakSelf);
|
||||||
|
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
|
||||||
|
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
||||||
|
dict[@"authorizationStatus"] = @(settings.authorizationStatus);
|
||||||
|
dict[@"soundSetting"] = @(settings.soundSetting);
|
||||||
|
dict[@"badgeSetting"] = @(settings.badgeSetting);
|
||||||
|
dict[@"alertSetting"] = @(settings.alertSetting);
|
||||||
|
dict[@"notificationCenterSetting"] = @(settings.notificationCenterSetting);
|
||||||
|
dict[@"lockScreenSetting"] = @(settings.lockScreenSetting);
|
||||||
|
dict[@"carPlaySetting"] = @(settings.carPlaySetting);
|
||||||
|
dict[@"alertStyle"] = @(settings.alertStyle);
|
||||||
|
[weakSelf handleResultWithValue:dict command:command];
|
||||||
|
}];
|
||||||
|
}else if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
|
||||||
|
UIUserNotificationSettings *settings = [[UIApplication sharedApplication] currentUserNotificationSettings];
|
||||||
|
UIUserNotificationType type = settings.types;
|
||||||
|
NSNumber *number = [NSNumber numberWithInteger:type];
|
||||||
|
[self handleResultWithValue:number command:command];
|
||||||
|
}else{
|
||||||
|
UIRemoteNotificationType type = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
|
||||||
|
NSNumber *number = [NSNumber numberWithInteger:type];
|
||||||
|
[self handleResultWithValue:number command:command];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma mark - 内部方法
|
||||||
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
+(void)setLaunchOptions:(NSDictionary *)theLaunchOptions{
|
||||||
_luanchOptions = theLaunchOptions;
|
_launchOptions = theLaunchOptions;
|
||||||
|
|
||||||
[JPUSHService setDebugMode];
|
[JPUSHService setDebugMode];
|
||||||
|
|
||||||
@@ -273,21 +324,43 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
|
NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
|
||||||
NSString * appkey = [plistData valueForKey:JM_APP_KEY];
|
NSString * appkey = [plistData valueForKey:JP_APP_KEY];
|
||||||
NSString * channel = [plistData valueForKey:JM_APP_CHANNEL];
|
NSString * channel = [plistData valueForKey:JP_APP_CHANNEL];
|
||||||
NSNumber * isProduction = [plistData valueForKey:JM_APP_ISPRODUCTION];
|
NSNumber * isProduction = [plistData valueForKey:JP_APP_ISPRODUCTION];
|
||||||
|
NSNumber *isIDFA = [plistData valueForKey:JP_APP_ISIDFA];
|
||||||
|
|
||||||
if (!appkey || appkey.length == 0) {
|
NSString *advertisingId = nil;
|
||||||
NSLog(@"error: app key not found in PushConfig.plist ");
|
if(isIDFA){
|
||||||
assert(0);
|
advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
|
||||||
}
|
}
|
||||||
|
[JPUSHService setupWithOption:_launchOptions
|
||||||
|
appKey:appkey
|
||||||
|
channel:channel
|
||||||
|
apsForProduction:[isProduction boolValue]
|
||||||
|
advertisingIdentifier:advertisingId];
|
||||||
|
|
||||||
[JPUSHService setupWithOption:_luanchOptions appKey:appkey
|
}
|
||||||
channel:channel apsForProduction:[isProduction boolValue] ];
|
|
||||||
|
+(void)registerForRemoteNotification{
|
||||||
|
[(AppDelegate*)[UIApplication sharedApplication].delegate registerForIos10RemoteNotification];
|
||||||
|
|
||||||
|
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
|
||||||
|
//可以添加自定义categories
|
||||||
|
[JPUSHService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
|
||||||
|
UIUserNotificationTypeSound |
|
||||||
|
UIUserNotificationTypeAlert)
|
||||||
|
categories:nil];
|
||||||
|
} else if([[UIDevice currentDevice].systemVersion floatValue] < 8.0){
|
||||||
|
//categories 必须为nil
|
||||||
|
[JPUSHService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
|
||||||
|
UIRemoteNotificationTypeSound |
|
||||||
|
UIRemoteNotificationTypeAlert)
|
||||||
|
categories:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark 将参数返回给js
|
#pragma mark 将参数返回给js
|
||||||
-(void)hanleResultWithValue:(id)value command:(CDVInvokedUrlCommand*)command{
|
-(void)handleResultWithValue:(id)value command:(CDVInvokedUrlCommand*)command{
|
||||||
CDVPluginResult *result = nil;
|
CDVPluginResult *result = nil;
|
||||||
CDVCommandStatus status = CDVCommandStatus_OK;
|
CDVCommandStatus status = CDVCommandStatus_OK;
|
||||||
|
|
||||||
@@ -312,50 +385,35 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
|
|
||||||
#pragma mark 设置标签及别名回调
|
#pragma mark 设置标签及别名回调
|
||||||
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
|
-(void)tagsWithAliasCallback:(int)resultCode tags:(NSSet *)tags alias:(NSString *)alias{
|
||||||
|
|
||||||
NSDictionary *dict = @{@"resultCode":[NSNumber numberWithInt:resultCode],
|
NSDictionary *dict = @{@"resultCode":[NSNumber numberWithInt:resultCode],
|
||||||
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
|
@"tags" :tags == nil ? [NSNull null] : [tags allObjects],
|
||||||
@"alias" :alias == nil ? [NSNull null] : alias
|
@"alias" :alias == nil ? [NSNull null] : alias
|
||||||
};
|
};
|
||||||
NSError *error;
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dict options:0 error:&error];
|
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",jsonString]];
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.setTagsWithAlias',%@)",[dict toJsonString]]];
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
- (void)networkDidReceiveMessage:(NSNotification *)notification {
|
||||||
if (notification) {
|
if (notification) {
|
||||||
NSDictionary *userInfo = [notification userInfo];
|
|
||||||
//NSLog(@"%@",userInfo);
|
|
||||||
|
|
||||||
NSError *error;
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
||||||
|
|
||||||
//NSLog(@"%@",jsonString);
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveMessage',%@)",jsonString]];
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"cordova.fireDocumentEvent('jpush.receiveMessage',%@)",[notification.userInfo toJsonString]]];
|
||||||
|
|
||||||
[self.commandDelegate evalJs:[NSString stringWithFormat:@"window.plugins.jPushPlugin.receiveMessageIniOSCallback('%@')",jsonString]];
|
[self.commandDelegate evalJs:[NSString stringWithFormat:@"window.plugins.jPushPlugin.receiveMessageIniOSCallback('%@')",[notification.userInfo toJsonString]]];
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)networkDidReceiveNotification:(id)notification{
|
-(void)networkDidReceiveNotification:(NSNotification *)notification{
|
||||||
|
|
||||||
NSError *error;
|
NSError *error;
|
||||||
NSDictionary *userInfo = [notification object];
|
NSDictionary *userInfo = [notification object];
|
||||||
|
|
||||||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:userInfo options:0 error:&error];
|
||||||
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
NSString *jsonString = [[NSString alloc]initWithData:jsonData encoding:NSUTF8StringEncoding];
|
||||||
|
|
||||||
switch ([UIApplication sharedApplication].applicationState) {
|
switch ([UIApplication sharedApplication].applicationState) {
|
||||||
case UIApplicationStateActive:{
|
case UIApplicationStateActive:{
|
||||||
//前台收到
|
//前台收到
|
||||||
@@ -379,10 +437,10 @@ static NSDictionary *_luanchOptions = nil;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
//do nothing
|
//do nothing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -8,5 +8,7 @@
|
|||||||
<string>Subscription</string>
|
<string>Subscription</string>
|
||||||
<key>IsProduction</key>
|
<key>IsProduction</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>IsIDFA</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
Executable → Regular
+172
-19
@@ -9,23 +9,102 @@
|
|||||||
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
|
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define JPUSH_VERSION_NUMBER 2.1.0
|
#define JPUSH_VERSION_NUMBER 2.1.9
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@class CLRegion;
|
@class CLRegion;
|
||||||
@class UILocalNotification;
|
@class UILocalNotification;
|
||||||
|
@class CLLocation;
|
||||||
|
@class UNNotificationCategory;
|
||||||
|
@class UNNotificationSettings;
|
||||||
|
@class UNNotificationRequest;
|
||||||
|
@class UNNotification;
|
||||||
|
@protocol JPUSHRegisterDelegate;
|
||||||
|
|
||||||
extern NSString *const kJPFNetworkIsConnectingNotification; // 正在连接中
|
extern NSString *const kJPFNetworkIsConnectingNotification; // 正在连接中
|
||||||
extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
|
extern NSString *const kJPFNetworkDidSetupNotification; // 建立连接
|
||||||
extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
|
extern NSString *const kJPFNetworkDidCloseNotification; // 关闭连接
|
||||||
extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
|
extern NSString *const kJPFNetworkDidRegisterNotification; // 注册成功
|
||||||
|
extern NSString *const kJPFNetworkFailedRegisterNotification; //注册失败
|
||||||
extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
|
extern NSString *const kJPFNetworkDidLoginNotification; // 登录成功
|
||||||
extern NSString *const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
extern NSString *const kJPFNetworkDidReceiveMessageNotification; // 收到消息(非APNS)
|
||||||
extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||||
|
|
||||||
@class CLLocation;
|
/*!
|
||||||
|
* 通知注册实体类
|
||||||
|
*/
|
||||||
|
@interface JPUSHRegisterEntity : NSObject
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* 支持的类型
|
||||||
|
* badge,sound,alert
|
||||||
|
*/
|
||||||
|
@property (nonatomic, assign) NSInteger types;
|
||||||
|
/*!
|
||||||
|
* 注入的类别
|
||||||
|
* iOS10 UNNotificationCategory
|
||||||
|
* iOS8-iOS9 UIUserNotificationCategory
|
||||||
|
*/
|
||||||
|
@property (nonatomic, strong) NSSet *categories;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* 进行删除、查找推送实体类
|
||||||
|
*/
|
||||||
|
@interface JPushNotificationIdentifier : NSObject<NSCopying, NSCoding>
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSArray<NSString *> *identifiers; // 推送的标识数组
|
||||||
|
@property (nonatomic, copy) UILocalNotification *notificationObj NS_DEPRECATED_IOS(4_0, 10_0); // iOS10以下可以传UILocalNotification对象数据,iOS10以上无效
|
||||||
|
@property (nonatomic, assign) BOOL delivered NS_AVAILABLE_IOS(10_0); // 在通知中心显示的或待推送的标志,默认为NO,YES表示在通知中心显示的,NO表示待推送的
|
||||||
|
@property (nonatomic, copy) void (^findCompletionHandler)(NSArray *results); // 用于查询回调,调用[findNotification:]方法前必须设置,results为返回相应对象数组,iOS10以下返回UILocalNotification对象数组;iOS10以上根据delivered传入值返回UNNotification或UNNotificationRequest对象数组(delivered传入YES,则返回UNNotification对象数组,否则返回UNNotificationRequest对象数组)
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* 推送内容实体类
|
||||||
|
*/
|
||||||
|
@interface JPushNotificationContent : NSObject<NSCopying, NSCoding>
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *title; // 推送标题
|
||||||
|
@property (nonatomic, copy) NSString *subtitle; // 推送副标题
|
||||||
|
@property (nonatomic, copy) NSString *body; // 推送内容
|
||||||
|
@property (nonatomic, copy) NSNumber *badge; // 角标的数字。如果不需要改变角标传@(-1)
|
||||||
|
@property (nonatomic, copy) NSString *action NS_DEPRECATED_IOS(8_0, 10_0); // 弹框的按钮显示的内容(IOS 8默认为"打开", 其他默认为"启动",iOS10以上无效)
|
||||||
|
@property (nonatomic, copy) NSString *categoryIdentifier; // 行为分类标识
|
||||||
|
@property (nonatomic, copy) NSDictionary *userInfo; // 本地推送时可以设置userInfo来增加附加信息,远程推送时设置的payload推送内容作为此userInfo
|
||||||
|
@property (nonatomic, copy) NSString *sound; // 声音名称,不设置则为默认声音
|
||||||
|
@property (nonatomic, copy) NSArray *attachments NS_AVAILABLE_IOS(10_0); // 附件,iOS10以上有效,需要传入UNNotificationAttachment对象数组类型
|
||||||
|
@property (nonatomic, copy) NSString *threadIdentifier NS_AVAILABLE_IOS(10_0); // 线程或与推送请求相关对话的标识,iOS10以上有效,可用来对推送进行分组
|
||||||
|
@property (nonatomic, copy) NSString *launchImageName NS_AVAILABLE_IOS(10_0); // 启动图片名,iOS10以上有效,从推送启动时将会用到
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* 推送触发方式实体类
|
||||||
|
* 注:dateComponents、timeInterval、region在iOS10以上可选择其中一个参数传入有效值,如果同时传入值会根据优先级I、II、III使其中一种触发方式生效,fireDate为iOS10以下根据时间触发时须传入的参数
|
||||||
|
*/
|
||||||
|
@interface JPushNotificationTrigger : NSObject<NSCopying, NSCoding>
|
||||||
|
|
||||||
|
@property (nonatomic, assign) BOOL repeat; // 设置是否重复,默认为NO
|
||||||
|
@property (nonatomic, copy) NSDate *fireDate NS_DEPRECATED_IOS(2_0, 10_0); // 用来设置触发推送的时间,iOS10以上无效
|
||||||
|
@property (nonatomic, copy) CLRegion *region NS_AVAILABLE_IOS(8_0); // 用来设置触发推送的位置,iOS8以上有效,iOS10以上优先级为I,应用需要有允许使用定位的授权
|
||||||
|
@property (nonatomic, copy) NSDateComponents *dateComponents NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的日期时间,iOS10以上有效,优先级为II
|
||||||
|
@property (nonatomic, assign) NSTimeInterval timeInterval NS_AVAILABLE_IOS(10_0); // 用来设置触发推送的时间,iOS10以上有效,优先级为III
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* 注册或更新推送实体类
|
||||||
|
*/
|
||||||
|
@interface JPushNotificationRequest : NSObject<NSCopying, NSCoding>
|
||||||
|
|
||||||
|
@property (nonatomic, copy) NSString *requestIdentifier; // 推送请求标识
|
||||||
|
@property (nonatomic, copy) JPushNotificationContent *content; // 设置推送的具体内容
|
||||||
|
@property (nonatomic, copy) JPushNotificationTrigger *trigger; // 设置推送的触发方式
|
||||||
|
@property (nonatomic, copy) void (^completionHandler)(id result); // 注册或更新推送成功回调,iOS10以上成功则result为UNNotificationRequest对象,失败则result为nil;iOS10以下成功result为UILocalNotification对象,失败则result为nil
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* JPush 核心头文件
|
* JPush 核心头文件
|
||||||
@@ -51,6 +130,7 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
|||||||
* @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识.
|
* @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识.
|
||||||
* @param channel 发布渠道. 可选.
|
* @param channel 发布渠道. 可选.
|
||||||
* @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
|
* @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
|
||||||
|
* @param advertisingIdentifier 广告标识符(IDFA) 如果不需要使用IDFA,传nil.
|
||||||
*
|
*
|
||||||
* @discussion 提供SDK启动必须的参数, 来启动 SDK.
|
* @discussion 提供SDK启动必须的参数, 来启动 SDK.
|
||||||
* 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作.
|
* 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作.
|
||||||
@@ -61,6 +141,13 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
|||||||
apsForProduction:(BOOL)isProduction;
|
apsForProduction:(BOOL)isProduction;
|
||||||
|
|
||||||
|
|
||||||
|
+ (void)setupWithOption:(NSDictionary *)launchingOption
|
||||||
|
appKey:(NSString *)appKey
|
||||||
|
channel:(NSString *)channel
|
||||||
|
apsForProduction:(BOOL)isProduction
|
||||||
|
advertisingIdentifier:(NSString *)advertisingId;
|
||||||
|
|
||||||
|
|
||||||
///----------------------------------------------------
|
///----------------------------------------------------
|
||||||
/// @name APNs about 通知相关
|
/// @name APNs about 通知相关
|
||||||
///----------------------------------------------------
|
///----------------------------------------------------
|
||||||
@@ -69,15 +156,24 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
|||||||
* @abstract 注册要处理的远程通知类型
|
* @abstract 注册要处理的远程通知类型
|
||||||
*
|
*
|
||||||
* @param types 通知类型
|
* @param types 通知类型
|
||||||
* @param categories
|
* @param categories 类别组
|
||||||
*
|
*
|
||||||
* @discussion
|
|
||||||
*/
|
*/
|
||||||
+ (void)registerForRemoteNotificationTypes:(NSUInteger)types
|
+ (void)registerForRemoteNotificationTypes:(NSUInteger)types
|
||||||
categories:(NSSet *)categories;
|
categories:(NSSet *)categories;
|
||||||
|
/*!
|
||||||
|
* @abstract 新版本的注册方法(兼容iOS10)
|
||||||
|
*
|
||||||
|
* @param config 注册通知配置
|
||||||
|
* @param delegate 代理
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)registerForRemoteNotificationConfig:(JPUSHRegisterEntity *)config delegate:(id<JPUSHRegisterDelegate>)delegate;
|
||||||
|
|
||||||
|
|
||||||
+ (void)registerDeviceToken:(NSData *)deviceToken;
|
+ (void)registerDeviceToken:(NSData *)deviceToken;
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 处理收到的 APNs 消息
|
* @abstract 处理收到的 APNs 消息
|
||||||
*/
|
*/
|
||||||
@@ -90,14 +186,14 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
* 下面的接口是可选的
|
* 下面的接口是可选的
|
||||||
* 设置标签和(或)别名(若参数为nil,则忽略;若是空对象,则清空;详情请参考文档:http://docs.jpush.io/client/ios_api/#api-ios)
|
* 设置标签和(或)别名(若参数为nil,则忽略;若是空对象,则清空;详情请参考文档:http://docs.jiguang.cn/client/ios_api/#api-ios)
|
||||||
* setTags:alias:fetchCompletionHandle:是新的设置标签别名的方法,不再需要显示声明回调函数,只需要在block里面处理设置结果即可.
|
* setTags:alias:fetchCompletionHandle:是新的设置标签别名的方法,不再需要显示声明回调函数,只需要在block里面处理设置结果即可.
|
||||||
* WARN: 使用block时需要注意循环引用问题
|
* WARN: 使用block时需要注意循环引用问题
|
||||||
*/
|
*/
|
||||||
+ (void) setTags:(NSSet *)tags
|
+ (void) setTags:(NSSet *)tags
|
||||||
alias:(NSString *)alias
|
alias:(NSString *)alias
|
||||||
callbackSelector:(SEL)cbSelector
|
callbackSelector:(SEL)cbSelector
|
||||||
target:(id)theTarget;
|
target:(id)theTarget __attribute__((deprecated("JPush 2.1.1 版本已过期")));
|
||||||
|
|
||||||
+ (void) setTags:(NSSet *)tags
|
+ (void) setTags:(NSSet *)tags
|
||||||
alias:(NSString *)alias
|
alias:(NSString *)alias
|
||||||
@@ -108,9 +204,9 @@ callbackSelector:(SEL)cbSelector
|
|||||||
callbackSelector:(SEL)cbSelector
|
callbackSelector:(SEL)cbSelector
|
||||||
object:(id)theTarget;
|
object:(id)theTarget;
|
||||||
|
|
||||||
+ (void) setTags:(NSSet *)tags
|
+ (void)setTags:(NSSet *)tags
|
||||||
alias:(NSString *)alias
|
alias:(NSString *)alias
|
||||||
fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;
|
fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;
|
||||||
|
|
||||||
+ (void) setTags:(NSSet *)tags
|
+ (void) setTags:(NSSet *)tags
|
||||||
aliasInbackground:(NSString *)alias;
|
aliasInbackground:(NSString *)alias;
|
||||||
@@ -183,6 +279,35 @@ callbackSelector:(SEL)cbSelector
|
|||||||
///----------------------------------------------------
|
///----------------------------------------------------
|
||||||
/// @name Local Notification 本地通知
|
/// @name Local Notification 本地通知
|
||||||
///----------------------------------------------------
|
///----------------------------------------------------
|
||||||
|
/*!
|
||||||
|
* @abstract 注册或更新推送 (支持iOS10,并兼容iOS10以下版本)
|
||||||
|
*
|
||||||
|
* JPush 2.1.9新接口
|
||||||
|
* @param request JPushNotificationRequest类型,设置推送的属性,设置已有推送的request.requestIdentifier即更新已有的推送,否则为注册新推送,更新推送仅仅在iOS10以上有效,结果通过request.completionHandler返回
|
||||||
|
* @discussion 旧的注册本地推送接口被废弃,使用此接口可以替换
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)addNotification:(JPushNotificationRequest *)request;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @abstract 移除推送 (支持iOS10,并兼容iOS10以下版本)
|
||||||
|
*
|
||||||
|
* JPush 2.1.9新接口
|
||||||
|
* @param identifier JPushNotificationIdentifier类型,iOS10以上identifier设置为nil,则移除所有在通知中心显示推送和待推送请求,也可以通过设置identifier.delivered和identifier.identifiers来移除相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则移除相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier设置为nil,则移除所有推送,identifier.delivered属性无效,另外可以通过identifier.notificationObj传入特定推送对象来移除此推送。
|
||||||
|
* @discussion 旧的所有删除推送接口被废弃,使用此接口可以替换
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)removeNotification:(JPushNotificationIdentifier *)identifier;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @abstract 查找推送 (支持iOS10,并兼容iOS10以下版本)
|
||||||
|
*
|
||||||
|
* JPush 2.1.9新接口
|
||||||
|
* @param identifier JPushNotificationIdentifier类型,iOS10以上可以通过设置identifier.delivered和identifier.identifiers来查找相应在通知中心显示推送或待推送请求,identifier.identifiers如果设置为nil或空数组则返回相应标志下所有在通知中心显示推送或待推送请求;iOS10以下identifier.delivered属性无效,identifier.identifiers如果设置nil或空数组则返回所有推送。须要设置identifier.findCompletionHandler回调才能得到查找结果,通过(NSArray *results)返回相应对象数组。
|
||||||
|
* @discussion 旧的查找推送接口被废弃,使用此接口可以替换
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
+ (void)findNotification:(JPushNotificationIdentifier *)identifier;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 本地推送,最多支持64个
|
* @abstract 本地推送,最多支持64个
|
||||||
@@ -195,7 +320,7 @@ callbackSelector:(SEL)cbSelector
|
|||||||
* @param userInfo 自定义参数,可以用来标识推送和增加附加信息
|
* @param userInfo 自定义参数,可以用来标识推送和增加附加信息
|
||||||
* @param soundName 自定义通知声音,设置为nil为默认声音
|
* @param soundName 自定义通知声音,设置为nil为默认声音
|
||||||
*
|
*
|
||||||
* @discussion 最多支持 64 个定义
|
* @discussion 最多支持 64 个定义,此方法被[addNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
||||||
alertBody:(NSString *)alertBody
|
alertBody:(NSString *)alertBody
|
||||||
@@ -203,7 +328,7 @@ callbackSelector:(SEL)cbSelector
|
|||||||
alertAction:(NSString *)alertAction
|
alertAction:(NSString *)alertAction
|
||||||
identifierKey:(NSString *)notificationKey
|
identifierKey:(NSString *)notificationKey
|
||||||
userInfo:(NSDictionary *)userInfo
|
userInfo:(NSDictionary *)userInfo
|
||||||
soundName:(NSString *)soundName;
|
soundName:(NSString *)soundName __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 本地推送 (支持 iOS8 新参数)
|
* @abstract 本地推送 (支持 iOS8 新参数)
|
||||||
@@ -212,6 +337,7 @@ callbackSelector:(SEL)cbSelector
|
|||||||
* @param region 自定义参数
|
* @param region 自定义参数
|
||||||
* @param regionTriggersOnce 自定义参数
|
* @param regionTriggersOnce 自定义参数
|
||||||
* @param category 自定义参数
|
* @param category 自定义参数
|
||||||
|
* @discussion 此方法被[addNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
+ (UILocalNotification *)setLocalNotification:(NSDate *)fireDate
|
||||||
alertBody:(NSString *)alertBody
|
alertBody:(NSString *)alertBody
|
||||||
@@ -222,7 +348,7 @@ callbackSelector:(SEL)cbSelector
|
|||||||
soundName:(NSString *)soundName
|
soundName:(NSString *)soundName
|
||||||
region:(CLRegion *)region
|
region:(CLRegion *)region
|
||||||
regionTriggersOnce:(BOOL)regionTriggersOnce
|
regionTriggersOnce:(BOOL)regionTriggersOnce
|
||||||
category:(NSString *)category NS_AVAILABLE_IOS(8_0);
|
category:(NSString *)category NS_AVAILABLE_IOS(8_0) __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 前台展示本地推送
|
* @abstract 前台展示本地推送
|
||||||
@@ -230,35 +356,39 @@ callbackSelector:(SEL)cbSelector
|
|||||||
* @param notification 本地推送对象
|
* @param notification 本地推送对象
|
||||||
* @param notificationKey 需要前台显示的本地推送通知的标示符
|
* @param notificationKey 需要前台显示的本地推送通知的标示符
|
||||||
*
|
*
|
||||||
* @discussion 默认App在前台运行时不会进行弹窗,在程序接收通知调用此接口可实现指定的推送弹窗。
|
* @discussion 默认App在前台运行时不会进行弹窗,在程序接收通知调用此接口可实现指定的推送弹窗。--iOS10以下还可继续使用,iOS10以上在[UNUserNotificationCenterDelegate willPresentNotification:withCompletionHandler:]方法中调用completionHandler(UNNotificationPresentationOptionSound | UNNotificationPresentationOptionAlert);即可
|
||||||
*/
|
*/
|
||||||
+ (void)showLocalNotificationAtFront:(UILocalNotification *)notification
|
+ (void)showLocalNotificationAtFront:(UILocalNotification *)notification
|
||||||
identifierKey:(NSString *)notificationKey;
|
identifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
/*!
|
/*!
|
||||||
* @abstract 删除本地推送定义
|
* @abstract 删除本地推送定义
|
||||||
*
|
*
|
||||||
* @param notificationKey 本地推送标示符
|
* @param notificationKey 本地推送标示符
|
||||||
* @param myUILocalNotification 本地推送对象
|
* @param myUILocalNotification 本地推送对象
|
||||||
|
* @discussion 此方法被[removeNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey;
|
+ (void)deleteLocalNotificationWithIdentifierKey:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 删除本地推送定义
|
* @abstract 删除本地推送定义
|
||||||
|
* @discussion 此方法被[removeNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (void)deleteLocalNotification:(UILocalNotification *)localNotification;
|
+ (void)deleteLocalNotification:(UILocalNotification *)localNotification __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 获取指定通知
|
* @abstract 获取指定通知
|
||||||
*
|
*
|
||||||
* @param notificationKey 本地推送标示符
|
* @param notificationKey 本地推送标示符
|
||||||
* @return 本地推送对象数组, [array count]为0时表示没找到
|
* @return 本地推送对象数组, [array count]为0时表示没找到
|
||||||
|
* @discussion 此方法被[findNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey;
|
+ (NSArray *)findLocalNotificationWithIdentifier:(NSString *)notificationKey __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 清除所有本地推送对象
|
* @abstract 清除所有本地推送对象
|
||||||
|
* @discussion 此方法被[removeNotification:]方法取代
|
||||||
*/
|
*/
|
||||||
+ (void)clearAllLocalNotifications;
|
+ (void)clearAllLocalNotifications __attribute__((deprecated("JPush 2.1.9 版本已过期")));
|
||||||
|
|
||||||
|
|
||||||
///----------------------------------------------------
|
///----------------------------------------------------
|
||||||
@@ -304,11 +434,13 @@ callbackSelector:(SEL)cbSelector
|
|||||||
*
|
*
|
||||||
* JPush 支持根据 registrationID 来进行推送.
|
* JPush 支持根据 registrationID 来进行推送.
|
||||||
* 如果你需要此功能, 应该通过此接口获取到 registrationID 后, 上报到你自己的服务器端, 并保存下来.
|
* 如果你需要此功能, 应该通过此接口获取到 registrationID 后, 上报到你自己的服务器端, 并保存下来.
|
||||||
*
|
* registrationIDCompletionHandler:是新增的获取registrationID的方法,需要在block中获取registrationID,resCode为返回码,模拟器调用此接口resCode返回1011,registrationID返回nil.
|
||||||
* 更多的理解请参考 JPush 的文档网站.
|
* 更多的理解请参考 JPush 的文档网站.
|
||||||
*/
|
*/
|
||||||
+ (NSString *)registrationID;
|
+ (NSString *)registrationID;
|
||||||
|
|
||||||
|
+ (void)registrationIDCompletionHandler:(void(^)(int resCode,NSString *registrationID))completionHandler;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @abstract 打开日志级别到 Debug
|
* @abstract 打开日志级别到 Debug
|
||||||
*
|
*
|
||||||
@@ -333,5 +465,26 @@ callbackSelector:(SEL)cbSelector
|
|||||||
*/
|
*/
|
||||||
+ (void)setLogOFF;
|
+ (void)setLogOFF;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@class UNUserNotificationCenter;
|
||||||
|
@class UNNotificationResponse;
|
||||||
|
|
||||||
|
@protocol JPUSHRegisterDelegate <NSObject>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief handle UserNotifications.framework [willPresentNotification:withCompletionHandler:]
|
||||||
|
* @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心
|
||||||
|
* @param notification 前台得到的的通知对象
|
||||||
|
* @param completionHandler 该callback中的options 请使用UNNotificationPresentationOptions
|
||||||
|
*/
|
||||||
|
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger options))completionHandler;
|
||||||
|
/*
|
||||||
|
* @brief handle UserNotifications.framework [didReceiveNotificationResponse:withCompletionHandler:]
|
||||||
|
* @param center [UNUserNotificationCenter currentNotificationCenter] 新特性用户通知中心
|
||||||
|
* @param response 通知响应对象
|
||||||
|
* @param completionHandler
|
||||||
|
*/
|
||||||
|
- (void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void(^)())completionHandler;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Binary file not shown.
+275
-266
@@ -1,363 +1,372 @@
|
|||||||
|
var JPushPlugin = function () {}
|
||||||
|
|
||||||
|
// private plugin function
|
||||||
var JPushPlugin = function(){
|
|
||||||
};
|
|
||||||
|
|
||||||
//private plugin function
|
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveMessage = {}
|
JPushPlugin.prototype.receiveMessage = {}
|
||||||
JPushPlugin.prototype.openNotification = {}
|
JPushPlugin.prototype.openNotification = {}
|
||||||
JPushPlugin.prototype.receiveNotification = {}
|
JPushPlugin.prototype.receiveNotification = {}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.isPlatformIOS = function () {
|
||||||
JPushPlugin.prototype.isPlatformIOS = function() {
|
var isPlatformIOS = device.platform == 'iPhone'
|
||||||
var isPlatformIOS = device.platform == "iPhone"
|
|| device.platform == 'iPad'
|
||||||
|| device.platform == "iPad"
|
|| device.platform == 'iPod touch'
|
||||||
|| device.platform == "iPod touch"
|
|| device.platform == 'iOS'
|
||||||
|| device.platform == "iOS";
|
return isPlatformIOS
|
||||||
return isPlatformIOS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.error_callback = function(msg) {
|
JPushPlugin.prototype.error_callback = function (msg) {
|
||||||
console.log("Javascript Callback Error: " + msg);
|
console.log('Javascript Callback Error: ' + msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.call_native = function(name, args, callback) {
|
JPushPlugin.prototype.call_native = function (name, args, callback) {
|
||||||
ret = cordova.exec(callback, this.error_callback, 'JPushPlugin', name, args);
|
ret = cordova.exec(callback, this.error_callback, 'JPushPlugin', name, args)
|
||||||
return ret;
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
// public methods
|
// public methods
|
||||||
JPushPlugin.prototype.init = function() {
|
JPushPlugin.prototype.init = function () {
|
||||||
if(this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [];
|
var data = []
|
||||||
this.call_native("initial", data, null);
|
this.call_native('initial', data, null)
|
||||||
} else {
|
} else {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("init", data, null);
|
this.call_native('init', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.getRegistrationID = function(callback) {
|
JPushPlugin.prototype.getRegistrationID = function (callback) {
|
||||||
try {
|
try {
|
||||||
var data = [];
|
var data = []
|
||||||
this.call_native("getRegistrationID", [data], callback);
|
this.call_native('getRegistrationID', [data], callback)
|
||||||
} catch(exception) {
|
} catch(exception) {
|
||||||
console.log(exception);
|
console.log(exception)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.stopPush = function() {
|
JPushPlugin.prototype.stopPush = function () {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("stopPush", data, null);
|
this.call_native('stopPush', data, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.resumePush = function() {
|
JPushPlugin.prototype.resumePush = function () {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("resumePush", data, null);
|
this.call_native('resumePush', data, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.isPushStopped = function(callback) {
|
JPushPlugin.prototype.isPushStopped = function (callback) {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("isPushStopped", data, callback);
|
this.call_native('isPushStopped', data, callback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// iOS methods
|
// iOS methods
|
||||||
JPushPlugin.prototype.setTagsWithAlias = function(tags, alias) {
|
JPushPlugin.prototype.setTagsWithAlias = function (tags, alias) {
|
||||||
try {
|
try {
|
||||||
if(tags == null) {
|
if (tags == null) {
|
||||||
this.setAlias(alias);
|
this.setAlias(alias)
|
||||||
return;
|
return
|
||||||
}
|
|
||||||
if(alias == null) {
|
|
||||||
this.setTags(tags);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var arrayTagWithAlias = [tags];
|
|
||||||
arrayTagWithAlias.unshift(alias);
|
|
||||||
this.call_native("setTagsWithAlias", arrayTagWithAlias, null);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setTags = function(tags) {
|
|
||||||
try {
|
|
||||||
this.call_native("setTags", tags, null);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setAlias = function(alias) {
|
|
||||||
try {
|
|
||||||
this.call_native("setAlias", [alias], null);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setBadge = function(value) {
|
|
||||||
if(this.isPlatformIOS()) {
|
|
||||||
try {
|
|
||||||
this.call_native("setBadge", [value], null);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.resetBadge = function() {
|
|
||||||
if(this.isPlatformIOS()) {
|
|
||||||
try {
|
|
||||||
var data = [];
|
|
||||||
this.call_native("resetBadge", [data], null);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setDebugModeFromIos = function() {
|
|
||||||
if(this.isPlatformIOS()) {
|
|
||||||
var data = [];
|
|
||||||
this.call_native("setDebugModeFromIos", [data], null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setLogOFF = function() {
|
|
||||||
if(this.isPlatformIOS()) {
|
|
||||||
var data = [];
|
|
||||||
this.call_native("setLogOFF", [data], null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
JPushPlugin.prototype.setCrashLogON = function() {
|
|
||||||
if (this.isPlatformIOS()) {
|
|
||||||
var data = [];
|
|
||||||
this.call_native("crashLogON", [data], null);
|
|
||||||
}
|
}
|
||||||
}
|
if (alias == null) {
|
||||||
|
this.setTags(tags)
|
||||||
JPushPlugin.prototype.addLocalNotificationForIOS = function(delayTime, content,
|
return
|
||||||
badge, notificationID, extras) {
|
|
||||||
if (this.isPlatformIOS()) {
|
|
||||||
var data = [delayTime, content, badge, notificationID, extras];
|
|
||||||
this.call_native("setLocalNotification", data, null);
|
|
||||||
}
|
}
|
||||||
|
var arrayTagWithAlias = [tags]
|
||||||
|
arrayTagWithAlias.unshift(alias)
|
||||||
|
this.call_native('setTagsWithAlias', arrayTagWithAlias, null)
|
||||||
|
} catch(exception) {
|
||||||
|
console.log(exception)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function(
|
JPushPlugin.prototype.setTags = function (tags) {
|
||||||
identifierKey) {
|
try {
|
||||||
if (this.isPlatformIOS()) {
|
this.call_native('setTags', tags, null)
|
||||||
var data = [identifierKey];
|
} catch(exception) {
|
||||||
this.call_native("deleteLocalNotificationWithIdentifierKey", data, null);
|
console.log(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.setAlias = function (alias) {
|
||||||
|
try {
|
||||||
|
this.call_native('setAlias', [alias], null)
|
||||||
|
} catch(exception) {
|
||||||
|
console.log(exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.setBadge = function (value) {
|
||||||
|
if (this.isPlatformIOS()) {
|
||||||
|
try {
|
||||||
|
this.call_native('setBadge', [value], null)
|
||||||
|
} catch(exception) {
|
||||||
|
console.log(exception)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearAllLocalNotifications = function(){
|
JPushPlugin.prototype.resetBadge = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [];
|
try {
|
||||||
this.call_native("clearAllLocalNotifications", data, null);
|
var data = []
|
||||||
|
this.call_native('resetBadge', [data], null)
|
||||||
|
} catch(exception) {
|
||||||
|
console.log(exception)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setLocation = function(latitude, longitude){
|
JPushPlugin.prototype.setDebugModeFromIos = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [latitude, longitude];
|
var data = []
|
||||||
this.call_native("setLocation", data, null);
|
this.call_native('setDebugModeFromIos', [data], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveMessageIniOSCallback = function(data) {
|
JPushPlugin.prototype.setLogOFF = function () {
|
||||||
try {
|
if (this.isPlatformIOS()) {
|
||||||
console.log("JPushPlugin:receiveMessageIniOSCallback--data:" + data);
|
var data = []
|
||||||
var bToObj = JSON.parse(data);
|
this.call_native('setLogOFF', [data], null)
|
||||||
var content = bToObj.content;
|
}
|
||||||
console.log(content);
|
|
||||||
} catch(exception) {
|
|
||||||
console.log("JPushPlugin:receiveMessageIniOSCallback" + exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.startLogPageView = function(pageName) {
|
JPushPlugin.prototype.setCrashLogON = function () {
|
||||||
if(this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
this.call_native("startLogPageView", [pageName], null);
|
var data = []
|
||||||
}
|
this.call_native('crashLogON', [data], null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.stopLogPageView = function(pageName) {
|
JPushPlugin.prototype.addLocalNotificationForIOS = function (delayTime, content,
|
||||||
if(this.isPlatformIOS()) {
|
badge, notificationID, extras) {
|
||||||
this.call_native("stopLogPageView", [pageName], null);
|
if (this.isPlatformIOS()) {
|
||||||
}
|
var data = [delayTime, content, badge, notificationID, extras]
|
||||||
|
this.call_native('setLocalNotification', data, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.beginLogPageView = function(pageName, duration) {
|
JPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (
|
||||||
if(this.isPlatformIOS()) {
|
identifierKey) {
|
||||||
this.call_native("beginLogPageView", [pageName, duration], null);
|
if (this.isPlatformIOS()) {
|
||||||
}
|
var data = [identifierKey]
|
||||||
|
this.call_native('deleteLocalNotificationWithIdentifierKey', data, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setApplicationIconBadgeNumber = function(badge) {
|
JPushPlugin.prototype.clearAllLocalNotifications = function () {
|
||||||
if(this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
this.call_native("setApplicationIconBadgeNumber", [badge], null);
|
var data = []
|
||||||
}
|
this.call_native('clearAllLocalNotifications', data, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback) {
|
JPushPlugin.prototype.setLocation = function (latitude, longitude) {
|
||||||
if(this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
this.call_native("getApplicationIconBadgeNumber", [], callback);
|
var data = [latitude, longitude]
|
||||||
}
|
this.call_native('setLocation', data, null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushPlugin.prototype.receiveMessageIniOSCallback = function (data) {
|
||||||
|
try {
|
||||||
|
console.log('JPushPlugin:receiveMessageIniOSCallback--data:' + data)
|
||||||
|
var bToObj = JSON.parse(data)
|
||||||
|
var content = bToObj.content
|
||||||
|
console.log(content)
|
||||||
|
} catch(exception) {
|
||||||
|
console.log('JPushPlugin:receiveMessageIniOSCallback' + exception)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断系统设置中是否对本应用启用通知。
|
||||||
|
// iOS: 返回值如果大于 0,代表通知开启;0: 通知关闭。
|
||||||
|
// UIRemoteNotificationTypeNone = 0,
|
||||||
|
// UIRemoteNotificationTypeBadge = 1 << 0,
|
||||||
|
// UIRemoteNotificationTypeSound = 1 << 1,
|
||||||
|
// UIRemoteNotificationTypeAlert = 1 << 2,
|
||||||
|
// UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
|
||||||
|
// Android: 返回值 1 代表通知启用、0: 通知关闭。
|
||||||
|
JPushPlugin.prototype.getUserNotificationSettings = function (callback) {
|
||||||
|
if (this.isPlatformIOS()) {
|
||||||
|
this.call_native('getUserNotificationSettings', [], callback)
|
||||||
|
} else if (device.platform == 'Android') {
|
||||||
|
this.call_native('areNotificationEnabled', [], callback)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Android methods
|
// Android methods
|
||||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
JPushPlugin.prototype.setDebugMode = function (mode) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setDebugMode", [mode], null);
|
this.call_native('setDebugMode', [mode], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setBasicPushNotificationBuilder = function() {
|
JPushPlugin.prototype.setBasicPushNotificationBuilder = function () {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("setBasicPushNotificationBuilder", data, null);
|
this.call_native('setBasicPushNotificationBuilder', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setCustomPushNotificationBuilder = function() {
|
JPushPlugin.prototype.setCustomPushNotificationBuilder = function () {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("setCustomPushNotificationBuilder", data, null);
|
this.call_native('setCustomPushNotificationBuilder', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveMessageInAndroidCallback = function(data) {
|
JPushPlugin.prototype.receiveMessageInAndroidCallback = function (data) {
|
||||||
try {
|
try {
|
||||||
console.log("JPushPlugin:receiveMessageInAndroidCallback");
|
data = JSON.stringify(data)
|
||||||
data = JSON.stringify(data);
|
console.log('JPushPlugin:receiveMessageInAndroidCallback: ' + data)
|
||||||
var bToObj = JSON.parse(data);
|
this.receiveMessage = JSON.parse(data)
|
||||||
this.receiveMessage = bToObj
|
cordova.fireDocumentEvent('jpush.receiveMessage', this.receiveMessage)
|
||||||
cordova.fireDocumentEvent('jpush.receiveMessage', null);
|
} catch(exception) {
|
||||||
} catch(exception) {
|
console.log('JPushPlugin:pushCallback ' + exception)
|
||||||
console.log("JPushPlugin:pushCallback " + exception);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.openNotificationInAndroidCallback = function(data) {
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function (data) {
|
||||||
try {
|
try {
|
||||||
console.log("JPushPlugin:openNotificationInAndroidCallback");
|
data = JSON.stringify(data)
|
||||||
data = JSON.stringify(data);
|
console.log('JPushPlugin:openNotificationInAndroidCallback: ' + data)
|
||||||
var bToObj = JSON.parse(data);
|
this.openNotification = JSON.parse(data)
|
||||||
this.openNotification = bToObj;
|
cordova.fireDocumentEvent('jpush.openNotification', this.openNotification)
|
||||||
cordova.fireDocumentEvent('jpush.openNotification', null);
|
} catch(exception) {
|
||||||
} catch(exception) {
|
console.log(exception)
|
||||||
console.log(exception);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function(data) {
|
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function (data) {
|
||||||
try{
|
try {
|
||||||
console.log("JPushPlugin:receiveNotificationInAndroidCallback");
|
data = JSON.stringify(data)
|
||||||
data = JSON.stringify(data);
|
console.log('JPushPlugin:receiveNotificationInAndroidCallback: ' + data)
|
||||||
var bToObj = JSON.parse(data);
|
this.receiveNotification = JSON.parse(data)
|
||||||
this.receiveNotification = bToObj;
|
cordova.fireDocumentEvent('jpush.receiveNotification', this.receiveNotification)
|
||||||
cordova.fireDocumentEvent('jpush.receiveNotification', null);
|
} catch(exception) {
|
||||||
} catch(exception) {
|
console.log(exception)
|
||||||
console.log(exception);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearAllNotification = function() {
|
JPushPlugin.prototype.clearAllNotification = function () {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("clearAllNotification", data, null);
|
this.call_native('clearAllNotification', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearNotificationById = function(notificationId) {
|
JPushPlugin.prototype.clearNotificationById = function (notificationId) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("clearNotificationById", [notificationId], null);
|
this.call_native('clearNotificationById', [notificationId], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setLatestNotificationNum = function(num) {
|
JPushPlugin.prototype.setLatestNotificationNum = function (num) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setLatestNotificationNum", [num], null);
|
this.call_native('setLatestNotificationNum', [num], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
JPushPlugin.prototype.setDebugMode = function (mode) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setDebugMode", [mode], null);
|
this.call_native('setDebugMode', [mode], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.addLocalNotification = function(builderId, content, title,
|
JPushPlugin.prototype.addLocalNotification = function (builderId, content, title,
|
||||||
notificationID, broadcastTime, extras) {
|
notificationID, broadcastTime, extras) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [builderId, content, title, notificationID, broadcastTime, extras];
|
data = [builderId, content, title, notificationID, broadcastTime, extras]
|
||||||
this.call_native("addLocalNotification", data, null);
|
this.call_native('addLocalNotification', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.removeLocalNotification = function(notificationID) {
|
JPushPlugin.prototype.removeLocalNotification = function (notificationID) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("removeLocalNotification", [notificationID], null);
|
this.call_native('removeLocalNotification', [notificationID], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearLocalNotifications = function() {
|
JPushPlugin.prototype.clearLocalNotifications = function () {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
data = [];
|
data = []
|
||||||
this.call_native("clearLocalNotifications", data, null);
|
this.call_native('clearLocalNotifications', data, null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.reportNotificationOpened = function(msgID) {
|
JPushPlugin.prototype.reportNotificationOpened = function (msgID) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("reportNotificationOpened", [msgID], null);
|
this.call_native('reportNotificationOpened', [msgID], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*是否开启统计分析功能,用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器上,
|
*是否开启统计分析功能,用于“用户使用时长”,“活跃用户”,“用户打开次数”的统计,并上报到服务器上,
|
||||||
*在 Portal 上展示给开发者。
|
*在 Portal 上展示给开发者。
|
||||||
*/
|
*/
|
||||||
JPushPlugin.prototype.setStatisticsOpen = function(mode) {
|
JPushPlugin.prototype.setStatisticsOpen = function (mode) {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setStatisticsOpen", [mode], null);
|
this.call_native('setStatisticsOpen', [mode], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于在 Android 6.0 及以上系统,申请一些权限
|
* 用于在 Android 6.0 及以上系统,申请一些权限
|
||||||
* 具体可看:http://docs.jpush.io/client/android_api/#android-60
|
* 具体可看:http://docs.jpush.io/client/android_api/#android-60
|
||||||
*/
|
*/
|
||||||
JPushPlugin.prototype.requestPermission = function() {
|
JPushPlugin.prototype.requestPermission = function () {
|
||||||
if(device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("requestPermission", [], null);
|
this.call_native('requestPermission', [], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setSilenceTime = function(startHour, startMinute, endHour, endMinute) {
|
JPushPlugin.prototype.setSilenceTime = function (startHour, startMinute, endHour, endMinute) {
|
||||||
if (device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setSilenceTime", [startHour, startMinute, endHour, endMinute], null);
|
this.call_native('setSilenceTime', [startHour, startMinute, endHour, endMinute], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setPushTime = function(weekdays, startHour, endHour) {
|
JPushPlugin.prototype.setPushTime = function (weekdays, startHour, endHour) {
|
||||||
if (device.platform == "Android") {
|
if (device.platform == 'Android') {
|
||||||
this.call_native("setPushTime", [weekdays, startHour, endHour], null);
|
this.call_native('setPushTime', [weekdays, startHour, endHour], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!window.plugins) {
|
if (!window.plugins) {
|
||||||
window.plugins = {};
|
window.plugins = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!window.plugins.jPushPlugin) {
|
if (!window.plugins.jPushPlugin) {
|
||||||
window.plugins.jPushPlugin = new JPushPlugin();
|
window.plugins.jPushPlugin = new JPushPlugin()
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = new JPushPlugin();
|
module.exports = new JPushPlugin()
|
||||||
|
|||||||
Reference in New Issue
Block a user