mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-04-19 00:03:45 +08:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1eaf73a8d3 | |||
| 6c2bc206e3 | |||
| 10b457d489 | |||
| 5b0613628b | |||
| 6f77da5f41 | |||
| 24328f2ac9 | |||
| 8ccdbd525b | |||
| 67421b5091 | |||
| 83b7ca162a | |||
| 7f2179fe32 |
@@ -1,7 +1,7 @@
|
|||||||
# JPush PhoneGap / Cordova Plugin
|
# JPush PhoneGap / Cordova Plugin
|
||||||
|
|
||||||
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
[](https://travis-ci.org/jpush/jpush-phonegap-plugin)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
[](https://github.com/jpush/jpush-phonegap-plugin/releases)
|
||||||
[](https://github.com/jpush/jpush-phonegap-plugin)
|
[](https://github.com/jpush/jpush-phonegap-plugin)
|
||||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
[](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
@@ -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
@@ -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>
|
||||||
|
|||||||
@@ -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{
|
||||||
|
|||||||
Reference in New Issue
Block a user