From 7f2179fe328965c5b5b62c248f0699e1f89329d3 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Wed, 31 Jan 2018 16:12:11 +0800 Subject: [PATCH 1/8] fix backgroup notification event fire twice --- src/ios/Plugins/AppDelegate+JPush.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index fcc7026..793d965 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -156,7 +156,7 @@ NSDictionary *_launchOptions; } -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{ - NSMutableDictionary *userInfo = @[].mutableCopy; + NSMutableDictionary *userInfo = @{}.mutableCopy; if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; @@ -169,6 +169,10 @@ NSDictionary *_launchOptions; userInfo[@"identifier"] = notification.request.identifier; } + if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件 + return; + } + [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]]; completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); } From 83b7ca162add9e5ed8280d70300d710be6115103 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Wed, 31 Jan 2018 16:19:17 +0800 Subject: [PATCH 2/8] update to 3.3.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dec7419..5bc39ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.3.0", + "version": "3.3.1", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", From 67421b5091cb3e5982877df5d457918e52ad63a0 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Thu, 1 Feb 2018 10:11:03 +0800 Subject: [PATCH 3/8] fix application in activity notification will not alert in ios10 --- package.json | 2 +- plugin.xml | 2 +- src/ios/Plugins/AppDelegate+JPush.m | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5bc39ea..5cbd4f2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.3.1", + "version": "3.3.2", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", diff --git a/plugin.xml b/plugin.xml index 8f6dcc1..9232aca 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.3.2"> JPush JPush for cordova plugin diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index 793d965..fe0c50d 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -169,12 +169,14 @@ NSDictionary *_launchOptions; userInfo[@"identifier"] = notification.request.identifier; } + completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); + if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件 return; } [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]]; - completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); + } -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ From 8ccdbd525b9450a4b36d70f6b2d4f76311d0be36 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Tue, 6 Feb 2018 14:32:12 +0800 Subject: [PATCH 4/8] fix app not launch open notification will fire twice bug --- src/ios/Plugins/AppDelegate+JPush.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index fe0c50d..fd2ce49 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -40,7 +40,8 @@ NSDictionary *_launchOptions; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]]; }]; - if (notification) { + if (notification != nil && + [[UIDevice currentDevice].systemVersion floatValue] < 10.0) {// iOS 10 以后通过 openNotification 这个回调触发事件。 if (notification.userInfo) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) { @@ -136,9 +137,6 @@ NSDictionary *_launchOptions; [JPUSHService handleRemoteNotification:userInfo]; NSString *eventName; switch ([UIApplication sharedApplication].applicationState) { - case UIApplicationStateInactive: - eventName = JPushDocumentEvent_OpenNotification; - break; case UIApplicationStateActive: eventName = JPushDocumentEvent_ReceiveNotification; break; From 24328f2ac98e8fe9b05f1b0eccd71f9d93f37779 Mon Sep 17 00:00:00 2001 From: huangminlinux <380108184@qq.com> Date: Tue, 6 Feb 2018 15:38:47 +0800 Subject: [PATCH 5/8] update to 3.3.3 --- package.json | 2 +- plugin.xml | 2 +- src/ios/Plugins/AppDelegate+JPush.m | 38 ++++++++++++++--------------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 5cbd4f2..60b9993 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.3.2", + "version": "3.3.3", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", diff --git a/plugin.xml b/plugin.xml index 9232aca..143c9ce 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.3.3"> JPush JPush for cordova plugin diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index fd2ce49..e4b759e 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -59,19 +59,19 @@ NSDictionary *_launchOptions; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]]; } } - - [JPUSHService setDebugMode]; - - NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"]; - NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath]; - NSNumber *delay = [plistData valueForKey:JPushConfig_Delay]; - - _launchOptions = notification.userInfo; - - if (![delay boolValue]) { - [self startJPushSDK]; - } } + + [JPUSHService setDebugMode]; + + NSString *plistPath = [[NSBundle mainBundle] pathForResource:JPushConfig_FileName ofType:@"plist"]; + NSMutableDictionary *plistData = [[NSMutableDictionary alloc] initWithContentsOfFile:plistPath]; + NSNumber *delay = [plistData valueForKey:JPushConfig_Delay]; + + _launchOptions = notification.userInfo; + + if (![delay boolValue]) { + [self startJPushSDK]; + } } -(void)startJPushSDK{ @@ -137,14 +137,12 @@ NSDictionary *_launchOptions; [JPUSHService handleRemoteNotification:userInfo]; NSString *eventName; switch ([UIApplication sharedApplication].applicationState) { - case UIApplicationStateActive: - eventName = JPushDocumentEvent_ReceiveNotification; - break; - case UIApplicationStateBackground: - eventName = JPushDocumentEvent_BackgroundNotification; - break; - default: - break; + case UIApplicationStateBackground: + eventName = JPushDocumentEvent_BackgroundNotification; + break; + default: + eventName = JPushDocumentEvent_ReceiveNotification; + break; } [JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]]; From 6f77da5f414c0b97e4c74c6a7c5b40c2e2d9f4ab Mon Sep 17 00:00:00 2001 From: Hevin Date: Mon, 26 Feb 2018 14:50:53 +0800 Subject: [PATCH 6/8] build: v3.4.0 Support cordova-android 7.0.0 --- README.md | 2 +- package.json | 4 ++-- plugin.xml | 58 ++++++++++++++++++++++++++-------------------------- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 63eed6e..e3107e5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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) -[![release](https://img.shields.io/badge/release-3.3.0-blue.svg)](https://github.com/jpush/jpush-phonegap-plugin/releases) +[![release](https://img.shields.io/badge/release-3.4.0-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) [![weibo](https://img.shields.io/badge/weibo-JPush-blue.svg)](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1) diff --git a/package.json b/package.json index dec7419..f8ca70f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jpush-phonegap-plugin", - "version": "3.3.0", + "version": "3.4.0", "description": "JPush for cordova plugin", "cordova": { "id": "jpush-phonegap-plugin", @@ -23,7 +23,7 @@ ], "devDependencies": { "cordova-plugin-device": "*", - "cordova-plugin-jcore": "*" + "cordova-plugin-jcore": ">=1.2.0" }, "author": "JiGuang", "license": "MIT", diff --git a/plugin.xml b/plugin.xml index 8f6dcc1..979967c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="3.4.0"> JPush JPush for cordova plugin @@ -57,10 +57,6 @@ $APP_KEY - - @@ -70,8 +66,8 @@ - - + + @@ -90,8 +86,8 @@ - - + + @@ -102,13 +98,13 @@ - + - + @@ -148,7 +144,7 @@ - + - + @@ -196,26 +192,30 @@ - + - - - + + + - - + + - - + + - - - + + + - + From 10b457d489841ffbf12d56bd10635dbe54d1b9ff Mon Sep 17 00:00:00 2001 From: Hevin Date: Mon, 26 Feb 2018 15:29:36 +0800 Subject: [PATCH 7/8] Add comments of cordova-android 7.0.0 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e3107e5..61a470b 100644 --- a/README.md +++ b/README.md @@ -11,14 +11,14 @@ - 如需要短信验证码功能插件,可关注 [cordova-plugin-jsms](https://github.com/jpush/cordova-plugin-jsms) - 如需要统计分析功能插件,可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics) -注意:目前插件暂未支持 cordova-android 7.0.0,因此在添加 android platform 时,请指定 7.0.0 以下版本,例如 6.4.0。 +**注意**:插件从 v3.4.0 开始支持 cordova-android 7.0.0,因为 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本的 cordova-plugin-jcore,再安装插件。 ## Install > 注意: > -> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。 -> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 +> -应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。 +> -在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 - 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+: From 6c2bc206e392ed2c4f7158e99fd15b540f92d358 Mon Sep 17 00:00:00 2001 From: Hevin Date: Mon, 26 Feb 2018 15:42:29 +0800 Subject: [PATCH 8/8] Format the style --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 61a470b..bd8243b 100644 --- a/README.md +++ b/README.md @@ -16,9 +16,8 @@ ## Install > 注意: -> -> -应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。 -> -在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 +> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。 +> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 - 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+: