2017-11-27 20:36:41 +08:00
|
|
|
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
export interface TagOptions {
|
|
|
|
sequence: number;
|
|
|
|
tags?: Array<string>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface AliasOptions {
|
|
|
|
sequence: number;
|
|
|
|
alias?: string;
|
|
|
|
}
|
|
|
|
|
2017-11-27 20:36:41 +08:00
|
|
|
@Plugin({
|
|
|
|
pluginName: 'JPush',
|
|
|
|
plugin: 'jpush-phonegap-plugin',
|
2017-12-08 21:35:42 +08:00
|
|
|
pluginRef: 'plugins.jPushPlugin',
|
2017-11-27 20:36:41 +08:00
|
|
|
repo: 'https://github.com/jpush/jpush-phonegap-plugin',
|
|
|
|
install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
|
|
|
|
installVariables: ['APP_KEY'],
|
|
|
|
platforms: ['Android', 'iOS']
|
|
|
|
})
|
|
|
|
@Injectable()
|
|
|
|
export class JPush extends IonicNativePlugin {
|
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS', 'Android']
|
|
|
|
})
|
|
|
|
init(): void { }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS', 'Android']
|
|
|
|
})
|
|
|
|
setDebugMode(enable: boolean): void { }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
getRegistrationID(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
stopPush(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
resumePush(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
isPushStopped(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
setTags(params: TagOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
addTags(params: TagOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
deleteTags(params: TagOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
cleanTags(params: TagOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
getAllTags(params: TagOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param params { sequence: number, tag: string }
|
|
|
|
*/
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
checkTagBindState(params: object): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
setAlias(params: AliasOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
deleteAlias(params: AliasOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
getAlias(params: AliasOptions): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determinate whether the application notification has been opened.
|
|
|
|
*
|
|
|
|
* iOS: 0: closed; >1: opened.
|
|
|
|
* UIRemoteNotificationTypeNone = 0,
|
|
|
|
* UIRemoteNotificationTypeBadge = 1 << 0,
|
|
|
|
* UIRemoteNotificationTypeSound = 1 << 1,
|
|
|
|
* UIRemoteNotificationTypeAlert = 1 << 2,
|
|
|
|
* UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
|
|
|
|
*
|
|
|
|
* Android: 0: closed; 1: opened.
|
|
|
|
*/
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
getUserNotificationSettings(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
clearLocalNotifications(): Promise<any> { return; }
|
|
|
|
|
|
|
|
// iOS API - start
|
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
setBadge(badge: number): void { }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
resetBadge(): void { }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
setApplicationIconBadgeNumber(badge: number): void { }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
getApplicationIconBadgeNumber(): Promise<any> { return; }
|
|
|
|
|
2019-02-23 23:58:23 +08:00
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): void { }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): void { }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
addDismissActions(actions: Array<object>, categoryId: string): void { }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
addNotificationActions(actions: Array<object>, categoryId: string): void { }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
setLocation(latitude: number, longitude: number): void { }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
startLogPageView(pageName: string): void { return; }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
stopLogPageView(pageName: string): void { return; }
|
|
|
|
|
|
|
|
@Cordova({
|
|
|
|
sync: true,
|
|
|
|
platforms: ['iOS']
|
|
|
|
})
|
|
|
|
beginLogPageView(pageName: string, duration: number): void { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
|
|
|
// iOS API - end
|
|
|
|
|
|
|
|
// Android API - start
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
getConnectionState(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
setBasicPushNotificationBuilder(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
setCustomPushNotificationBuilder(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
clearAllNotification(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
clearNotificationById(id: number): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
setLatestNotificationNum(num: number): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
|
|
|
addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any> { return; }
|
2017-11-27 20:36:41 +08:00
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
removeLocalNotification(notificationId: number): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
reportNotificationOpened(msgId: number): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
requestPermission(): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any> { return; }
|
|
|
|
|
2017-12-07 21:32:48 +08:00
|
|
|
@Cordova()
|
2017-11-27 20:36:41 +08:00
|
|
|
setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any> { return; }
|
|
|
|
|
|
|
|
// Android API - end
|
2017-12-07 21:32:48 +08:00
|
|
|
}
|