Compare commits

...

10 Commits

Author SHA1 Message Date
Hevin 1eaf73a8d3 Merge branch 'dev' 2018-02-26 15:42:43 +08:00
Hevin 6c2bc206e3 Format the style 2018-02-26 15:42:29 +08:00
Hevin 10b457d489 Add comments of cordova-android 7.0.0 2018-02-26 15:29:36 +08:00
Hevin 5b0613628b Merge cordova_android_7.0.0 to dev 2018-02-26 14:59:36 +08:00
Hevin 6f77da5f41 build: v3.4.0
Support cordova-android 7.0.0
2018-02-26 14:50:53 +08:00
huangminlinux 24328f2ac9 update to 3.3.3 2018-02-06 15:38:47 +08:00
huangminlinux 8ccdbd525b fix app not launch open notification will fire twice bug 2018-02-06 14:32:12 +08:00
huangminlinux 67421b5091 fix application in activity notification will not alert in ios10 2018-02-01 10:11:03 +08:00
huangminlinux 83b7ca162a update to 3.3.1 2018-01-31 16:19:17 +08:00
huangminlinux 7f2179fe32 fix backgroup notification event fire twice 2018-01-31 16:12:31 +08:00
4 changed files with 61 additions and 60 deletions
+2 -3
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.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) [![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)
@@ -11,12 +11,11 @@
- 如需要短信验证码功能插件,可关注 [cordova-plugin-jsms](https://github.com/jpush/cordova-plugin-jsms) - 如需要短信验证码功能插件,可关注 [cordova-plugin-jsms](https://github.com/jpush/cordova-plugin-jsms)
- 如需要统计分析功能插件,可关注 [cordova-plugin-janalytics](https://github.com/jpush/cordova-plugin-janalytics) - 如需要统计分析功能插件,可关注 [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 ## Install
> 注意: > 注意:
>
> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。 > - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 > - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "jpush-phonegap-plugin", "name": "jpush-phonegap-plugin",
"version": "3.3.0", "version": "3.4.0",
"description": "JPush for cordova plugin", "description": "JPush for cordova plugin",
"cordova": { "cordova": {
"id": "jpush-phonegap-plugin", "id": "jpush-phonegap-plugin",
@@ -23,7 +23,7 @@
], ],
"devDependencies": { "devDependencies": {
"cordova-plugin-device": "*", "cordova-plugin-device": "*",
"cordova-plugin-jcore": "*" "cordova-plugin-jcore": ">=1.2.0"
}, },
"author": "JiGuang", "author": "JiGuang",
"license": "MIT", "license": "MIT",
+29 -29
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.3.0"> version="3.4.0">
<name>JPush</name> <name>JPush</name>
<description>JPush for cordova plugin</description> <description>JPush for cordova plugin</description>
@@ -57,10 +57,6 @@
<config-file target="*JPushConfig.plist" parent="Appkey"> <config-file target="*JPushConfig.plist" parent="Appkey">
<string>$APP_KEY</string> <string>$APP_KEY</string>
</config-file> </config-file>
<!-- <hook type="after_platform_add" src="hooks/iosEnablePush.js" />
<hook type="after_plugin_install" src="hooks/iosEnablePush.js" />
<hook type="before_plugin_uninstall" src="hooks/iosDisablePush.js" /> -->
</platform> </platform>
<platform name="android"> <platform name="android">
@@ -70,8 +66,8 @@
</feature> </feature>
</config-file> </config-file>
<config-file target="AndroidManifest.xml" parent="/manifest"> <config-file target="AndroidManifest.xml" parent="/manifest" mode="merge">
<!-- Required 一些系统要求的权限,如访问网络等--> <!-- Required 一些系统要求的权限,如访问网络等 -->
<permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE" <permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" /> android:protectionLevel="signature" />
@@ -90,8 +86,8 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
</config-file> </config-file>
<config-file target="AndroidManifest.xml" parent="/manifest/application"> <config-file target="AndroidManifest.xml" parent="/manifest/application" mode="merge">
<!-- Required SDK核心功能--> <!-- Required SDK核心功能 -->
<activity android:name="cn.jpush.android.ui.PushActivity" <activity android:name="cn.jpush.android.ui.PushActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar" android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:configChanges="orientation|keyboardHidden"> android:configChanges="orientation|keyboardHidden">
@@ -102,13 +98,13 @@
</intent-filter> </intent-filter>
</activity> </activity>
<!-- Rich push 核心功能 since 2.0.6--> <!-- Rich push 核心功能 since 2.0.6 -->
<activity android:name="cn.jpush.android.ui.PopWinActivity" <activity android:name="cn.jpush.android.ui.PopWinActivity"
android:theme="@style/MyDialogStyle" android:theme="@style/MyDialogStyle"
android:exported="false"> android:exported="false">
</activity> </activity>
<!-- Required SDK核心功能--> <!-- Required SDK 核心功能 -->
<service android:name="cn.jpush.android.service.DownloadService" <service android:name="cn.jpush.android.service.DownloadService"
android:enabled="true" android:enabled="true"
android:exported="false"> android:exported="false">
@@ -148,7 +144,7 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- since 1.8.0 option 可选项。用于同一设备中不同应用的JPush服务相互拉起的功能。 --> <!-- since 1.8.0 option 可选项。用于同一设备中不同应用的 JPush 服务相互拉起的功能。 -->
<!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 --> <!-- 若不启用该功能可删除该组件,将不拉起其他应用也不能被其他应用拉起 -->
<service android:name="cn.jpush.android.service.DaemonService" <service android:name="cn.jpush.android.service.DaemonService"
android:enabled="true" android:enabled="true"
@@ -159,7 +155,7 @@
</intent-filter> </intent-filter>
</service> </service>
<!-- User defined. For test only 用户自定义的广播接收器 --> <!-- 通知广播接收器 -->
<receiver <receiver
android:name="cn.jiguang.cordova.push.JPushReceiver" android:name="cn.jiguang.cordova.push.JPushReceiver"
android:enabled="true"> android:enabled="true">
@@ -196,26 +192,30 @@
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" /> <meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
</config-file> </config-file>
<source-file src="src/android/libs/jpush-android-3.1.1.jar" target-dir="libs" /> <lib-file src="src/android/libs/jpush-android-3.1.1.jar" />
<source-file src="src/android/JPushReceiver.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushReceiver.java" target-dir="app/src/main/java/cn/jiguang/cordova/push" />
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushPlugin.java" target-dir="app/src/main/java/cn/jiguang/cordova/push" />
<source-file src="src/android/JPushEventReceiver.java" target-dir="src/cn/jiguang/cordova/push" /> <source-file src="src/android/JPushEventReceiver.java" target-dir="app/src/main/java/cn/jiguang/cordova/push" />
<source-file src="src/android/res/drawable-hdpi/jpush_richpush_btn_selector.xml" <resource-file src="src/android/res/drawable-hdpi/jpush_richpush_btn_selector.xml"
target-dir="res/drawable" /> target="res/drawable/jpush_richpush_btn_selector.xml" />
<source-file src="src/android/res/drawable-hdpi/jpush_richpush_progressbar.xml" <resource-file src="src/android/res/drawable-hdpi/jpush_richpush_progressbar.xml"
target-dir="res/drawable" /> target="res/drawable/jpush_richpush_progressbar.xml" />
<source-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png" <resource-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png"
target-dir="res/drawable-hdpi" /> target="res/drawable-hdpi/jpush_ic_richpush_actionbar_back.png" />
<source-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png" <resource-file src="src/android/res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png"
target-dir="res/drawable-hdpi" /> target="res/drawable-hdpi/jpush_ic_richpush_actionbar_divider.png" />
<source-file src="src/android/res/layout/jpush_popwin_layout.xml" target-dir="res/layout" /> <resource-file src="src/android/res/layout/jpush_popwin_layout.xml"
<source-file src="src/android/res/layout/jpush_webview_layout.xml" target-dir="res/layout" /> target="res/layout/jpush_popwin_layout.xml" />
<source-file src="src/android/res/layout/test_notification_layout.xml" target-dir="res/layout" /> <resource-file src="src/android/res/layout/jpush_webview_layout.xml"
target="res/layout/jpush_webview_layout.xml" />
<resource-file src="src/android/res/layout/test_notification_layout.xml"
target="res/layout/test_notification_layout.xml" />
<source-file src="src/android/res/values/jpush_style.xml" target-dir="res/values" /> <resource-file src="src/android/res/values/jpush_style.xml"
target="res/values/jpush_style.xml" />
</platform> </platform>
</plugin> </plugin>
+12 -10
View File
@@ -40,7 +40,8 @@ NSDictionary *_launchOptions;
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]]; [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) {
if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) {
@@ -58,6 +59,7 @@ NSDictionary *_launchOptions;
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]]; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]];
} }
} }
}
[JPUSHService setDebugMode]; [JPUSHService setDebugMode];
@@ -70,7 +72,6 @@ NSDictionary *_launchOptions;
if (![delay boolValue]) { if (![delay boolValue]) {
[self startJPushSDK]; [self startJPushSDK];
} }
}
} }
-(void)startJPushSDK{ -(void)startJPushSDK{
@@ -136,16 +137,11 @@ NSDictionary *_launchOptions;
[JPUSHService handleRemoteNotification:userInfo]; [JPUSHService handleRemoteNotification:userInfo];
NSString *eventName; NSString *eventName;
switch ([UIApplication sharedApplication].applicationState) { switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateInactive:
eventName = JPushDocumentEvent_OpenNotification;
break;
case UIApplicationStateActive:
eventName = JPushDocumentEvent_ReceiveNotification;
break;
case UIApplicationStateBackground: case UIApplicationStateBackground:
eventName = JPushDocumentEvent_BackgroundNotification; eventName = JPushDocumentEvent_BackgroundNotification;
break; break;
default: default:
eventName = JPushDocumentEvent_ReceiveNotification;
break; break;
} }
@@ -156,7 +152,7 @@ NSDictionary *_launchOptions;
} }
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{ -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{
NSMutableDictionary *userInfo = @[].mutableCopy; NSMutableDictionary *userInfo = @{}.mutableCopy;
if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) {
userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo];
@@ -169,8 +165,14 @@ NSDictionary *_launchOptions;
userInfo[@"identifier"] = notification.request.identifier; userInfo[@"identifier"] = notification.request.identifier;
} }
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert);
if ([userInfo[@"aps"][@"content-available"] isEqualToNumber:@(1)]) {// content-available 当用户开启后台推送是,防止触发两次事件
return;
}
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]];
} }
-(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{