mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2026-01-28 00:00:03 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83b7ca162a | ||
|
|
7f2179fe32 | ||
|
|
4f0c186bc3 | ||
|
|
1954d6b55b | ||
|
|
261eb44473 | ||
|
|
504fbb0789 | ||
|
|
cbacc7cb83 |
10
README.md
10
README.md
@@ -1,7 +1,7 @@
|
||||
# JPush PhoneGap / Cordova 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)
|
||||
[](http://weibo.com/jpush?refer_flag=1001030101_&is_all=1)
|
||||
|
||||
@@ -11,8 +11,15 @@
|
||||
- 如需要短信验证码功能插件,可关注 [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。
|
||||
|
||||
## Install
|
||||
|
||||
> 注意:
|
||||
>
|
||||
> - 应用的包名一定要和 APP_KEY 对应应用的包名一致,否则极光推送服务无法注册成功。
|
||||
> - 在使用 8 或以上版本的 Xcode 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
|
||||
|
||||
- 通过 Cordova Plugins 安装,要求 Cordova CLI 5.0+:
|
||||
|
||||
```shell
|
||||
@@ -53,7 +60,6 @@ import { JPush } from '@jiguang-ionic/jpush';
|
||||
|
||||
具体可参考 ./ionic/example 中的文件。
|
||||
|
||||
> 在使用 Xcode 8 或以上调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
35
issue_template.md
Normal file
35
issue_template.md
Normal 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
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jpush-phonegap-plugin",
|
||||
"version": "3.2.13",
|
||||
"version": "3.3.1",
|
||||
"description": "JPush for cordova plugin",
|
||||
"cordova": {
|
||||
"id": "jpush-phonegap-plugin",
|
||||
|
||||
23
plugin.xml
23
plugin.xml
@@ -2,7 +2,7 @@
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="jpush-phonegap-plugin"
|
||||
version="3.2.13">
|
||||
version="3.3.0">
|
||||
|
||||
<name>JPush</name>
|
||||
<description>JPush for cordova plugin</description>
|
||||
@@ -161,25 +161,14 @@
|
||||
|
||||
<!-- User defined. For test only 用户自定义的广播接收器 -->
|
||||
<receiver
|
||||
android:name="cn.jiguang.cordova.push.MyReceiver"
|
||||
android:name="cn.jiguang.cordova.push.JPushReceiver"
|
||||
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>
|
||||
<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" />
|
||||
<!-- Required 用户接收SDK消息的intent -->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" />
|
||||
<!-- Required 用户接收SDK通知栏信息的intent -->
|
||||
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" />
|
||||
<!-- Required 用户打开自定义通知栏的intent -->
|
||||
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" />
|
||||
<!-- Optional 用户接受Rich Push Javascript 回调函数的intent -->
|
||||
<action android:name="cn.jpush.android.intent.CONNECTION" />
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
@@ -198,7 +187,7 @@
|
||||
<receiver android:name="cn.jiguang.cordova.push.JPushEventReceiver">
|
||||
<intent-filter>
|
||||
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
|
||||
<category android:name="$PACKAGE_NAME"></category>
|
||||
<category android:name="$PACKAGE_NAME" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
@@ -207,9 +196,9 @@
|
||||
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/libs/jpush-android-3.1.0.jar" target-dir="libs" />
|
||||
<source-file src="src/android/libs/jpush-android-3.1.1.jar" target-dir="libs" />
|
||||
|
||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
<source-file src="src/android/JPushEventReceiver.java" target-dir="src/cn/jiguang/cordova/push" />
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Map;
|
||||
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
|
||||
public class MyReceiver extends BroadcastReceiver {
|
||||
public class JPushReceiver extends BroadcastReceiver {
|
||||
|
||||
private static final List<String> IGNORED_EXTRAS_KEYS =
|
||||
Arrays.asList(
|
||||
@@ -56,17 +56,14 @@ public class MyReceiver extends BroadcastReceiver {
|
||||
|
||||
Intent launch = context.getPackageManager().getLaunchIntentForPackage(
|
||||
context.getPackageName());
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(launch);
|
||||
if (launch != null) {
|
||||
launch.addCategory(Intent.CATEGORY_LAUNCHER);
|
||||
launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
context.startActivity(launch);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
JPushPlugin.notificationTitle = title;
|
||||
|
||||
Binary file not shown.
BIN
src/android/libs/jpush-android-3.1.1.jar
Executable file
BIN
src/android/libs/jpush-android-3.1.1.jar
Executable file
Binary file not shown.
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user