在ios中是否有办法可以获取最后一个徽章编号并将其添加到推送的新徽章编号
ios的代码在这里
- (void)setApplicationIconBadgeNumber:(CDVInvokedUrlCommand *)command {
self.callbackId = command.callbackId;
NSMutableDictionary* options = [command.arguments objectAtIndex:0];
int badge = [[options objectForKey:@"badge"] intValue] ?: 0;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber:badge];
[self successWithMessage:[NSString stringWithFormat:@"app badge count set to %d", badge]];
}
这是.js
// Call this to set the application icon badge
PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) {
if (errorCallback == null) { errorCallback = function() {}}
if (typeof errorCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function");
return
}
if (typeof successCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]);
};