Merge pull request #387 from jpush/dev

Dev
This commit is contained in:
JoshLipan 2018-12-20 16:27:34 +08:00 committed by GitHub
commit b2e818e88d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 59 additions and 35 deletions

View File

@ -42,6 +42,27 @@
cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey
```
### 参数
- APP_KEY: 必须设置JPush 上注册的包名对应的 Appkey
```shell
--variable APP_KEY=your_jpush_appkey
```
- CHANNEL: 可以不设置v3.6.0+ 版本开始支持(Android Only),方便开发者统计 APK 分发渠道,默认为 developer-default.
```shell
--variable CHANNEL=your_channel
```
- 同时动态配置 APP_KEY 和 CHANNEL 示例
```shell
cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_jpush_appkey --variable CHANNEL=your_channel
```
### Ionic
如果使用了 Ionic可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native

View File

@ -1,6 +1,6 @@
{
"name": "jpush-phonegap-plugin",
"version": "3.5.0",
"version": "3.6.0",
"description": "JPush for cordova plugin",
"cordova": {
"id": "jpush-phonegap-plugin",

View File

@ -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.5.0">
version="3.6.0">
<name>JPush</name>
<description>JPush for cordova plugin</description>
@ -11,6 +11,7 @@
<license>MIT License</license>
<preference name="APP_KEY" />
<preference name="CHANNEL" default="developer-default" />
<engines>
<engine name="cordova" version=">=3.0" />
@ -212,11 +213,11 @@
<!-- Required. Enable it you can get statistics data with channel -->
<meta-data android:name="JPUSH_CHANNEL" android:value="developer-default" />
<meta-data android:name="JPUSH_CHANNEL" android:value="$CHANNEL" />
<meta-data android:name="JPUSH_APPKEY" android:value="$APP_KEY" />
</config-file>
<lib-file src="src/android/libs/jpush-android-3.1.7.jar" />
<lib-file src="src/android/libs/jpush-android-3.1.8.jar" />
<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" />

View File

@ -1,8 +1,8 @@
package cn.jiguang.cordova.push;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AppOpsManager;
import android.app.NotificationManager;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.Build;
@ -20,22 +20,17 @@ import org.json.JSONObject;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import cn.jpush.android.api.BasicPushNotificationBuilder;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.TagAliasCallback;
import cn.jpush.android.data.JPushLocalNotification;
import cn.jpush.android.service.JPushMessageReceiver;
public class JPushPlugin extends CordovaPlugin {
@ -673,9 +668,14 @@ public class JPushPlugin extends CordovaPlugin {
}
};
@TargetApi(Build.VERSION_CODES.KITKAT)
private boolean hasPermission(String appOpsServiceId) {
Context context = cordova.getActivity().getApplicationContext();
if (Build.VERSION.SDK_INT >= 24) {
NotificationManager mNotificationManager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
return mNotificationManager.areNotificationsEnabled();
} else {
AppOpsManager mAppOps = (AppOpsManager) context.getSystemService(Context.APP_OPS_SERVICE);
ApplicationInfo appInfo = context.getApplicationInfo();
@ -702,6 +702,8 @@ public class JPushPlugin extends CordovaPlugin {
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return true;
}
return false;
}
}

Binary file not shown.