mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 22:42:51 +08:00
Update Android_detail_api.md & Optimize JPushPlugin.js
This commit is contained in:
parent
3adbc003b0
commit
637624edab
@ -157,6 +157,19 @@
|
|||||||
|
|
||||||
window.plugins.jPushPlugin.clearAllNotification()
|
window.plugins.jPushPlugin.clearAllNotification()
|
||||||
|
|
||||||
|
### API - clearNotificationById
|
||||||
|
根据通知 Id 清除通知(包括本地通知)。
|
||||||
|
|
||||||
|
#### 接口定义
|
||||||
|
|
||||||
|
window.plugins.jPushPlugin.clearNotificationById(notificationId)
|
||||||
|
|
||||||
|
#### 参数说明
|
||||||
|
- notificationId:int,通知的 id。
|
||||||
|
|
||||||
|
#### 代码示例
|
||||||
|
|
||||||
|
window.plugins.jPushPlugin.clearNotificationById(1)
|
||||||
|
|
||||||
## 设置允许推送时间
|
## 设置允许推送时间
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ JPushPlugin.prototype.openNotification = {}
|
|||||||
JPushPlugin.prototype.receiveNotification = {}
|
JPushPlugin.prototype.receiveNotification = {}
|
||||||
|
|
||||||
JPushPlugin.prototype.isPlatformIOS = function () {
|
JPushPlugin.prototype.isPlatformIOS = function () {
|
||||||
var isPlatformIOS = device.platform == 'iPhone'
|
var isPlatformIOS = device.platform == 'iPhone' ||
|
||||||
|| device.platform == 'iPad'
|
device.platform == 'iPad' ||
|
||||||
|| device.platform == 'iPod touch'
|
device.platform == 'iPod touch' ||
|
||||||
|| device.platform == 'iOS'
|
device.platform == 'iOS'
|
||||||
return isPlatformIOS
|
return isPlatformIOS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,41 +26,30 @@ JPushPlugin.prototype.call_native = function (name, args, callback) {
|
|||||||
// public methods
|
// public methods
|
||||||
JPushPlugin.prototype.init = function () {
|
JPushPlugin.prototype.init = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = []
|
this.call_native('initial', [], null)
|
||||||
this.call_native('initial', data, null)
|
|
||||||
} else {
|
} else {
|
||||||
data = []
|
this.call_native('init', [], null)
|
||||||
this.call_native('init', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.getRegistrationID = function (callback) {
|
JPushPlugin.prototype.getRegistrationID = function (callback) {
|
||||||
try {
|
this.call_native('getRegistrationID', [], callback)
|
||||||
var data = []
|
|
||||||
this.call_native('getRegistrationID', [data], callback)
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.stopPush = function () {
|
JPushPlugin.prototype.stopPush = function () {
|
||||||
data = []
|
this.call_native('stopPush', [], null)
|
||||||
this.call_native('stopPush', data, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.resumePush = function () {
|
JPushPlugin.prototype.resumePush = function () {
|
||||||
data = []
|
this.call_native('resumePush', [], null)
|
||||||
this.call_native('resumePush', data, null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.isPushStopped = function (callback) {
|
JPushPlugin.prototype.isPushStopped = function (callback) {
|
||||||
data = []
|
this.call_native('isPushStopped', [], callback)
|
||||||
this.call_native('isPushStopped', data, callback)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// iOS methods
|
// iOS methods
|
||||||
JPushPlugin.prototype.setTagsWithAlias = function (tags, alias) {
|
JPushPlugin.prototype.setTagsWithAlias = function (tags, alias) {
|
||||||
try {
|
|
||||||
if (tags == null) {
|
if (tags == null) {
|
||||||
this.setAlias(alias)
|
this.setAlias(alias)
|
||||||
return
|
return
|
||||||
@ -72,96 +61,68 @@ JPushPlugin.prototype.setTagsWithAlias = function (tags, alias) {
|
|||||||
var arrayTagWithAlias = [tags]
|
var arrayTagWithAlias = [tags]
|
||||||
arrayTagWithAlias.unshift(alias)
|
arrayTagWithAlias.unshift(alias)
|
||||||
this.call_native('setTagsWithAlias', arrayTagWithAlias, null)
|
this.call_native('setTagsWithAlias', arrayTagWithAlias, null)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setTags = function (tags) {
|
JPushPlugin.prototype.setTags = function (tags) {
|
||||||
try {
|
|
||||||
this.call_native('setTags', tags, null)
|
this.call_native('setTags', tags, null)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setAlias = function (alias) {
|
JPushPlugin.prototype.setAlias = function (alias) {
|
||||||
try {
|
|
||||||
this.call_native('setAlias', [alias], null)
|
this.call_native('setAlias', [alias], null)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setBadge = function (value) {
|
JPushPlugin.prototype.setBadge = function (value) {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
try {
|
|
||||||
this.call_native('setBadge', [value], null)
|
this.call_native('setBadge', [value], null)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.resetBadge = function () {
|
JPushPlugin.prototype.resetBadge = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
try {
|
this.call_native('resetBadge', [], null)
|
||||||
var data = []
|
|
||||||
this.call_native('resetBadge', [data], null)
|
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setDebugModeFromIos = function () {
|
JPushPlugin.prototype.setDebugModeFromIos = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = []
|
this.call_native('setDebugModeFromIos', [], null)
|
||||||
this.call_native('setDebugModeFromIos', [data], null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setLogOFF = function () {
|
JPushPlugin.prototype.setLogOFF = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = []
|
this.call_native('setLogOFF', [], null)
|
||||||
this.call_native('setLogOFF', [data], null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setCrashLogON = function () {
|
JPushPlugin.prototype.setCrashLogON = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = []
|
this.call_native('crashLogON', [], null)
|
||||||
this.call_native('crashLogON', [data], null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.addLocalNotificationForIOS = function (delayTime, content,
|
JPushPlugin.prototype.addLocalNotificationForIOS = function (delayTime, content,
|
||||||
badge, notificationID, extras) {
|
badge, notificationID, extras) {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [delayTime, content, badge, notificationID, extras]
|
this.call_native('setLocalNotification', [delayTime, content, badge, notificationID, extras], null)
|
||||||
this.call_native('setLocalNotification', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (
|
JPushPlugin.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (identifierKey) {
|
||||||
identifierKey) {
|
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [identifierKey]
|
this.call_native('deleteLocalNotificationWithIdentifierKey', [identifierKey], null)
|
||||||
this.call_native('deleteLocalNotificationWithIdentifierKey', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearAllLocalNotifications = function () {
|
JPushPlugin.prototype.clearAllLocalNotifications = function () {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = []
|
this.call_native('clearAllLocalNotifications', [], null)
|
||||||
this.call_native('clearAllLocalNotifications', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setLocation = function (latitude, longitude) {
|
JPushPlugin.prototype.setLocation = function (latitude, longitude) {
|
||||||
if (this.isPlatformIOS()) {
|
if (this.isPlatformIOS()) {
|
||||||
var data = [latitude, longitude]
|
this.call_native('setLocation', [latitude, longitude], null)
|
||||||
this.call_native('setLocation', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,61 +189,45 @@ JPushPlugin.prototype.setDebugMode = function (mode) {
|
|||||||
|
|
||||||
JPushPlugin.prototype.setBasicPushNotificationBuilder = function () {
|
JPushPlugin.prototype.setBasicPushNotificationBuilder = function () {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = []
|
this.call_native('setBasicPushNotificationBuilder', [], null)
|
||||||
this.call_native('setBasicPushNotificationBuilder', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.setCustomPushNotificationBuilder = function () {
|
JPushPlugin.prototype.setCustomPushNotificationBuilder = function () {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = []
|
this.call_native('setCustomPushNotificationBuilder', [], null)
|
||||||
this.call_native('setCustomPushNotificationBuilder', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveMessageInAndroidCallback = function (data) {
|
JPushPlugin.prototype.receiveMessageInAndroidCallback = function (data) {
|
||||||
try {
|
|
||||||
data = JSON.stringify(data)
|
data = JSON.stringify(data)
|
||||||
console.log('JPushPlugin:receiveMessageInAndroidCallback: ' + data)
|
console.log('JPushPlugin:receiveMessageInAndroidCallback: ' + data)
|
||||||
this.receiveMessage = JSON.parse(data)
|
this.receiveMessage = JSON.parse(data)
|
||||||
cordova.fireDocumentEvent('jpush.receiveMessage', this.receiveMessage)
|
cordova.fireDocumentEvent('jpush.receiveMessage', this.receiveMessage)
|
||||||
} catch(exception) {
|
|
||||||
console.log('JPushPlugin:pushCallback ' + exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.openNotificationInAndroidCallback = function (data) {
|
JPushPlugin.prototype.openNotificationInAndroidCallback = function (data) {
|
||||||
try {
|
|
||||||
data = JSON.stringify(data)
|
data = JSON.stringify(data)
|
||||||
console.log('JPushPlugin:openNotificationInAndroidCallback: ' + data)
|
console.log('JPushPlugin:openNotificationInAndroidCallback: ' + data)
|
||||||
this.openNotification = JSON.parse(data)
|
this.openNotification = JSON.parse(data)
|
||||||
cordova.fireDocumentEvent('jpush.openNotification', this.openNotification)
|
cordova.fireDocumentEvent('jpush.openNotification', this.openNotification)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function (data) {
|
JPushPlugin.prototype.receiveNotificationInAndroidCallback = function (data) {
|
||||||
try {
|
|
||||||
data = JSON.stringify(data)
|
data = JSON.stringify(data)
|
||||||
console.log('JPushPlugin:receiveNotificationInAndroidCallback: ' + data)
|
console.log('JPushPlugin:receiveNotificationInAndroidCallback: ' + data)
|
||||||
this.receiveNotification = JSON.parse(data)
|
this.receiveNotification = JSON.parse(data)
|
||||||
cordova.fireDocumentEvent('jpush.receiveNotification', this.receiveNotification)
|
cordova.fireDocumentEvent('jpush.receiveNotification', this.receiveNotification)
|
||||||
} catch(exception) {
|
|
||||||
console.log(exception)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearAllNotification = function () {
|
JPushPlugin.prototype.clearAllNotification = function () {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = []
|
this.call_native('clearAllNotification', [], null)
|
||||||
this.call_native('clearAllNotification', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JPushPlugin.prototype.clearNotificationById = function (notificationId) {
|
JPushPlugin.prototype.clearNotificationById = function (notificationId) {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = []
|
|
||||||
this.call_native('clearNotificationById', [notificationId], null)
|
this.call_native('clearNotificationById', [notificationId], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,8 +247,7 @@ JPushPlugin.prototype.setDebugMode = function (mode) {
|
|||||||
JPushPlugin.prototype.addLocalNotification = function (builderId, content, title,
|
JPushPlugin.prototype.addLocalNotification = function (builderId, content, title,
|
||||||
notificationID, broadcastTime, extras) {
|
notificationID, broadcastTime, extras) {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = [builderId, content, title, notificationID, broadcastTime, extras]
|
this.call_native('addLocalNotification', [builderId, content, title, notificationID, broadcastTime, extras], null)
|
||||||
this.call_native('addLocalNotification', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,8 +259,7 @@ JPushPlugin.prototype.removeLocalNotification = function (notificationID) {
|
|||||||
|
|
||||||
JPushPlugin.prototype.clearLocalNotifications = function () {
|
JPushPlugin.prototype.clearLocalNotifications = function () {
|
||||||
if (device.platform == 'Android') {
|
if (device.platform == 'Android') {
|
||||||
data = []
|
this.call_native('clearLocalNotifications', [], null)
|
||||||
this.call_native('clearLocalNotifications', data, null)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user