index.ts 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
  2. import { Injectable } from '@angular/core';
  3. export interface TagOptions {
  4. sequence: number;
  5. tags?: Array<string>;
  6. }
  7. export interface AliasOptions {
  8. sequence: number;
  9. alias?: string;
  10. }
  11. @Plugin({
  12. pluginName: 'JPush',
  13. plugin: 'jpush-phonegap-plugin',
  14. pluginRef: 'plugins.jPushPlugin',
  15. repo: 'https://github.com/jpush/jpush-phonegap-plugin',
  16. install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',
  17. installVariables: ['APP_KEY'],
  18. platforms: ['Android', 'iOS']
  19. })
  20. @Injectable()
  21. export class JPush extends IonicNativePlugin {
  22. @Cordova()
  23. init(): Promise<any> { return; }
  24. @Cordova()
  25. setDebugMode(enable: boolean): Promise<any> { return; }
  26. @Cordova()
  27. getRegistrationID(): Promise<any> { return; }
  28. @Cordova()
  29. stopPush(): Promise<any> { return; }
  30. @Cordova()
  31. resumePush(): Promise<any> { return; }
  32. @Cordova()
  33. isPushStopped(): Promise<any> { return; }
  34. @Cordova()
  35. setTags(params: TagOptions): Promise<any> { return; }
  36. @Cordova()
  37. addTags(params: TagOptions): Promise<any> { return; }
  38. @Cordova()
  39. deleteTags(params: TagOptions): Promise<any> { return; }
  40. @Cordova()
  41. cleanTags(params: TagOptions): Promise<any> { return; }
  42. @Cordova()
  43. getAllTags(params: TagOptions): Promise<any> { return; }
  44. /**
  45. * @param params { sequence: number, tag: string }
  46. */
  47. @Cordova()
  48. checkTagBindState(params: object): Promise<any> { return; }
  49. @Cordova()
  50. setAlias(params: AliasOptions): Promise<any> { return; }
  51. @Cordova()
  52. deleteAlias(params: AliasOptions): Promise<any> { return; }
  53. @Cordova()
  54. getAlias(params: AliasOptions): Promise<any> { return; }
  55. /**
  56. * Determinate whether the application notification has been opened.
  57. *
  58. * iOS: 0: closed; >1: opened.
  59. * UIRemoteNotificationTypeNone = 0,
  60. * UIRemoteNotificationTypeBadge = 1 << 0,
  61. * UIRemoteNotificationTypeSound = 1 << 1,
  62. * UIRemoteNotificationTypeAlert = 1 << 2,
  63. * UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
  64. *
  65. * Android: 0: closed; 1: opened.
  66. */
  67. @Cordova()
  68. getUserNotificationSettings(): Promise<any> { return; }
  69. @Cordova()
  70. clearLocalNotifications(): Promise<any> { return; }
  71. // iOS API - start
  72. @Cordova()
  73. setBadge(badge: number): Promise<any> { return; }
  74. @Cordova()
  75. resetBadge(): Promise<any> { return; }
  76. @Cordova()
  77. setApplicationIconBadgeNumber(badge: number): Promise<any> { return; }
  78. @Cordova()
  79. getApplicationIconBadgeNumber(): Promise<any> { return; }
  80. @Cordova()
  81. addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise<any> { return; }
  82. @Cordova()
  83. deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any> { return; }
  84. @Cordova()
  85. addDismissActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
  86. @Cordova()
  87. addNotificationActions(actions: Array<object>, categoryId: string): Promise<any> { return; }
  88. @Cordova()
  89. setLocation(latitude: number, longitude: number): Promise<any> { return; }
  90. @Cordova()
  91. startLogPageView(pageName: string): Promise<any> { return; }
  92. @Cordova()
  93. stopLogPageView(pageName: string): Promise<any> { return; }
  94. @Cordova()
  95. beginLogPageView(pageName: string, duration: number): Promise<any> { return; }
  96. // iOS API - end
  97. // Android API - start
  98. @Cordova()
  99. getConnectionState(): Promise<any> { return; }
  100. @Cordova()
  101. setBasicPushNotificationBuilder(): Promise<any> { return; }
  102. @Cordova()
  103. setCustomPushNotificationBuilder(): Promise<any> { return; }
  104. @Cordova()
  105. clearAllNotification(): Promise<any> { return; }
  106. @Cordova()
  107. clearNotificationById(id: number): Promise<any> { return; }
  108. @Cordova()
  109. setLatestNotificationNum(num: number): Promise<any> { return; }
  110. @Cordova()
  111. addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any> { return; }
  112. @Cordova()
  113. removeLocalNotification(notificationId: number): Promise<any> { return; }
  114. @Cordova()
  115. reportNotificationOpened(msgId: number): Promise<any> { return; }
  116. @Cordova()
  117. requestPermission(): Promise<any> { return; }
  118. @Cordova()
  119. setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any> { return; }
  120. @Cordova()
  121. setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any> { return; }
  122. // Android API - end
  123. }