forked from github/jpush-phonegap-plugin
android增加本地通知
This commit is contained in:
parent
5a33f0c6e2
commit
3d74b92952
@ -38,8 +38,16 @@
|
|||||||
}
|
}
|
||||||
var initiateUI = function(){
|
var initiateUI = function(){
|
||||||
|
|
||||||
|
try{
|
||||||
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
||||||
|
// var extras={"name":"json"};
|
||||||
|
// window.plugins.jPushPlugin.addLocalNotification(1,"hh","ln",1111,1000*60,extras);
|
||||||
|
// window.plugins.jPushPlugin.removeLocalNotification(1111);
|
||||||
|
// window.plugins.jPushPlugin.clearLocalNotifications();
|
||||||
|
}
|
||||||
|
catch(exception){
|
||||||
|
console.log(exception);
|
||||||
|
}
|
||||||
|
|
||||||
//test android interface
|
//test android interface
|
||||||
//window.plugins.jPushPlugin.stopPush()
|
//window.plugins.jPushPlugin.stopPush()
|
||||||
|
@ -44,7 +44,10 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
"isPushStopped",
|
"isPushStopped",
|
||||||
"setLatestNotificationNum",
|
"setLatestNotificationNum",
|
||||||
"setPushTime",
|
"setPushTime",
|
||||||
"clearAllNotification");
|
"clearAllNotification",
|
||||||
|
"addLocalNotification",
|
||||||
|
"removeLocalNotification",
|
||||||
|
"clearLocalNotifications");
|
||||||
|
|
||||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||||
private static JPushPlugin instance;
|
private static JPushPlugin instance;
|
||||||
@ -373,6 +376,41 @@ public class JPushPlugin extends CordovaPlugin {
|
|||||||
callbackContext.error("error id");
|
callbackContext.error("error id");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void addLocalNotification(JSONArray data,
|
||||||
|
CallbackContext callbackContext) throws JSONException{
|
||||||
|
//builderId,content,title,notificaitonID,broadcastTime,extras
|
||||||
|
|
||||||
|
int builderId=data.getInt(0);
|
||||||
|
String content =data.getString(1);
|
||||||
|
String title = data.getString(2);
|
||||||
|
int notificationID= data.getInt(3);
|
||||||
|
int broadcastTime=data.getInt(4);
|
||||||
|
JSONObject extras=data.getJSONObject(5);
|
||||||
|
|
||||||
|
JPushLocalNotification ln = new JPushLocalNotification();
|
||||||
|
ln.setBuilderId(builderId);
|
||||||
|
ln.setContent(content);
|
||||||
|
ln.setTitle(title);
|
||||||
|
ln.setNotificationId(notificationID) ;
|
||||||
|
ln.setBroadcastTime(System.currentTimeMillis() + broadcastTime);
|
||||||
|
|
||||||
|
ln.setExtras(extras.toString()) ;
|
||||||
|
JPushInterface.addLocalNotification(this.cordova.getActivity(), ln);
|
||||||
|
|
||||||
|
}
|
||||||
|
void removeLocalNotification(JSONArray data,
|
||||||
|
CallbackContext callbackContext) throws JSONException{
|
||||||
|
|
||||||
|
int notificationID=data.getInt(0);
|
||||||
|
JPushInterface.removeLocalNotification(this.cordova.getActivity(),notificationID);
|
||||||
|
|
||||||
|
}
|
||||||
|
void clearLocalNotifications(JSONArray data,
|
||||||
|
CallbackContext callbackContext){
|
||||||
|
|
||||||
|
JPushInterface.clearLocalNotifications(this.cordova.getActivity());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
|
private final TagAliasCallback mTagWithAliasCallback = new TagAliasCallback() {
|
||||||
|
|
||||||
|
@ -223,6 +223,23 @@ JPushPlugin.prototype.setDebugMode = function(mode){
|
|||||||
this.call_native("setDebugMode",[mode],null);
|
this.call_native("setDebugMode",[mode],null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
JPushPlugin.prototype.addLocalNotification = function(builderId,content,title,notificaitonID,broadcastTime,extras){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[builderId,content,title,notificaitonID,broadcastTime,extras];
|
||||||
|
this.call_native("addLocalNotification",data,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.removeLocalNotification = function(notificationID){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
this.call_native("removeLocalNotification",[notificationID],null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JPushPlugin.prototype.clearLocalNotifications = function(){
|
||||||
|
if(device.platform == "Android") {
|
||||||
|
data=[]
|
||||||
|
this.call_native("clearLocalNotifications",data,null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//iOS single
|
//iOS single
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user