mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-04-08 16:21:32 +08:00
android增加本地通知
This commit is contained in:
parent
5a33f0c6e2
commit
3d74b92952
@ -38,8 +38,16 @@
|
||||
}
|
||||
var initiateUI = function(){
|
||||
|
||||
window.plugins.jPushPlugin.getRegistrationID(onGetRegistradionID);
|
||||
|
||||
try{
|
||||
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
|
||||
//window.plugins.jPushPlugin.stopPush()
|
||||
|
@ -44,7 +44,10 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
"isPushStopped",
|
||||
"setLatestNotificationNum",
|
||||
"setPushTime",
|
||||
"clearAllNotification");
|
||||
"clearAllNotification",
|
||||
"addLocalNotification",
|
||||
"removeLocalNotification",
|
||||
"clearLocalNotifications");
|
||||
|
||||
private ExecutorService threadPool = Executors.newFixedThreadPool(1);
|
||||
private static JPushPlugin instance;
|
||||
@ -373,6 +376,41 @@ public class JPushPlugin extends CordovaPlugin {
|
||||
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() {
|
||||
|
||||
|
@ -223,6 +223,23 @@ JPushPlugin.prototype.setDebugMode = function(mode){
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user