Compare commits

...

19 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
Hevin 54b653e442 Merge branch 'dev' 2018-01-27 10:27:49 +08:00
Hevin 4f0c186bc3 build: v3.3.0 2018-01-27 09:54:21 +08:00
Hevin 1954d6b55b Update Android SDK to v3.1.1 & Update MyReceiver to JPushReceiver 2018-01-27 09:41:35 +08:00
Hevin 8487d9c823 Merge branch 'dev' 2018-01-17 15:18:36 +08:00
Hevin 261eb44473 Add comment about cordova-android 7.0.0 2018-01-17 15:18:17 +08:00
huangminlinux 7549e347b7 Merge pull request #309 from jpush/dev
add issue template
2017-12-26 10:37:36 +08:00
huangminlinux 504fbb0789 add issue template 2017-12-26 10:37:09 +08:00
Hevin a6fc0bc7a1 Merge branch 'dev' 2017-12-20 13:23:13 +08:00
Hevin cbacc7cb83 Add explain of APP_KEY 2017-12-20 13:22:08 +08:00
8 changed files with 110 additions and 82 deletions
+7 -2
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.13-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,8 +11,14 @@
- 如需要短信验证码功能插件,可关注 [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)
**注意**:插件从 v3.4.0 开始支持 cordova-android 7.0.0,因为 cordova-android 7.0.0 修改了 Android 项目结构,因此不兼容之前的版本,升级前请务必注意。如果需要安装之前版本的插件,请先安装 v1.2.0 以下版本的 cordova-plugin-jcore,再安装插件。
## Install ## Install
> 注意:
> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+ - 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+
```shell ```shell
@@ -53,7 +59,6 @@ import { JPush } from '@jiguang-ionic/jpush';
具体可参考 ./ionic/example 中的文件。 具体可参考 ./ionic/example 中的文件。
> 在使用 Xcode 8 或以上调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
## Usage ## Usage
+35
View File
@@ -0,0 +1,35 @@
**WARNING: 如果不按照这个表格,我们将无法帮助你,并将忽略你的问题。**
## 你的运行环境
* 插件版本:
* 平台(Android / iOS:
* Cordova version (```cordova -v```):
* Cordova platform version (```cordova platform ls```):
* Ionic Version (if using Ionic)
## 期望效果
告诉我们你希望达到什么效果。
## 实际效果
告诉我们实际是什么效果。
## 重现步骤
1. ...
2. ...
3. ...
4. ...
## 背景
你尝试做过些什么?
## Debug logs
包括 Android 或 iOS 的日志:
* iOS: XCode logs
* Android: $ adb logcat / Android Studio logcat
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "jpush-phonegap-plugin", "name": "jpush-phonegap-plugin",
"version": "3.2.13", "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",
+32 -43
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.13"> 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,27 +155,16 @@
</intent-filter> </intent-filter>
</service> </service>
<!-- User defined. For test only 用户自定义的广播接收器 --> <!-- 通知广播接收器 -->
<receiver <receiver
android:name="cn.jiguang.cordova.push.MyReceiver" android:name="cn.jiguang.cordova.push.JPushReceiver"
android:enabled="true"> android:enabled="true">
<intent-filter android:priority="1000">
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED_PROXY" />
<!-- Required 显示通知栏 -->
<category android:name="$PACKAGE_NAME" />
</intent-filter>
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <action android:name="cn.jpush.android.intent.REGISTRATION" />
<!-- Required 用户注册SDK的intent -->
<action android:name="cn.jpush.android.intent.UNREGISTRATION" />
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" />
<!-- Required 用户接收SDK消息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
<!-- Required 用户接收SDK通知栏信息的intent -->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
<!-- Required 用户打开自定义通知栏的intent --> <action android:name="cn.jpush.android.intent.CONNECTION" />
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
<category android:name="$PACKAGE_NAME" /> <category android:name="$PACKAGE_NAME" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@@ -198,7 +183,7 @@
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver"> <receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
<intent-filter> <intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" /> <action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="$PACKAGE_NAME"></category> <category android:name="$PACKAGE_NAME" />
</intent-filter> </intent-filter>
</receiver> </receiver>
@@ -207,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.0.jar" target-dir="libs" /> <lib-file src="src/android/libs/jpush-android-3.1.1.jar" />
<source-file src="src/android/MyReceiver.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>
@@ -11,7 +11,7 @@ import java.util.Map;
import cn.jpush.android.api.JPushInterface; import cn.jpush.android.api.JPushInterface;
public class MyReceiver extends BroadcastReceiver { public class JPushReceiver extends BroadcastReceiver {
private static final List<String> IGNORED_EXTRAS_KEYS = private static final List<String> IGNORED_EXTRAS_KEYS =
Arrays.asList( Arrays.asList(
@@ -56,17 +56,14 @@ public class MyReceiver extends BroadcastReceiver {
Intent launch = context.getPackageManager().getLaunchIntentForPackage( Intent launch = context.getPackageManager().getLaunchIntentForPackage(
context.getPackageName()); context.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER); if (launch != null) {
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); launch.addCategory(Intent.CATEGORY_LAUNCHER);
context.startActivity(launch); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
context.startActivity(launch);
}
} }
private void handlingNotificationReceive(Context context, Intent intent) { private void handlingNotificationReceive(Context context, Intent intent) {
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
context.getPackageName());
launch.addCategory(Intent.CATEGORY_LAUNCHER);
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE); String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
JPushPlugin.notificationTitle = title; JPushPlugin.notificationTitle = title;
Binary file not shown.
Binary file not shown.
+28 -26
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,19 +59,19 @@ NSDictionary *_launchOptions;
[JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[localNotificationEvent toJsonString]]; [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{ -(void)startJPushSDK{
@@ -136,17 +137,12 @@ NSDictionary *_launchOptions;
[JPUSHService handleRemoteNotification:userInfo]; [JPUSHService handleRemoteNotification:userInfo];
NSString *eventName; NSString *eventName;
switch ([UIApplication sharedApplication].applicationState) { switch ([UIApplication sharedApplication].applicationState) {
case UIApplicationStateInactive: case UIApplicationStateBackground:
eventName = JPushDocumentEvent_OpenNotification; eventName = JPushDocumentEvent_BackgroundNotification;
break; break;
case UIApplicationStateActive: default:
eventName = JPushDocumentEvent_ReceiveNotification; eventName = JPushDocumentEvent_ReceiveNotification;
break; break;
case UIApplicationStateBackground:
eventName = JPushDocumentEvent_BackgroundNotification;
break;
default:
break;
} }
[JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]]; [JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]];
@@ -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{