index.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. sync: true,
  24. platforms: ['iOS', 'Android']
  25. })
  26. init(): void { }
  27. @Cordova({
  28. sync: true,
  29. platforms: ['iOS', 'Android']
  30. })
  31. setDebugMode(enable: boolean): void { }
  32. @Cordova()
  33. getRegistrationID(): Promise<any> { return; }
  34. @Cordova()
  35. stopPush(): Promise<any> { return; }
  36. @Cordova()
  37. resumePush(): Promise<any> { return; }
  38. @Cordova()
  39. isPushStopped(): Promise<any> { return; }
  40. @Cordova()
  41. setTags(params: TagOptions): Promise<any> { return; }
  42. @Cordova()
  43. addTags(params: TagOptions): Promise<any> { return; }
  44. @Cordova()
  45. deleteTags(params: TagOptions): Promise<any> { return; }
  46. @Cordova()
  47. cleanTags(params: TagOptions): Promise<any> { return; }
  48. @Cordova()
  49. getAllTags(params: TagOptions): Promise<any> { return; }
  50. /**
  51. * @param params { sequence: number, tag: string }
  52. */
  53. @Cordova()
  54. checkTagBindState(params: object): Promise<any> { return; }
  55. @Cordova()
  56. setAlias(params: AliasOptions): Promise<any> { return; }
  57. @Cordova()
  58. deleteAlias(params: AliasOptions): Promise<any> { return; }
  59. @Cordova()
  60. getAlias(params: AliasOptions): Promise<any> { return; }
  61. /**
  62. * Determinate whether the application notification has been opened.
  63. *
  64. * iOS: 0: closed; >1: opened.
  65. * UIRemoteNotificationTypeNone = 0,
  66. * UIRemoteNotificationTypeBadge = 1 << 0,
  67. * UIRemoteNotificationTypeSound = 1 << 1,
  68. * UIRemoteNotificationTypeAlert = 1 << 2,
  69. * UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3
  70. *
  71. * Android: 0: closed; 1: opened.
  72. */
  73. @Cordova()
  74. getUserNotificationSettings(): Promise<any> { return; }
  75. @Cordova()
  76. clearLocalNotifications(): Promise<any> { return; }
  77. // iOS API - start
  78. @Cordova({
  79. sync: true,
  80. platforms: ['iOS']
  81. })
  82. setBadge(badge: number): void { }
  83. @Cordova({
  84. sync: true,
  85. platforms: ['iOS']
  86. })
  87. resetBadge(): void { }
  88. @Cordova({
  89. sync: true,
  90. platforms: ['iOS']
  91. })
  92. setApplicationIconBadgeNumber(badge: number): void { }
  93. @Cordova()
  94. getApplicationIconBadgeNumber(): Promise<any> { return; }
  95. @Cordova({
  96. sync: true,
  97. platforms: ['iOS']
  98. })
  99. addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): void { }
  100. @Cordova({
  101. sync: true,
  102. platforms: ['iOS']
  103. })
  104. deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): void { }
  105. @Cordova({
  106. sync: true,
  107. platforms: ['iOS']
  108. })
  109. addDismissActions(actions: Array<object>, categoryId: string): void { }
  110. @Cordova({
  111. sync: true,
  112. platforms: ['iOS']
  113. })
  114. addNotificationActions(actions: Array<object>, categoryId: string): void { }
  115. @Cordova({
  116. sync: true,
  117. platforms: ['iOS']
  118. })
  119. setLocation(latitude: number, longitude: number): void { }
  120. @Cordova({
  121. sync: true,
  122. platforms: ['iOS']
  123. })
  124. startLogPageView(pageName: string): void { return; }
  125. @Cordova({
  126. sync: true,
  127. platforms: ['iOS']
  128. })
  129. stopLogPageView(pageName: string): void { return; }
  130. @Cordova({
  131. sync: true,
  132. platforms: ['iOS']
  133. })
  134. beginLogPageView(pageName: string, duration: number): void { return; }
  135. // iOS API - end
  136. // Android API - start
  137. @Cordova()
  138. getConnectionState(): Promise<any> { return; }
  139. @Cordova()
  140. setBasicPushNotificationBuilder(): Promise<any> { return; }
  141. @Cordova()
  142. setCustomPushNotificationBuilder(): Promise<any> { return; }
  143. @Cordova()
  144. clearAllNotification(): Promise<any> { return; }
  145. @Cordova()
  146. clearNotificationById(id: number): Promise<any> { return; }
  147. @Cordova()
  148. setLatestNotificationNum(num: number): Promise<any> { return; }
  149. @Cordova()
  150. addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise<any> { return; }
  151. @Cordova()
  152. removeLocalNotification(notificationId: number): Promise<any> { return; }
  153. @Cordova()
  154. reportNotificationOpened(msgId: number): Promise<any> { return; }
  155. @Cordova()
  156. requestPermission(): Promise<any> { return; }
  157. @Cordova()
  158. setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise<any> { return; }
  159. @Cordova()
  160. setPushTime(weekdays: Array<string>, startHour: number, endHour: number): Promise<any> { return; }
  161. // Android API - end
  162. }