mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-01 06:52:50 +08:00
Merge branch 'dev'
This commit is contained in:
commit
494df2e527
@ -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.9-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)
|
||||||
|
|
||||||
|
@ -9,19 +9,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
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
# 通用 API 说明(同时适用于 Android 和 iOS 系统)
|
# 通用 API 说明(同时适用于 Android 和 iOS 系统)
|
||||||
|
|
||||||
|
- [注册成功事件](#注册成功事件)
|
||||||
- [停止与恢复推送服务](#停止与恢复推送服务)
|
- [停止与恢复推送服务](#停止与恢复推送服务)
|
||||||
- [获取 RegistrationID](#获取-registrationid)
|
- [获取 RegistrationID](#获取-registrationid)
|
||||||
- [设置别名与标签](#设置别名与标签)
|
- [设置别名与标签](#设置别名与标签)
|
||||||
@ -8,7 +9,23 @@
|
|||||||
- [获取自定义消息推送内容](#获取自定义消息推送内容)
|
- [获取自定义消息推送内容](#获取自定义消息推送内容)
|
||||||
- [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送)
|
- [判断系统设置中是否允许当前应用推送](#判断系统设置中是否允许当前应用推送)
|
||||||
|
|
||||||
|
## 注册成功事件
|
||||||
|
|
||||||
|
### jpush.receiveRegistrationId
|
||||||
|
|
||||||
|
集成了 JPush SDK 的应用程序在第一次成功注册到 JPush 服务器时,JPush 服务器会给客户端返回一个唯一的该设备的标识 - RegistrationID。
|
||||||
|
就会触发这个事件(注意只有第一次会触发该事件,之后如果想要取到 registrationId,可以直接调用 *getRegistrationID* 方法)。
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
```js
|
||||||
|
document.addEventListener('jpush.receiveRegistrationId', function (event) {
|
||||||
|
console.log(event.registrationId)
|
||||||
|
}, false)
|
||||||
|
```
|
||||||
|
|
||||||
## 停止与恢复推送服务
|
## 停止与恢复推送服务
|
||||||
|
|
||||||
### API - init
|
### API - init
|
||||||
|
|
||||||
调用此 API,用来开启 JPush SDK 提供的推送服务。
|
调用此 API,用来开启 JPush SDK 提供的推送服务。
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jpush-phonegap-plugin",
|
"name": "jpush-phonegap-plugin",
|
||||||
"version": "3.2.8",
|
"version": "3.2.9",
|
||||||
"description": "JPush for cordova plugin",
|
"description": "JPush for cordova plugin",
|
||||||
"cordova": {
|
"cordova": {
|
||||||
"id": "jpush-phonegap-plugin",
|
"id": "jpush-phonegap-plugin",
|
||||||
|
@ -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.9">
|
||||||
|
|
||||||
<name>JPush</name>
|
<name>JPush</name>
|
||||||
<description>JPush for cordova plugin</description>
|
<description>JPush for cordova plugin</description>
|
||||||
|
@ -155,7 +155,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 {
|
||||||
|
@ -79,6 +79,10 @@
|
|||||||
selector:@selector(networkDidReceiveMessage:)
|
selector:@selector(networkDidReceiveMessage:)
|
||||||
name:kJPFNetworkDidReceiveMessageNotification
|
name:kJPFNetworkDidReceiveMessageNotification
|
||||||
object:nil];
|
object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(receiveLocalNotification:)
|
||||||
|
name:JPushDocumentEvent_ReceiveLocalNotification
|
||||||
|
object:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
+(void)fireDocumentEvent:(NSString*)eventName jsString:(NSString*)jsString{
|
||||||
@ -347,14 +351,50 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void)setLocalNotification:(CDVInvokedUrlCommand*)command{
|
-(void)setLocalNotification:(CDVInvokedUrlCommand*)command{
|
||||||
NSLog(@"ios 10 after please use UNNotificationRequest to set local notification, see apple doc to learn more");
|
NSNumber *delay = [command argumentAtIndex:0];
|
||||||
|
|
||||||
NSDate *date = [NSDate dateWithTimeIntervalSinceNow:[[command argumentAtIndex:0] intValue]];
|
|
||||||
NSString *alert = [command argumentAtIndex:1];
|
NSString *alert = [command argumentAtIndex:1];
|
||||||
NSNumber *badge = [command argumentAtIndex:2];
|
NSNumber *badge = [command argumentAtIndex:2];
|
||||||
NSString *idKey = [command argumentAtIndex:3];
|
NSString *idKey = [command argumentAtIndex:3];
|
||||||
NSDictionary *dict = [command argumentAtIndex:4];
|
NSDictionary *userInfo = [command argumentAtIndex:4];
|
||||||
[JPUSHService setLocalNotification:date alertBody:alert badge:badge.intValue alertAction:nil identifierKey:idKey userInfo:dict soundName:nil];
|
|
||||||
|
JPushNotificationContent *content = [[JPushNotificationContent alloc] init];
|
||||||
|
|
||||||
|
if (alert) {
|
||||||
|
content.body = alert;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (badge) {
|
||||||
|
content.badge = badge;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (userInfo) {
|
||||||
|
content.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushNotificationTrigger *trigger = [[JPushNotificationTrigger alloc] init];
|
||||||
|
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
|
||||||
|
if (delay) {
|
||||||
|
trigger.timeInterval = [delay doubleValue];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (delay) {
|
||||||
|
trigger.fireDate = [NSDate dateWithTimeIntervalSinceNow:[[command argumentAtIndex:0] intValue]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JPushNotificationRequest *request = [[JPushNotificationRequest alloc] init];
|
||||||
|
request.content = content;
|
||||||
|
request.trigger = trigger;
|
||||||
|
|
||||||
|
if (idKey) {
|
||||||
|
request.requestIdentifier = idKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.completionHandler = ^(id result) {
|
||||||
|
NSLog(@"result");
|
||||||
|
};
|
||||||
|
|
||||||
|
[JPUSHService addNotification:request];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{
|
-(void)deleteLocalNotificationWithIdentifierKey:(CDVInvokedUrlCommand*)command{
|
||||||
@ -503,4 +543,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(void)receiveLocalNotification:(NSNotification *)notification {
|
||||||
|
if (notification && notification.object) {
|
||||||
|
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveLocalNotification
|
||||||
|
jsString:[notification.object toJsonString]];
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user