mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-02-20 20:22:50 +08:00
Add Android API.
This commit is contained in:
parent
f8c56b5aa1
commit
cea1eb85fa
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
id="cn.jpush.phonegap.JPushPlugin"
|
||||
id="cordova-plugin-JPush"
|
||||
version="2.2.1">
|
||||
|
||||
<name>JPush Plugin</name>
|
||||
@ -16,8 +16,10 @@
|
||||
<engine name="cordova" version=">=3.0"/>
|
||||
</engines>
|
||||
|
||||
<dependency id="org.apache.cordova.device" url="https://github.com/apache/cordova-plugin-device.git"/>
|
||||
|
||||
<js-module src="www/JPushPlugin.js" name="JPushPlugin">
|
||||
<clobbers target="window.JPush"/>
|
||||
<clobbers target="JPush"/>
|
||||
</js-module>
|
||||
|
||||
<platform name="ios">
|
||||
@ -58,6 +60,8 @@
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<framework src="com.android.support:support-v4:24.0.0" />
|
||||
|
||||
<config-file target="AndroidManifest.xml" parent="/manifest">
|
||||
<!-- Required 一些系统要求的权限,如访问网络等-->
|
||||
<uses-permission android:name="$PACKAGE_NAME.permission.JPUSH_MESSAGE"/>
|
||||
@ -186,7 +190,6 @@
|
||||
<source-file src="src/android/x86/libjpush217.so" target-dir="libs/x86"/>
|
||||
<source-file src="src/android/x86_64/libjpush217.so" target-dir="libs/x86_64"/>
|
||||
|
||||
<!--<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>-->
|
||||
<source-file src="src/android/MyReceiver.java" target-dir="src/cn/jpush/phonegap"/>
|
||||
<source-file src="src/android/JPushPlugin.java" target-dir="src/cn/jpush/phonegap"/>
|
||||
<source-file src="src/android/test_notification_layout.xml" target-dir="res/layout"/>
|
||||
|
@ -2,6 +2,7 @@ package cn.jpush.phonegap;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@ -26,7 +27,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import cn.jpush.android.api.BasicPushNotificationBuilder;
|
||||
import cn.jpush.android.api.CustomPushNotificationBuilder;
|
||||
import cn.jpush.android.api.JPushInterface;
|
||||
import cn.jpush.android.api.TagAliasCallback;
|
||||
import cn.jpush.android.data.JPushLocalNotification;
|
||||
@ -35,6 +35,7 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
private final static List<String> methodList =
|
||||
Arrays.asList(
|
||||
"addLocalNotification",
|
||||
"areNotificationEnabled",
|
||||
"clearAllNotification",
|
||||
"clearLocalNotifications",
|
||||
"clearNotificationById",
|
||||
@ -312,6 +313,18 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
void areNotificationEnabled(JSONArray data, final CallbackContext callback) {
|
||||
NotificationManagerCompat nmc = NotificationManagerCompat.from(
|
||||
cordova.getActivity().getApplicationContext());
|
||||
int isEnabled;
|
||||
if (nmc.areNotificationsEnabled()) {
|
||||
isEnabled = 1;
|
||||
} else {
|
||||
isEnabled = 0;
|
||||
}
|
||||
callback.success(isEnabled);
|
||||
}
|
||||
|
||||
void setLatestNotificationNum(JSONArray data, CallbackContext callbackContext) {
|
||||
int num = -1;
|
||||
try {
|
||||
|
@ -210,9 +210,20 @@ JPushPlugin.prototype.getApplicationIconBadgeNumber = function(callback) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 判断系统设置中是否对本应用启用通知。
|
||||
// iOS: 返回值如果大于 0,代表通知开启;0: 通知关闭。
|
||||
// UIRemoteNotificationTypeNone = 0,
|
||||
// UIRemoteNotificationTypeBadge = 1 << 0,
|
||||
// UIRemoteNotificationTypeSound = 1 << 1,
|
||||
// UIRemoteNotificationTypeAlert = 1 << 2,
|
||||
// UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3,
|
||||
// Android: 返回值 1 代表通知启用、0: 通知关闭。
|
||||
JPushPlugin.prototype.getUserNotificationSettings = function(callback) {
|
||||
if(this.isPlatformIOS()) {
|
||||
this.call_native("getUserNotificationSettings", [], callback);
|
||||
} else if (device.platform == "Android") {
|
||||
this.call_native("areNotificationEnabled", [], callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user