mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-02-08 00:05:13 +08:00
Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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>
|
||||
124
README.md
124
README.md
@@ -1,79 +1,41 @@
|
||||
# JPush PhoneGap / Cordova 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-plugin)
|
||||
[]()
|
||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||
|
||||
支持 iOS, Android 的 Cordova 推送插件。
|
||||
> 如需要 IM 功能的插件,可关注 [JMessage PhoneGap Plugin](https://github.com/jpush/jmessage-phonegap-plugin)。
|
||||
|
||||
## 功能特性
|
||||
+ 发送推送通知。
|
||||
+ 发送推送自定义消息。
|
||||
+ 设置推送标签和别名。
|
||||
+ 设置角标(iOS)。
|
||||
> QQ 交流群:413602425
|
||||
|
||||
*如需要 IM 功能插件,请关注 [jmessage-phonegap-plugin](https://github.com/jpush/jmessage-phonegap-plugin)*。
|
||||
## 集成步骤
|
||||
集成 JPush PhoneGap Plugin 有两种方法:
|
||||
|
||||
## 安装
|
||||
### 准备工作
|
||||
### 在线安装
|
||||
- 通过 Cordova Plugins 安装,要求 PhoneGap/Cordova CLI 5.0+:
|
||||
|
||||
1. cordova create 文件夹名字 包名 应用名字
|
||||
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
|
||||
|
||||
cordova create Myproj com.myproj.jpush MyTestProj
|
||||
- 直接通过 url 安装:
|
||||
|
||||
2. 添加平台:
|
||||
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
|
||||
|
||||
cd Myproj
|
||||
cordova platform add android
|
||||
cordova platform add ios
|
||||
|
||||
ps: 这里请注意iOS平台,必须先执行 cordova platform add ios,
|
||||
然后再执行 cordova plugin add xxxxx 命令,不然有一些必须要的链接库需要手动添加。
|
||||
|
||||
|
||||
### 安装插件(Android & iOS)
|
||||
|
||||
#### 1.安装 JPush PhoneGap Plugin
|
||||
安装 JPush PhoneGap Plugin 有两种方法:
|
||||
|
||||
方法一:在线安装
|
||||
|
||||
通过 cordova plugins 安装,要求 phonegap/cordova CLI 5.0+:
|
||||
|
||||
cordova plugin add jpush-phonegap-plugin --variable API_KEY=your_jpush_appkey
|
||||
|
||||
直接通过 url 安装:
|
||||
|
||||
cordova plugin add https://github.com/jpush/jpush-phonegap-plugin.git --variable API_KEY=your_jpush_appkey
|
||||
|
||||
方法二:下载到本地再安装
|
||||
|
||||
使用 git 命令将 JPush PhoneGap 插件下载的本地,目录标记为 $JPUSH_PLUGIN_DIR。
|
||||
### 本地安装
|
||||
使用 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 插件
|
||||
|
||||
cordova plugin add org.apache.cordova.device
|
||||
|
||||
|
||||
#### 3.在 js 中调用函数,初始化 JPush
|
||||
|
||||
//由于 PhoneGap 插件采用了 Lazy load 的特性,所以建议在 js 文件能执行的最开始就添加
|
||||
window.plugins.jPushPlugin.init();
|
||||
|
||||
- [Android 手动安装文档地址](/doc/Android_handle_install.md)。
|
||||
|
||||
- [iOS 手动安装文档地址](/doc/iOS_install.md)。
|
||||
|
||||
## Demo
|
||||
插件中包含示例 Demo。若想参考,可以在 $JPUSH_PLUGIN_DIR/example 文件夹内找到并拷贝以下文件:
|
||||
插件项目中包含一个简单的 Demo。若想参考,可以在 /example 文件夹内找到并拷贝以下文件:
|
||||
|
||||
src/example/index.html -> www/index.html
|
||||
src/example/css/* -> www/css
|
||||
@@ -81,58 +43,52 @@
|
||||
|
||||
## 关于 PhoneGap build 云服务
|
||||
|
||||
该项目基于 cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
|
||||
该项目基于 Cordova 实现,目前无法使用 PhoneGap build 云服务进行打包,建议使用本地环境进行打包。
|
||||
|
||||
## API 说明
|
||||
|
||||
插件的 API 集中在 JPushPlugin.js 文件中,该文件的具体位置如下:
|
||||
|
||||
Android:
|
||||
|
||||
插件的 API 在 JPushPlugin.js 文件中,该文件的具体位置如下:
|
||||
### Android
|
||||
[Project]/assets/www/plugins/cn.jpush.phonegap.JPushPlugin/www
|
||||
|
||||
iOS:
|
||||
|
||||
### 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)
|
||||
- [公共 API](/doc/Common_detail_api.md)。
|
||||
|
||||
- [iOS API](https://github.com/jpush/jpush-phonegap-plugin/blob/dev/API/iOS%20API.md)
|
||||
- [iOS API](/doc/iOS_API.md)。
|
||||
|
||||
- [Android API](https://github.com/jpush/jpush-phonegap-plugin/blob/dev/API/Android_detail_api.md)
|
||||
- [Android API](/doc/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)。
|
||||
若要使用 CLI 来编译项目,注意应使用 cordova compile 而不是 cordova build 命令,因为如果修改了插件安装时默认写入到 AndroidManifest.xml
|
||||
中的代码,cordova build 可能会导致对 AndroidManifest.xml 的修改。
|
||||
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 中 import PhoneGap 工程之后出现:*Type CallbackContext cannot be resolved to a type*。
|
||||
|
||||
解决方案:eclipse 中右键单击工程名,Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
|
||||
解决方案:Eclipse 中右键单击工程名,Build Path -> Config Build Path -> Projects -> 选中工程名称 -> CordovaLib -> 点击 add。
|
||||
|
||||
### 2. iOS
|
||||
|
||||
- 设置 / 修改 APP_KEY:
|
||||
- 收不到推送:
|
||||
请首先按照正确方式再次配置证书、描述文件,具体可参考 [iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
||||
|
||||
在 PushConfig.plist 中修改。
|
||||
PushConfig.plist 中其他值说明:
|
||||
- 设置 PushConfig.plist:
|
||||
- APP_KEY:应用标识。
|
||||
- CHANNEL:渠道标识。
|
||||
- IsProduction:是否生产环境。
|
||||
- IsIDFA:是否使用 IDFA 启动 SDK。
|
||||
|
||||
- CHANNEL: 渠道标识。
|
||||
- IsProduction: 是否生产环境(暂未启用)。
|
||||
|
||||
|
||||
- 收不到推送:
|
||||
|
||||
请首先按照正确方式再次配置证书、描述文件
|
||||
[iOS 证书设置指南](http://docs.jpush.io/client/ios_tutorials/#ios_1)。
|
||||
|
||||
|
||||
## 更多
|
||||
[JPush 官网文档](http://docs.jpush.io/)
|
||||
|
||||
如有问题可访问[极光社区](http://community.jpush.cn/)
|
||||
- QQ 群:413602425。
|
||||
- [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。
|
||||
- broadcastTime: 设置本地通知触发时间,为距离当前时间的数值,单位是毫秒。
|
||||
- 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
|
||||
@@ -370,3 +370,28 @@ ps:点击通知后传递的 json object 保存在 window.plugins.jPushPlugin.r
|
||||
"content":"今天去哪儿",
|
||||
"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
|
||||
|
||||
iOS平台,检查推送服务是否注册。
|
||||
iOS平台,检查推送服务是否停止。
|
||||
|
||||
#### 接口定义
|
||||
|
||||
@@ -69,12 +69,12 @@ iOS平台,检查推送服务是否注册。
|
||||
- callback 回调函数,用来通知 JPush 的推送服务是否开启。
|
||||
|
||||
#### 代码示例
|
||||
window.plugins.jPushPlugin.resumePush(callback)
|
||||
var onCallback = function(data) {
|
||||
window.plugins.jPushPlugin.isPushStopped(callback)
|
||||
var callback = function(data) {
|
||||
if(data > 0) {
|
||||
// 开启
|
||||
// 已关闭
|
||||
} else {
|
||||
// 关闭
|
||||
// 已开启
|
||||
}
|
||||
}
|
||||
|
||||
35
doc/iOS_install.md
Normal file
35
doc/iOS_install.md
Normal file
@@ -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>
|
||||
BIN
example/.DS_Store
vendored
BIN
example/.DS_Store
vendored
Binary file not shown.
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "jpush-phonegap-plugin",
|
||||
"version": "2.1.6",
|
||||
"version": "2.2.2",
|
||||
"description": "JPush for cordova plugin",
|
||||
"cordova": {
|
||||
"id": "cn.jpush.phonegap.JPushPlugin",
|
||||
"id": "cordova-plugin-JPush",
|
||||
"platforms": [
|
||||
"ios",
|
||||
"android"
|
||||
@@ -16,6 +16,7 @@
|
||||
"keywords": [
|
||||
"JPush",
|
||||
"push",
|
||||
"Push",
|
||||
"ecosystem:cordova",
|
||||
"cordova-ios",
|
||||
"cordova-android"
|
||||
@@ -26,6 +27,9 @@
|
||||
"version": ">=3.0"
|
||||
}
|
||||
],
|
||||
"peerDependencies": {
|
||||
"cordova-plugin-device": ">=1.0.0"
|
||||
},
|
||||
"author": "jpush",
|
||||
"license": "Apache 2.0 License",
|
||||
"bugs": {
|
||||
|
||||
67
plugin.xml
67
plugin.xml
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cn.jpush.phonegap.JPushPlugin"
|
||||
version="2.1.6">
|
||||
id="cordova-plugin-JPush"
|
||||
version="2.2.2">
|
||||
|
||||
<name>JPush Plugin</name>
|
||||
<description>JPush for cordova plugin</description>
|
||||
@@ -16,8 +16,10 @@
|
||||
<engine name="cordova" version=">=3.0"/>
|
||||
</engines>
|
||||
|
||||
<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device.git"/>
|
||||
|
||||
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
||||
<clobbers target="jPushPlugin"/>
|
||||
<clobbers target="JPush"/>
|
||||
</js-module>
|
||||
|
||||
<platform name="ios">
|
||||
@@ -31,7 +33,7 @@
|
||||
<source-file src="src/ios/Plugins/JPushPlugin.m"/>
|
||||
|
||||
<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.8.a" framework="true" />
|
||||
<header-file src="src/ios/Plugins/AppDelegate+JPush.h"/>
|
||||
<source-file src="src/ios/Plugins/AppDelegate+JPush.m"/>
|
||||
<resource-file src="src/ios/PushConfig.plist" />
|
||||
@@ -43,26 +45,23 @@
|
||||
<framework src="Foundation.framework" weak="true" />
|
||||
<framework src="UIKit.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" />
|
||||
|
||||
<config-file target="*PushConfig.plist" parent="APP_KEY">
|
||||
<string>$API_KEY</string>
|
||||
</config-file>
|
||||
</platform>
|
||||
|
||||
<!-- 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="/*">
|
||||
<feature name="JPushPlugin">
|
||||
<param name="android-package" value="cn.jpush.phonegap.JPushPlugin"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<framework src="com.android.support:support-v4:24.0.0" />
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="/manifest">
|
||||
<!-- Required 一些系统要求的权限,如访问网络等-->
|
||||
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"/>
|
||||
@@ -94,6 +93,13 @@
|
||||
</intent-filter>
|
||||
</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核心功能-->
|
||||
<service
|
||||
android:name="cn.jpush.android.service.DownloadService"
|
||||
@@ -131,10 +137,21 @@
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.PACKAGE_ADDED"/>
|
||||
<action android:name="android.intent.action.PACKAGE_REMOVED"/>
|
||||
<data android:scheme="package"/>
|
||||
</intent-filter>
|
||||
</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 用户自定义的广播接收器 -->
|
||||
<receiver
|
||||
android:name="cn.jpush.phonegap.MyReceiver"
|
||||
@@ -161,20 +178,30 @@
|
||||
</receiver>
|
||||
<!-- Required SDK核心功能-->
|
||||
<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_APPKEY" android:value="$API_KEY"/>
|
||||
</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.7.jar" target-dir="libs"/>
|
||||
<source-file src="src/android/armeabi/libjpush217.so" target-dir="libs/armeabi"/>
|
||||
<source-file src="src/android/armeabi-v7a/libjpush217.so" target-dir="libs/armeabi-v7a"/>
|
||||
<source-file src="src/android/arm64-v8a/libjpush217.so" target-dir="libs/arm64-v8a"/>
|
||||
<source-file src="src/android/x86/libjpush217.so" target-dir="libs/x86"/>
|
||||
<source-file src="src/android/x86_64/libjpush217.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>
|
||||
</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);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -2,11 +2,10 @@ package cn.jpush.phonegap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import __PACKAGE_NAME__.R;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
@@ -28,7 +27,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
||||
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.TagAliasCallback;
|
||||
import cn.jpush.android.data.JPushLocalNotification;
|
||||
@@ -37,6 +35,7 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
private final static List<String> methodList =
|
||||
Arrays.asList(
|
||||
"addLocalNotification",
|
||||
"areNotificationEnabled",
|
||||
"clearAllNotification",
|
||||
"clearLocalNotifications",
|
||||
"clearNotificationById",
|
||||
@@ -314,6 +313,18 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
void areNotificationEnabled(JSONArray data, final CallbackContext callback) {
|
||||
NotificationManagerCompat nmc = NotificationManagerCompat.from(
|
||||
cordova.getActivity().getApplicationContext());
|
||||
int isEnabled;
|
||||
if (nmc.areNotificationsEnabled()) {
|
||||
isEnabled = 1;
|
||||
} else {
|
||||
isEnabled = 0;
|
||||
}
|
||||
callback.success(isEnabled);
|
||||
}
|
||||
|
||||
void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
|
||||
int num = -1;
|
||||
try {
|
||||
@@ -438,19 +449,23 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义推送通知栏样式,需要自己实现具体代码。
|
||||
* http://docs.jiguang.cn/client/android_tutorials/#_11
|
||||
*/
|
||||
void setCustomPushNotificationBuilder(JSONArray data,
|
||||
CallbackContext callbackContext) {
|
||||
CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
||||
this.cordova.getActivity(), R.layout.test_notification_layout,
|
||||
R.id.icon, R.id.title, R.id.text);
|
||||
builder.developerArg0 = "Custom Builder 1";
|
||||
JPushInterface.setPushNotificationBuilder(2, builder);
|
||||
JSONObject obj = new JSONObject();
|
||||
try {
|
||||
obj.put("id", 2);
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// CustomPushNotificationBuilder builder = new CustomPushNotificationBuilder(
|
||||
// this.cordova.getActivity(), R.layout.test_notification_layout,
|
||||
// R.id.icon, R.id.title, R.id.text);
|
||||
// builder.developerArg0 = "Custom Builder 1";
|
||||
// JPushInterface.setPushNotificationBuilder(2, builder);
|
||||
// JSONObject obj = new JSONObject();
|
||||
// try {
|
||||
// obj.put("id", 2);
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
void clearAllNotification(JSONArray data, CallbackContext callbackContext) {
|
||||
|
||||
@@ -30,6 +30,10 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
handlingNotificationReceive(context, intent);
|
||||
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(action)) {
|
||||
handlingNotificationOpen(context, intent);
|
||||
} else if (JPushInterface.ACTION_RICHPUSH_CALLBACK.equals(action)) {
|
||||
// 当在 HTML 页面中调用 JPushWeb.triggerNativeAction(String params) 方法时触发此方法,
|
||||
// 再进行相关的操作。
|
||||
|
||||
} else {
|
||||
Log.d(TAG, "Unhandled intent - " + action);
|
||||
}
|
||||
|
||||
Binary file not shown.
BIN
src/android/arm64-v8a/libjpush217.so
Normal file
BIN
src/android/arm64-v8a/libjpush217.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/armeabi-v7a/libjpush217.so
Normal file
BIN
src/android/armeabi-v7a/libjpush217.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/armeabi/libjpush217.so
Normal file
BIN
src/android/armeabi/libjpush217.so
Normal file
Binary file not shown.
BIN
src/android/ic_richpush_actionbar_back.png
Normal file
BIN
src/android/ic_richpush_actionbar_back.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 695 B |
BIN
src/android/ic_richpush_actionbar_divider.png
Normal file
BIN
src/android/ic_richpush_actionbar_divider.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 181 B |
Binary file not shown.
BIN
src/android/jpush-android-2.1.7.jar
Normal file
BIN
src/android/jpush-android-2.1.7.jar
Normal file
Binary file not shown.
15
src/android/jpush_popwin_layout.xml
Normal file
15
src/android/jpush_popwin_layout.xml
Normal file
@@ -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>
|
||||
13
src/android/jpush_style.xml
Normal file
13
src/android/jpush_style.xml
Normal file
@@ -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>
|
||||
51
src/android/jpush_webview_layout.xml
Normal file
51
src/android/jpush_webview_layout.xml
Normal file
@@ -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>
|
||||
21
src/android/richpush_btn_selector.xml
Normal file
21
src/android/richpush_btn_selector.xml
Normal file
@@ -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.
BIN
src/android/x86/libjpush217.so
Normal file
BIN
src/android/x86/libjpush217.so
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/android/x86_64/libjpush217.so
Normal file
BIN
src/android/x86_64/libjpush217.so
Normal file
Binary file not shown.
@@ -58,6 +58,9 @@
|
||||
//地理位置上报 [latitude,longitude]
|
||||
-(void)setLocation:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
//检查用户的推送设置情况
|
||||
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
/*
|
||||
* 以下为js中可监听到的事件
|
||||
* jpush.openNotification 点击推送消息启动或唤醒app
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
#import "JPushPlugin.h"
|
||||
#import "JPUSHService.h"
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <AdSupport/AdSupport.h>
|
||||
|
||||
static NSString *const JM_APP_KEY = @"APP_KEY";
|
||||
static NSString *const JM_APP_CHANNEL = @"CHANNEL";
|
||||
static NSString *const JM_APP_ISPRODUCTION = @"IsProduction";
|
||||
static NSString *const JP_APP_KEY = @"APP_KEY";
|
||||
static NSString *const JP_APP_CHANNEL = @"CHANNEL";
|
||||
static NSString *const JP_APP_ISPRODUCTION = @"IsProduction";
|
||||
static NSString *const JP_APP_ISIDFA = @"IsIDFA";
|
||||
static NSString *const JPushConfigFileName = @"PushConfig";
|
||||
static NSDictionary *_luanchOptions = nil;
|
||||
static NSDictionary *_launchOptions = nil;
|
||||
|
||||
@implementation JPushPlugin
|
||||
|
||||
@@ -50,7 +52,7 @@ static NSDictionary *_luanchOptions = nil;
|
||||
}else{
|
||||
result = @(1);
|
||||
}
|
||||
[self hanleResultWithValue:result command:command];
|
||||
[self handleResultWithValue:result command:command];
|
||||
}
|
||||
|
||||
-(void)initial:(CDVInvokedUrlCommand*)command{
|
||||
@@ -90,8 +92,8 @@ static NSDictionary *_luanchOptions = nil;
|
||||
name:kJPushPluginReceiveNotification
|
||||
object:nil];
|
||||
|
||||
if (_luanchOptions) {
|
||||
NSDictionary *userInfo = [_luanchOptions
|
||||
if (_launchOptions) {
|
||||
NSDictionary *userInfo = [_launchOptions
|
||||
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
|
||||
if ([userInfo count] >0) {
|
||||
NSError *error;
|
||||
@@ -151,7 +153,7 @@ static NSDictionary *_luanchOptions = nil;
|
||||
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command{
|
||||
NSString* registrationID = [JPUSHService registrationID];
|
||||
NSLog(@"### getRegistrationID %@",registrationID);
|
||||
[self hanleResultWithValue:registrationID command:command];
|
||||
[self handleResultWithValue:registrationID command:command];
|
||||
}
|
||||
|
||||
-(void)startLogPageView:(CDVInvokedUrlCommand*)command{
|
||||
@@ -220,7 +222,7 @@ static NSDictionary *_luanchOptions = nil;
|
||||
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
|
||||
NSInteger num = [UIApplication sharedApplication].applicationIconBadgeNumber;
|
||||
NSNumber *number = [NSNumber numberWithInteger:num];
|
||||
[self hanleResultWithValue:number command:command];
|
||||
[self handleResultWithValue:number command:command];
|
||||
}
|
||||
|
||||
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command{
|
||||
@@ -257,9 +259,23 @@ static NSDictionary *_luanchOptions = nil;
|
||||
[JPUSHService setLatitude:[((NSString*)command.arguments[0]) doubleValue] longitude:[((NSString*)command.arguments[1]) doubleValue]];
|
||||
}
|
||||
|
||||
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command{
|
||||
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{
|
||||
_luanchOptions = theLaunchOptions;
|
||||
_launchOptions = theLaunchOptions;
|
||||
|
||||
[JPUSHService setDebugMode];
|
||||
|
||||
@@ -273,21 +289,30 @@ static NSDictionary *_luanchOptions = nil;
|
||||
}
|
||||
|
||||
NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath];
|
||||
NSString * appkey = [plistData valueForKey:JM_APP_KEY];
|
||||
NSString * channel = [plistData valueForKey:JM_APP_CHANNEL];
|
||||
NSNumber * isProduction = [plistData valueForKey:JM_APP_ISPRODUCTION];
|
||||
NSString * appkey = [plistData valueForKey:JP_APP_KEY];
|
||||
NSString * channel = [plistData valueForKey:JP_APP_CHANNEL];
|
||||
NSNumber * isProduction = [plistData valueForKey:JP_APP_ISPRODUCTION];
|
||||
NSNumber *isIDFA = [plistData valueForKey:JP_APP_ISIDFA];
|
||||
|
||||
if (!appkey || appkey.length == 0) {
|
||||
NSLog(@"error: app key not found in PushConfig.plist ");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
[JPUSHService setupWithOption:_luanchOptions appKey:appkey
|
||||
channel:channel apsForProduction:[isProduction boolValue] ];
|
||||
NSString *advertisingId = nil;
|
||||
if(isIDFA){
|
||||
advertisingId = [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString];
|
||||
}
|
||||
[JPUSHService setupWithOption:_launchOptions
|
||||
appKey:appkey
|
||||
channel:channel
|
||||
apsForProduction:[isProduction boolValue]
|
||||
advertisingIdentifier:advertisingId];
|
||||
|
||||
}
|
||||
|
||||
#pragma mark 将参数返回给js
|
||||
-(void)hanleResultWithValue:(id)value command:(CDVInvokedUrlCommand*)command{
|
||||
-(void)handleResultWithValue:(id)value command:(CDVInvokedUrlCommand*)command{
|
||||
CDVPluginResult *result = nil;
|
||||
CDVCommandStatus status = CDVCommandStatus_OK;
|
||||
|
||||
|
||||
@@ -8,5 +8,7 @@
|
||||
<string>Subscription</string>
|
||||
<key>IsProduction</key>
|
||||
<false/>
|
||||
<key>IsIDFA</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
|
||||
*/
|
||||
|
||||
#define JPUSH_VERSION_NUMBER 2.1.0
|
||||
#define JPUSH_VERSION_NUMBER 2.1.8
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@@ -51,6 +51,7 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||
* @param appKey 一个JPush 应用必须的,唯一的标识. 请参考 JPush 相关说明文档来获取这个标识.
|
||||
* @param channel 发布渠道. 可选.
|
||||
* @param isProduction 是否生产环境. 如果为开发状态,设置为 NO; 如果为生产状态,应改为 YES.
|
||||
* @param advertisingIdentifier 广告标识符(IDFA) 如果不需要使用IDFA,传nil.
|
||||
*
|
||||
* @discussion 提供SDK启动必须的参数, 来启动 SDK.
|
||||
* 此接口必须在 App 启动时调用, 否则 JPush SDK 将无法正常工作.
|
||||
@@ -61,6 +62,13 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||
apsForProduction:(BOOL)isProduction;
|
||||
|
||||
|
||||
+ (void)setupWithOption:(NSDictionary *)launchingOption
|
||||
appKey:(NSString *)appKey
|
||||
channel:(NSString *)channel
|
||||
apsForProduction:(BOOL)isProduction
|
||||
advertisingIdentifier:(NSString *)advertisingId;
|
||||
|
||||
|
||||
///----------------------------------------------------
|
||||
/// @name APNs about 通知相关
|
||||
///----------------------------------------------------
|
||||
@@ -78,6 +86,7 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||
|
||||
+ (void)registerDeviceToken:(NSData *)deviceToken;
|
||||
|
||||
|
||||
/*!
|
||||
* @abstract 处理收到的 APNs 消息
|
||||
*/
|
||||
@@ -97,7 +106,7 @@ extern NSString *const kJPFServiceErrorNotification; // 错误提示
|
||||
+ (void) setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
callbackSelector:(SEL)cbSelector
|
||||
target:(id)theTarget;
|
||||
target:(id)theTarget __attribute__((deprecated("JPush 2.1.1 版本已过期")));;
|
||||
|
||||
+ (void) setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
@@ -108,9 +117,9 @@ callbackSelector:(SEL)cbSelector
|
||||
callbackSelector:(SEL)cbSelector
|
||||
object:(id)theTarget;
|
||||
|
||||
+ (void) setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;
|
||||
+ (void)setTags:(NSSet *)tags
|
||||
alias:(NSString *)alias
|
||||
fetchCompletionHandle:(void (^)(int iResCode, NSSet *iTags, NSString *iAlias))completionHandler;
|
||||
|
||||
+ (void) setTags:(NSSet *)tags
|
||||
aliasInbackground:(NSString *)alias;
|
||||
|
||||
Binary file not shown.
@@ -210,6 +210,23 @@ JPushPlugin.prototype.getApplicationIconBadgeNumber = function(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
|
||||
JPushPlugin.prototype.setDebugMode = function(mode) {
|
||||
if(device.platform == "Android") {
|
||||
|
||||
Reference in New Issue
Block a user