Compare commits

..

15 Commits

Author SHA1 Message Date
huangminlinux
4b929a8e2e update 3.2.12 2017-11-08 13:56:14 +08:00
huangminlinux
d3e2e1a5d7 fix app not launch open notification bug 2017-11-08 13:49:50 +08:00
Hevin
001ab96283 Fix error words 2017-11-03 17:37:48 +08:00
huangminlinux
1314d33c62 udpate docs 2017-11-03 17:13:52 +08:00
huangminlinux
22b6d9a006 adjust glable var to static 2017-11-01 16:29:27 +08:00
Hevin
0cbedb412c Format api doc 2017-10-27 14:29:43 +08:00
Hevin
fbd9d63590 build: v3.2.11 2017-10-25 11:19:14 +08:00
huangminlinux
184ee01d1d update registrationId evet 2017-10-25 11:09:46 +08:00
huangminlinux
14a40c6572 adjust ios registerNotification event 2017-10-25 10:49:58 +08:00
Hevin
fefaaea14f build: v3.2.10 2017-10-23 17:22:53 +08:00
huangminlinux
d2f9959ae1 open notification event add to jpush event cache 2017-10-23 17:18:49 +08:00
huangminlinux
3129165d3f add jpush event cache 2017-10-23 17:11:35 +08:00
Hevin
66932a8bc8 build: v3.2.9 2017-10-20 13:09:32 +08:00
huangminlinux
07c9b2b945 fix iOS10 remove local notification fail bug 2017-10-20 11:28:51 +08:00
huangminlinux
8811dfc002 update docs 2017-10-19 13:51:19 +08:00
9 changed files with 751 additions and 659 deletions

View File

@@ -1,7 +1,7 @@
# JPush PhoneGap / Cordova Plugin # JPush PhoneGap / Cordova Plugin
[![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin) [![Build Status](https://travis-ci.org/jpush/jpush-phonegap-plugin.svg?branch=master)](https://travis-ci.org/jpush/jpush-phonegap-plugin)
[![release](https://img.shields.io/badge/release-3.2.8-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) [![release](https://img.shields.io/badge/release-3.2.12-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases)
[![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin) [![platforms](https://img.shields.io/badge/platforms-iOS%7CAndroid-lightgrey.svg)](https://github.com/jpush/jpush-phonegap-plugin)
[![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1) [![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
@@ -28,7 +28,7 @@
- 或下载到本地安装: - 或下载到本地安装:
```shell ```shell
cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey
``` ```
> 在使用 Xcode 8 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 > 在使用 Xcode 8 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。

View File

@@ -1,7 +1,5 @@
# Android API 简介 # Android API 简介
- [注册成功事件](#注册成功事件)
- [获取集成日志(同时适用于 iOS](#获取集成日志同时适用于-ios)
- [清除通知](#清除通知) - [清除通知](#清除通知)
- [设置允许推送时间](#设置允许推送时间) - [设置允许推送时间](#设置允许推送时间)
- [设置通知静默时间](#设置通知静默时间) - [设置通知静默时间](#设置通知静默时间)
@@ -9,19 +7,6 @@
- [设置保留最近通知条数](#设置保留最近通知条数) - [设置保留最近通知条数](#设置保留最近通知条数)
- [本地通知](#本地通知) - [本地通知](#本地通知)
## 注册成功事件
### jpush.receiveRegistrationId
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时JPush 服务器会给客户端返回一个唯一的该设备的标识 - RegistrationID。
就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 registrationId可以直接调用 *getRegistrationID* 方法)。
#### 代码示例
```js
document.addEventListener('jpush.receiveRegistrationId', function (event) {
console.log(event.registrationId)
}, false)
```
## 获取集成日志(同时适用于 iOS ## 获取集成日志(同时适用于 iOS
### API - setDebugMode ### API - setDebugMode
@@ -103,7 +88,7 @@ window.JPush.setPushTime(days, startHour, endHour)
#### 参数说明 #### 参数说明
- days: 数组0 表示星期天1 表示星期一以此类推7天制数组中值的范围为 0 到 6 )。 - days: 数组0 表示星期天1 表示星期一以此类推7天制数组中值的范围为 0 到 6 )。
数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0则表示任何时间都收不到消息和通知。 数组的值为 null, 表示任何时间都可以收到消息和通知,数组的 size 为 0则表示任何时间都收不到消息和通知。
- startHour: 整形,允许推送的开始时间 24 小时制startHour 的范围为 0 到 23 - startHour: 整形,允许推送的开始时间 24 小时制startHour 的范围为 0 到 23
- endHour: 整形,允许推送的结束时间 24 小时制endHour 的范围为 0 到 23 - endHour: 整形,允许推送的结束时间 24 小时制endHour 的范围为 0 到 23

View File

@@ -1,15 +1,52 @@
# 通用 API 说明(同时适用于 Android 和 iOS 系统) # 通用 API 说明(同时适用于 Android 和 iOS 系统)
- [停止与恢复推送服务](#停止与恢复推送服务) - [注册成功事件](#注册成功事件)
- [jpush.receiveRegistrationId](#jpushreceiveregistrationid)
- [初始化、停止与恢复推送服务](#初始化停止与恢复推送服务)
- [init](#init)
- [stopPush](#stoppush)
- [resumePush](#resumepush)
- [isPushStopped](#ispushstopped)
- [开启 Debug 模式](#开启-debug-模式)
- [setDebugMode](#setdebugmode)
- [获取 RegistrationID](#获取-registrationid) - [获取 RegistrationID](#获取-registrationid)
- [getRegistrationID](#getregistrationid)
- [设置别名与标签](#设置别名与标签) - [设置别名与标签](#设置别名与标签)
- [setAlias](#setalias)
- [deleteAlias](#deletealias)
- [getAlias](#getalias)
- [setTags](#settags)
- [addTags](#addtags)
- [deleteTags](#deletetags)
- [cleanTags](#cleantags)
- [getAllTags](#getalltags)
- [checkTagBindState](#checktagbindstate)
- [获取点击通知内容](#获取点击通知内容) - [获取点击通知内容](#获取点击通知内容)
- [event - jpush.openNotification](#event---jpushopennotification)
- [获取通知内容](#获取通知内容) - [获取通知内容](#获取通知内容)
- [event - jpush.receiveNotification](#event---jpushreceivenotification)
- [获取自定义消息推送内容](#获取自定义消息推送内容) - [获取自定义消息推送内容](#获取自定义消息推送内容)
- [event - jpush.receiveMessage](#event---jpushreceivemessage)
- [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送) - [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送)
## 停止与恢复推送服务 ## 注册成功事件
### API - init
### jpush.receiveRegistrationId
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时JPush 服务器会给客户端返回一个唯一的该设备的标识 - Registration ID。
此时就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 Registration Id可以直接调用 `getRegistrationID` 方法)。
#### 代码示例
```js
document.addEventListener('jpush.receiveRegistrationId', function (event) {
console.log(event.registrationId)
}, false)
```
## 初始化、停止与恢复推送服务
### init
调用此 API用来开启 JPush SDK 提供的推送服务。 调用此 API用来开启 JPush SDK 提供的推送服务。
@@ -27,7 +64,7 @@
window.JPush.init() window.JPush.init()
``` ```
### API - stopPush ### stopPush
- Android: - Android:
- 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。 - 开发者 App 可以通过调用停止推送服务 API 来停止极光推送服务,当又需要使用极光推送服务时,则必须要调用恢复推送服务 API。
@@ -46,7 +83,7 @@ window.JPush.init()
window.JPush.stopPush() window.JPush.stopPush()
``` ```
### API - resumePush ### resumePush
恢复推送服务。调用了此 API 后: 恢复推送服务。调用了此 API 后:
@@ -62,7 +99,7 @@ window.JPush.stopPush()
window.JPush.resumePush() window.JPush.resumePush()
``` ```
### API - isPushStopped ### isPushStopped
- Android 平台: - Android 平台:
- 用来检查 Push Service 是否已经被停止。 - 用来检查 Push Service 是否已经被停止。
@@ -93,7 +130,7 @@ window.JPush.isPushStopped(function (result) {
``` ```
## 开启 Debug 模式 ## 开启 Debug 模式
### API - setDebugMode ### setDebugMode
用于开启 Debug 模式,显示更多的日志信息。 用于开启 Debug 模式,显示更多的日志信息。
#### 代码示例 #### 代码示例
@@ -103,11 +140,13 @@ window.JPush.setDebugMode(true)
``` ```
#### 参数说明 #### 参数说明
- isOpen: true开启 Debug 模式false关闭 Debug 模式,不显示错误信息之外的日志信息。
- true: 开启 Debug 模式;
- false: 关闭 Debug 模式,不显示错误信息之外的日志信息。
## 获取 RegistrationID ## 获取 RegistrationID
### API - getRegistrationID ### getRegistrationID
RegistrationID 定义: RegistrationID 定义:
@@ -361,7 +400,7 @@ window.JPush.checkTagBindState({ sequence: 1, tag: 'tag1' },
### event - jpush.openNotification ### event - jpush.openNotification
点击通知进入应用程序时会出发改事件 点击通知进入应用程序时触发
#### 代码示例 #### 代码示例
@@ -378,8 +417,6 @@ document.addEventListener("jpush.openNotification", function (event) {
}, false) }, false)
``` ```
> ps点击通知后传递的 json object 保存在 window.JPush.openNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。
- Android: - Android:
```json ```json
@@ -418,7 +455,7 @@ document.addEventListener("jpush.openNotification", function (event) {
### event - jpush.receiveNotification ### event - jpush.receiveNotification
收到通知时触发该事件 收到通知时触发。
#### 代码示例 #### 代码示例
@@ -436,8 +473,6 @@ document.addEventListener("jpush.receiveNotification", function (event) {
}, false) }, false)
``` ```
> ps点击通知后传递的 json object 保存在 window.JPush.receiveNotification直接访问即可字段示例根据实际推送情况可能略有差别请注意。
- Android: - Android:
```json ```json
@@ -476,7 +511,7 @@ document.addEventListener("jpush.receiveNotification", function (event) {
### event - jpush.receiveMessage ### event - jpush.receiveMessage
收到自定义消息时触发这个事件,推荐使用事件的方式传递。 收到自定义消息时触发,推荐使用事件的方式传递。
但同时保留了 `receiveMessageIniOSCallback` 的回调函数,兼容以前的代码。 但同时保留了 `receiveMessageIniOSCallback` 的回调函数,兼容以前的代码。
@@ -495,8 +530,6 @@ document.addEventListener("jpush.receiveMessage", function (event) {
}, false) }, false)
``` ```
> ps点击通知后传递的 json object 保存在 window.JPush.receiveMessage直接访问即可字段示例根据实际推送情况可能略有差别请注意。
- Android: - Android:
```json ```json
@@ -545,4 +578,4 @@ window.JPush.getUserNotificationSettings(function(result) {
} else if(result > 0) { } else if(result > 0) {
// 系统设置中打开了应用推送。 // 系统设置中打开了应用推送。
}) })
``` ```

View File

@@ -143,7 +143,7 @@ window.JPush.getRegistrationID(function(data) {
#### event - jpush.openNotification #### event - jpush.openNotification
点击通知启动或唤醒应用程序时会发该事件 点击通知启动或唤醒应用程序时会发该事件
#### 代码示例 #### 代码示例

View File

@@ -1,6 +1,6 @@
{ {
"name": "jpush-phonegap-plugin", "name": "jpush-phonegap-plugin",
"version": "3.2.8", "version": "3.2.12",
"description": "JPush for cordova plugin", "description": "JPush for cordova plugin",
"cordova": { "cordova": {
"id": "jpush-phonegap-plugin", "id": "jpush-phonegap-plugin",

View File

@@ -2,7 +2,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
id="jpush-phonegap-plugin" id="jpush-phonegap-plugin"
version="3.2.8"> version="3.2.12">
<name>JPush</name> <name>JPush</name>
<description>JPush for cordova plugin</description> <description>JPush for cordova plugin</description>

View File

@@ -28,25 +28,23 @@
return [self init_plus]; return [self init_plus];
} }
-(void)fireOpenNotification:(NSTimer*)timer{
if (SharedJPushPlugin) {
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[timer.userInfo toJsonString]];
[timer invalidate];
}
}
NSDictionary *_launchOptions; NSDictionary *_launchOptions;
-(void)applicationDidLaunch:(NSNotification *)notification{ -(void)applicationDidLaunch:(NSNotification *)notification{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jpushSDKDidLoginNotification) name:kJPFNetworkDidLoginNotification object:nil]; if (!_jpushEventCache) {
_jpushEventCache = @{}.mutableCopy;
}
[JPUSHService registrationIDCompletionHandler:^(int resCode, NSString *registrationID) {
NSDictionary *event = @{@"registrationId": registrationID?:@""};
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]];
}];
if (notification) { if (notification) {
if (notification.userInfo) { if (notification.userInfo) {
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[notification.userInfo toJsonString]];
userInfo:[notification.userInfo
valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] repeats:YES];
} }
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) {
@@ -56,7 +54,7 @@ NSDictionary *_launchOptions;
@"badge": @(localNotification.applicationIconBadgeNumber), @"badge": @(localNotification.applicationIconBadgeNumber),
@"extras":localNotification.userInfo, @"extras":localNotification.userInfo,
}; };
[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(fireOpenNotification:) userInfo:localNotificationEvent repeats:YES]; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]];
} }
} }
@@ -155,7 +153,12 @@ NSDictionary *_launchOptions;
} }
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
[[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:notification.userInfo]; NSDictionary* localNotificationEvent = @{@"content":notification.alertBody,
@"badge": @(notification.applicationIconBadgeNumber),
@"extras":notification.userInfo,
};
[[NSNotificationCenter defaultCenter] postNotificationName:JPushDocumentEvent_ReceiveLocalNotification object:localNotificationEvent];
} }
- (void)applicationWillEnterForeground:(UIApplication *)application { - (void)applicationWillEnterForeground:(UIApplication *)application {

View File

@@ -1,100 +1,102 @@
// //
// PushTalkPlugin.h // PushTalkPlugin.h
// PushTalk // PushTalk
// //
// Created by zhangqinghe on 13-12-13. // Created by zhangqinghe on 13-12-13.
// //
// //
#import <Cordova/CDV.h> #import <Cordova/CDV.h>
@interface JPushPlugin : CDVPlugin{ static NSMutableDictionary *_jpushEventCache;
} @interface JPushPlugin : CDVPlugin{
//注册通知服务并启动 SDK }
-(void)startJPushSDK:(CDVInvokedUrlCommand*)command;
//注册通知服务并启动 SDK
//以下为js中可调用接口 -(void)startJPushSDK:(CDVInvokedUrlCommand*)command;
//设置标签、别名
-(void)setTags:(CDVInvokedUrlCommand*)command; //以下为js中可调用接口
-(void)addTags:(CDVInvokedUrlCommand*)command; //设置标签、别名
-(void)deleteTags:(CDVInvokedUrlCommand*)command; -(void)setTags:(CDVInvokedUrlCommand*)command;
-(void)cleanTags:(CDVInvokedUrlCommand*)command; -(void)addTags:(CDVInvokedUrlCommand*)command;
-(void)getAllTags:(CDVInvokedUrlCommand*)command; -(void)deleteTags:(CDVInvokedUrlCommand*)command;
-(void)checkTagBindState:(CDVInvokedUrlCommand*)command; -(void)cleanTags:(CDVInvokedUrlCommand*)command;
-(void)getAllTags:(CDVInvokedUrlCommand*)command;
-(void)setAlias:(CDVInvokedUrlCommand*)command; -(void)checkTagBindState:(CDVInvokedUrlCommand*)command;
-(void)deleteAlias:(CDVInvokedUrlCommand*)command;
-(void)getAlias:(CDVInvokedUrlCommand*)command; -(void)setAlias:(CDVInvokedUrlCommand*)command;
-(void)deleteAlias:(CDVInvokedUrlCommand*)command;
//获取 RegistrationID -(void)getAlias:(CDVInvokedUrlCommand*)command;
-(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
//获取 RegistrationID
//页面统计 -(void)getRegistrationID:(CDVInvokedUrlCommand*)command;
-(void)startLogPageView:(CDVInvokedUrlCommand*)command;
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command; //页面统计
-(void)beginLogPageView:(CDVInvokedUrlCommand*)command; -(void)startLogPageView:(CDVInvokedUrlCommand*)command;
-(void)stopLogPageView:(CDVInvokedUrlCommand*)command;
//设置角标到服务器,服务器下一次发消息时,会设置成这个值 -(void)beginLogPageView:(CDVInvokedUrlCommand*)command;
//本接口不会改变应用本地的角标值.
-(void)setBadge:(CDVInvokedUrlCommand*)command; //设置角标到服务器,服务器下一次发消息时,会设置成这个值
//相当于 [setBadge:0] //本接口不会改变应用本地的角标值.
-(void)resetBadge:(CDVInvokedUrlCommand*)command; -(void)setBadge:(CDVInvokedUrlCommand*)command;
//相当于 [setBadge:0]
//应用本地的角标值设置/获取 -(void)resetBadge:(CDVInvokedUrlCommand*)command;
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
-(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command; //应用本地的角标值设置/获取
-(void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
//停止与恢复推送 -(void)getApplicationIconBadgeNumber:(CDVInvokedUrlCommand*)command;
-(void)stopPush:(CDVInvokedUrlCommand*)command;
-(void)resumePush:(CDVInvokedUrlCommand*)command; //停止与恢复推送
-(void)isPushStopped:(CDVInvokedUrlCommand*)command; -(void)stopPush:(CDVInvokedUrlCommand*)command;
-(void)resumePush:(CDVInvokedUrlCommand*)command;
//开关日志 -(void)isPushStopped:(CDVInvokedUrlCommand*)command;
-(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
-(void)setLogOFF:(CDVInvokedUrlCommand*)command; //开关日志
-(void)crashLogON:(CDVInvokedUrlCommand*)command; -(void)setDebugModeFromIos:(CDVInvokedUrlCommand*)command;
-(void)setLogOFF:(CDVInvokedUrlCommand*)command;
//本地推送 -(void)crashLogON:(CDVInvokedUrlCommand*)command;
-(void)setLocalNotification:(CDVInvokedUrlCommand*)command;
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command; //本地推送
-(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command; -(void)setLocalNotification:(CDVInvokedUrlCommand*)command;
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command;
//地理位置上报 [latitude,longitude] -(void)clearAllLocalNotifications:(CDVInvokedUrlCommand*)command;
-(void)setLocation:(CDVInvokedUrlCommand*)command;
//地理位置上报 [latitude,longitude]
//检查用户的推送设置情况 -(void)setLocation:(CDVInvokedUrlCommand*)command;
-(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
//检查用户的推送设置情况
//ios 10 APIs -(void)getUserNotificationSettings:(CDVInvokedUrlCommand*)command;
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
-(void)addNotificationActions:(CDVInvokedUrlCommand*)command; //ios 10 APIs
-(void)addDismissActions:(CDVInvokedUrlCommand*)command;
/* -(void)addNotificationActions:(CDVInvokedUrlCommand*)command;
* 以下为js中可监听到的事件
* jpush.openNotification 点击推送消息启动或唤醒app /*
* jpush.receiveMessage 收到自定义消息 * 以下为js中可监听到的事件
* jpush.receiveNotification 前台收到推送 * jpush.openNotification 点击推送消息启动或唤醒app
* jpush.backgroundNotification 后台收到推送 * jpush.receiveMessage 收到自定义消息
*/ * jpush.receiveNotification 前台收到推送
* jpush.backgroundNotification 后台收到推送
# pragma mark - private */
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString; # pragma mark - private
+(void)setupJPushSDK:(NSDictionary*)userInfo; +(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString;
@end +(void)setupJPushSDK:(NSDictionary*)userInfo;
JPushPlugin *SharedJPushPlugin; @end
@interface NSDictionary (JPush) static JPushPlugin *SharedJPushPlugin;
-(NSString*)toJsonString;
@end @interface NSDictionary (JPush)
-(NSString*)toJsonString;
@interface NSString (JPush) @end
-(NSDictionary*)toDictionary;
@end @interface NSString (JPush)
-(NSDictionary*)toDictionary;
@end

File diff suppressed because it is too large Load Diff