diff --git a/.gitignore b/.gitignore index d912879..bc5ffa0 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,34 @@ Network Trash Folder Temporary Items .apdisk +# Ionic example +ionic/example/.sourcemaps/* +ionic/example/node_modules/* +ionic/example/plugins/* +ionic/example/config.xml +ionic/example/ionic.config.json +ionic/example/package-lock.json +ionic/example/package.json +ionic/example/tsconfig.json +ionic/example/tslint.json +ionic/example/resources/README\.md +ionic/example/www/* +ionic/example/src/assets/* +ionic/example/src/theme +ionic/example/platforms + +ionic/example/src/manifest\.json + +ionic/example/resources/android/splash/ + +ionic/example/resources/ + +ionic/example/src/service-worker\.js + +ionic/example/src/index\.html + +ionic/example/src/app/app\.scss + +ionic/example/src/app/main\.ts + # End of https://www.gitignore.io/api/macos,apachecordova diff --git a/README.md b/README.md index 63cc890..7f99134 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,28 @@ cordova plugin add Your_Plugin_Path --variable APP_KEY=your_jpush_appkey ``` +### Ionic + +如果使用了 Ionic,可以再安装 @jiguang-ionic/jpush 包,适配 ionic-native: + +```shell +npm install --save @jiguang-ionic/jpush +``` + +然后在 *app.module.ts* 中增加: + +```js +import { JPush } from '@jiguang-ionic/jpush'; +... + providers: [ + ... + JPush, + ... + ] +``` + +具体可参考 ./ionic/example 中的文件。 + > 在使用 Xcode 8 调试 iOS 项目时,需要先在项目配置界面的 Capabilities 中打开 Push Notifications 开关。 ## Usage diff --git a/doc/iOS_API.md b/doc/iOS_API.md index 8c79704..1650521 100644 --- a/doc/iOS_API.md +++ b/doc/iOS_API.md @@ -143,7 +143,7 @@ window.JPush.getRegistrationID(function(data) { #### event - jpush.openNotification -点击通知启动或唤醒应用程序时会触发该事件 +点击通知(包括 localNotification 和 remoteNotification)启动或唤醒应用程序时会触发该事件 #### 代码示例 @@ -379,7 +379,7 @@ window.JPush.addLocalNotificationForIOS(delayTime, content, badge, notificationI #### 参数说明 -- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可。 +- delayTime: 本地推送延迟多长时间后显示,数值类型或纯数字的字符型均可,单位为秒。 - content: 本地推送需要显示的内容。 - badge: 角标的数字。如果不需要改变角标传-1。数值类型或纯数字的字符型均可。 - notificationID: 本地推送标识符,字符串。 @@ -433,6 +433,34 @@ window.JPush.clearAllLocalNotifications() 监听 `jpush.receiveLocalNotification` 事件获取,「App 在后台时点击通知横幅」或「App 在前台时收到」均会触发该事件。 +#### 代码示例 + +- 在你需要接收通知的的 js 文件中加入: + +```js +document.addEventListener("jpush.receiveLocalNotification", onLocalNotification, false) +``` + +- onLocalNotification 需要这样写: + +```js +var onLocalNotification = function(event) { + alert("receive Local Notification:" + JSON.stringify(event)) +} +``` + +- event 举例 + +```json +{ + badge = 1; + content = "Hello JPush"; + extras = { + "__JPUSHNotificationKey" = notificationIdentify_1; + }; +} +``` + ### iOS 10 收到本地通知 监听 [jpush.receiveNotification](#前台收到推送)、[jpush.openNotification](点击推送通知),获取推送内容后,通过获取到的 `__JPUSHNotificationKey` 字段([本地通知](#本地通知) 设置的 `notificationID`)来判断是本地通知,并处理。 diff --git a/example/js/.DS_Store b/example/js/.DS_Store deleted file mode 100644 index 924b172..0000000 Binary files a/example/js/.DS_Store and /dev/null differ diff --git a/ionic/example/src/app/app.component.ts b/ionic/example/src/app/app.component.ts new file mode 100644 index 0000000..5283370 --- /dev/null +++ b/ionic/example/src/app/app.component.ts @@ -0,0 +1,25 @@ +import { Component } from '@angular/core'; +import { Platform } from 'ionic-angular'; +import { StatusBar } from '@ionic-native/status-bar'; +import { SplashScreen } from '@ionic-native/splash-screen'; +import { JPush } from '@jiguang-ionic/jpush'; + +import { HomePage } from '../pages/home/home'; +@Component({ + templateUrl: 'app.html' +}) +export class MyApp { + rootPage:any = HomePage; + + constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, jpush: JPush) { + platform.ready().then(() => { + // Okay, so the platform is ready and our plugins are available. + // Here you can do any higher level native things you might need. + statusBar.styleDefault(); + splashScreen.hide(); + + jpush.init(); + jpush.setDebugMode(true); + }); + } +} diff --git a/ionic/example/src/app/app.html b/ionic/example/src/app/app.html new file mode 100644 index 0000000..7b88c96 --- /dev/null +++ b/ionic/example/src/app/app.html @@ -0,0 +1 @@ + diff --git a/ionic/example/src/app/app.module.ts b/ionic/example/src/app/app.module.ts new file mode 100644 index 0000000..ce364d8 --- /dev/null +++ b/ionic/example/src/app/app.module.ts @@ -0,0 +1,34 @@ +import { BrowserModule } from '@angular/platform-browser'; +import { ErrorHandler, NgModule } from '@angular/core'; +import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; +import { SplashScreen } from '@ionic-native/splash-screen'; +import { StatusBar } from '@ionic-native/status-bar'; +import { Device } from '@ionic-native/device'; +import { JPush } from '@jiguang-ionic/jpush'; + +import { MyApp } from './app.component'; +import { HomePage } from '../pages/home/home'; + +@NgModule({ + declarations: [ + MyApp, + HomePage + ], + imports: [ + BrowserModule, + IonicModule.forRoot(MyApp) + ], + bootstrap: [IonicApp], + entryComponents: [ + MyApp, + HomePage + ], + providers: [ + StatusBar, + SplashScreen, + Device, + JPush, + {provide: ErrorHandler, useClass: IonicErrorHandler} + ] +}) +export class AppModule {} diff --git a/ionic/example/src/pages/home/home.html b/ionic/example/src/pages/home/home.html new file mode 100644 index 0000000..6219446 --- /dev/null +++ b/ionic/example/src/pages/home/home.html @@ -0,0 +1,36 @@ + + + + JPush Ionic Example + + + + + + + + + Registration Id: {{registrationId}} + Get Registration Id + + + + Set tags - Tag1, Tag2 + Add tags - Tag3, Tag4 + Check tag bind state - Tag1 + Delete tags - Tag4 + Get all tags + Clean tags + + + + Set Alias - TestAlias + Get Alias + Delete Alias + + + + Trigger local notification after 5 seconds + + + diff --git a/ionic/example/src/pages/home/home.scss b/ionic/example/src/pages/home/home.scss new file mode 100644 index 0000000..d4cc8fc --- /dev/null +++ b/ionic/example/src/pages/home/home.scss @@ -0,0 +1,3 @@ +page-home { + +} diff --git a/ionic/example/src/pages/home/home.ts b/ionic/example/src/pages/home/home.ts new file mode 100644 index 0000000..dba5e08 --- /dev/null +++ b/ionic/example/src/pages/home/home.ts @@ -0,0 +1,146 @@ +import { Component } from '@angular/core'; +import { NavController } from 'ionic-angular'; +import { JPush } from '@jiguang-ionic/jpush'; +import { Device } from '@ionic-native/device'; + +@Component({ + selector: 'page-home', + templateUrl: 'home.html' +}) +export class HomePage { + + public registrationId: string; + + devicePlatform: string; + sequence: number = 0; + + tagResultHandler = function(result) { + var sequence: number = result.sequence; + var tags: Array = result.tags == null ? [] : result.tags; + alert('Success!' + '\nSequence: ' + sequence + '\nTags: ' + tags.toString()); + }; + + aliasResultHandler = function(result) { + var sequence: number = result.sequence; + var alias: string = result.alias; + alert('Success!' + '\nSequence: ' + sequence + '\nAlias: ' + alias); + }; + + errorHandler = function(err) { + var sequence: number = err.sequence; + var code = err.code; + alert('Error!' + '\nSequence: ' + sequence + '\nCode: ' + code); + }; + + constructor(public navCtrl: NavController, public jpush: JPush, device: Device) { + + this.devicePlatform = device.platform; + + document.addEventListener('jpush.receiveNotification', (event: any) => { + var content; + if (this.devicePlatform == 'Android') { + content = event.alert; + } else { + content = event.aps.alert; + } + alert('Receive notification: ' + JSON.stringify(event)); + }, false); + + document.addEventListener('jpush.openNotification', (event: any) => { + var content; + if (this.devicePlatform == 'Android') { + content = event.alert; + } else { // iOS + if (event.aps == undefined) { // 本地通知 + content = event.content; + } else { // APNS + content = event.aps.alert; + } + } + alert('open notification: ' + JSON.stringify(event)); + }, false); + + document.addEventListener('jpush.receiveLocalNotification', (event: any) => { + // iOS(*,9) Only , iOS(10,*) 将在 jpush.openNotification 和 jpush.receiveNotification 中触发。 + var content; + if (this.devicePlatform == 'Android') { + } else { + content = event.content; + } + alert('receive local notification: ' + JSON.stringify(event)); + }, false); + } + + getRegistrationID() { + this.jpush.getRegistrationID() + .then(rId => { + this.registrationId = rId; + }); + } + + setTags() { + this.jpush.setTags({ sequence: this.sequence++, tags: ['Tag1', 'Tag2']}) + .then(this.tagResultHandler) + .catch(this.errorHandler); + } + + addTags() { + this.jpush.addTags({ sequence: this.sequence++, tags: ['Tag3', 'Tag4']}) + .then(this.tagResultHandler) + .catch(this.errorHandler); + } + + checkTagBindState() { + this.jpush.checkTagBindState({ sequence: this.sequence++, tag: 'Tag1' }) + .then(result => { + var sequence = result.sequence; + var tag = result.tag; + var isBind = result.isBind; + alert('Sequence: ' + sequence + '\nTag: ' + tag + '\nIsBind: ' + isBind); + }).catch(this.errorHandler); + } + + deleteTags() { + this.jpush.deleteTags({ sequence: this.sequence++, tags: ['Tag4']}) + .then(this.tagResultHandler) + .catch(this.errorHandler); + } + + getAllTags() { + this.jpush.getAllTags({ sequence: this.sequence++ }) + .then(this.tagResultHandler) + .catch(this.errorHandler); + } + + cleanTags() { + this.jpush.cleanTags({ sequence: this.sequence++ }) + .then(this.tagResultHandler) + .catch(this.errorHandler); + } + + setAlias() { + this.jpush.setAlias({ sequence: this.sequence++, alias: 'TestAlias' }) + .then(this.aliasResultHandler) + .catch(this.errorHandler); + } + + getAlias() { + this.jpush.getAlias({ sequence: this.sequence++ }) + .then(this.aliasResultHandler) + .catch(this.errorHandler); + } + + deleteAlias() { + this.jpush.deleteAlias({ sequence: this.sequence++ }) + .then(this.aliasResultHandler) + .catch(this.errorHandler); + } + + addLocalNotification() { + if (this.devicePlatform == 'Android') { + this.jpush.addLocalNotification(0, 'Hello JPush', 'JPush', 1, 5000); + } else { + this.jpush.addLocalNotificationForIOS(5, 'Hello JPush', 1, 'localNoti1'); + } + } +} diff --git a/ionic/index.ts b/ionic/index.ts new file mode 100644 index 0000000..6753d17 --- /dev/null +++ b/ionic/index.ts @@ -0,0 +1,171 @@ +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +export interface TagOptions { + sequence: number; + tags?: Array; +} + +export interface AliasOptions { + sequence: number; + alias?: string; +} + +@Plugin({ + pluginName: 'JPush', + plugin: 'jpush-phonegap-plugin', + pluginRef: 'plugins.jPushPlugin', + 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 { + + @Cordova() + init(): Promise { return; } + + @Cordova() + setDebugMode(enable: boolean): Promise { return; } + + @Cordova() + getRegistrationID(): Promise { return; } + + @Cordova() + stopPush(): Promise { return; } + + @Cordova() + resumePush(): Promise { return; } + + @Cordova() + isPushStopped(): Promise { return; } + + @Cordova() + setTags(params: TagOptions): Promise { return; } + + @Cordova() + addTags(params: TagOptions): Promise { return; } + + @Cordova() + deleteTags(params: TagOptions): Promise { return; } + + @Cordova() + cleanTags(params: TagOptions): Promise { return; } + + @Cordova() + getAllTags(params: TagOptions): Promise { return; } + + /** + * @param params { sequence: number, tag: string } + */ + @Cordova() + checkTagBindState(params: object): Promise { return; } + + @Cordova() + setAlias(params: AliasOptions): Promise { return; } + + @Cordova() + deleteAlias(params: AliasOptions): Promise { return; } + + @Cordova() + getAlias(params: AliasOptions): Promise { return; } + + /** + * 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. + */ + @Cordova() + getUserNotificationSettings(): Promise { return; } + + @Cordova() + clearLocalNotifications(): Promise { return; } + + // iOS API - start + + @Cordova() + setBadge(badge: number): Promise { return; } + + @Cordova() + resetBadge(): Promise { return; } + + @Cordova() + setApplicationIconBadgeNumber(badge: number): Promise { return; } + + @Cordova() + getApplicationIconBadgeNumber(): Promise { return; } + + @Cordova() + addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise { return; } + + @Cordova() + deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise { return; } + + @Cordova() + addDismissActions(actions: Array, categoryId: string): Promise { return; } + + @Cordova() + addNotificationActions(actions: Array, categoryId: string): Promise { return; } + + @Cordova() + setLocation(latitude: number, longitude: number): Promise { return; } + + @Cordova() + startLogPageView(pageName: string): Promise { return; } + + @Cordova() + stopLogPageView(pageName: string): Promise { return; } + + @Cordova() + beginLogPageView(pageName: string, duration: number): Promise { return; } + + // iOS API - end + + // Android API - start + + @Cordova() + getConnectionState(): Promise { return; } + + @Cordova() + setBasicPushNotificationBuilder(): Promise { return; } + + @Cordova() + setCustomPushNotificationBuilder(): Promise { return; } + + @Cordova() + clearAllNotification(): Promise { return; } + + @Cordova() + clearNotificationById(id: number): Promise { return; } + + @Cordova() + setLatestNotificationNum(num: number): Promise { return; } + + @Cordova() + addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise { return; } + + @Cordova() + removeLocalNotification(notificationId: number): Promise { return; } + + @Cordova() + reportNotificationOpened(msgId: number): Promise { return; } + + @Cordova() + requestPermission(): Promise { return; } + + @Cordova() + setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise { return; } + + @Cordova() + setPushTime(weekdays: Array, startHour: number, endHour: number): Promise { return; } + + // Android API - end +} diff --git a/ionic/jpush/index.d.ts b/ionic/jpush/index.d.ts new file mode 100644 index 0000000..0046106 --- /dev/null +++ b/ionic/jpush/index.d.ts @@ -0,0 +1,67 @@ +import { IonicNativePlugin } from '@ionic-native/core'; +export interface TagOptions { + sequence: number; + tags?: Array; +} +export interface AliasOptions { + sequence: number; + alias?: string; +} +export declare class JPush extends IonicNativePlugin { + init(): Promise; + setDebugMode(enable: boolean): Promise; + getRegistrationID(): Promise; + stopPush(): Promise; + resumePush(): Promise; + isPushStopped(): Promise; + setTags(params: TagOptions): Promise; + addTags(params: TagOptions): Promise; + deleteTags(params: TagOptions): Promise; + cleanTags(params: TagOptions): Promise; + getAllTags(params: TagOptions): Promise; + /** + * @param params { sequence: number, tag: string } + */ + checkTagBindState(params: object): Promise; + setAlias(params: AliasOptions): Promise; + deleteAlias(params: AliasOptions): Promise; + getAlias(params: AliasOptions): Promise; + /** + * 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. + */ + getUserNotificationSettings(): Promise; + clearLocalNotifications(): Promise; + setBadge(badge: number): Promise; + resetBadge(): Promise; + setApplicationIconBadgeNumber(badge: number): Promise; + getApplicationIconBadgeNumber(): Promise; + addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise; + deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise; + addDismissActions(actions: Array, categoryId: string): Promise; + addNotificationActions(actions: Array, categoryId: string): Promise; + setLocation(latitude: number, longitude: number): Promise; + startLogPageView(pageName: string): Promise; + stopLogPageView(pageName: string): Promise; + beginLogPageView(pageName: string, duration: number): Promise; + getConnectionState(): Promise; + setBasicPushNotificationBuilder(): Promise; + setCustomPushNotificationBuilder(): Promise; + clearAllNotification(): Promise; + clearNotificationById(id: number): Promise; + setLatestNotificationNum(num: number): Promise; + addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise; + removeLocalNotification(notificationId: number): Promise; + reportNotificationOpened(msgId: number): Promise; + requestPermission(): Promise; + setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise; + setPushTime(weekdays: Array, startHour: number, endHour: number): Promise; +} diff --git a/ionic/jpush/index.js b/ionic/jpush/index.js new file mode 100644 index 0000000..52e5b2b --- /dev/null +++ b/ionic/jpush/index.js @@ -0,0 +1,352 @@ +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __metadata = (this && this.__metadata) || function (k, v) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); +}; +import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; +var JPush = (function (_super) { + __extends(JPush, _super); + function JPush() { + return _super !== null && _super.apply(this, arguments) || this; + } + JPush.prototype.init = function () { return; }; + JPush.prototype.setDebugMode = function (enable) { return; }; + JPush.prototype.getRegistrationID = function () { return; }; + JPush.prototype.stopPush = function () { return; }; + JPush.prototype.resumePush = function () { return; }; + JPush.prototype.isPushStopped = function () { return; }; + JPush.prototype.setTags = function (params) { return; }; + JPush.prototype.addTags = function (params) { return; }; + JPush.prototype.deleteTags = function (params) { return; }; + JPush.prototype.cleanTags = function (params) { return; }; + JPush.prototype.getAllTags = function (params) { return; }; + /** + * @param params { sequence: number, tag: string } + */ + JPush.prototype.checkTagBindState = function (params) { return; }; + JPush.prototype.setAlias = function (params) { return; }; + JPush.prototype.deleteAlias = function (params) { return; }; + JPush.prototype.getAlias = function (params) { return; }; + /** + * 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. + */ + JPush.prototype.getUserNotificationSettings = function () { return; }; + JPush.prototype.clearLocalNotifications = function () { return; }; + // iOS API - start + JPush.prototype.setBadge = function (badge) { return; }; + JPush.prototype.resetBadge = function () { return; }; + JPush.prototype.setApplicationIconBadgeNumber = function (badge) { return; }; + JPush.prototype.getApplicationIconBadgeNumber = function () { return; }; + JPush.prototype.addLocalNotificationForIOS = function (delayTime, content, badge, identifierKey, extras) { return; }; + JPush.prototype.deleteLocalNotificationWithIdentifierKeyInIOS = function (identifierKey) { return; }; + JPush.prototype.addDismissActions = function (actions, categoryId) { return; }; + JPush.prototype.addNotificationActions = function (actions, categoryId) { return; }; + JPush.prototype.setLocation = function (latitude, longitude) { return; }; + JPush.prototype.startLogPageView = function (pageName) { return; }; + JPush.prototype.stopLogPageView = function (pageName) { return; }; + JPush.prototype.beginLogPageView = function (pageName, duration) { return; }; + // iOS API - end + // Android API - start + JPush.prototype.getConnectionState = function () { return; }; + JPush.prototype.setBasicPushNotificationBuilder = function () { return; }; + JPush.prototype.setCustomPushNotificationBuilder = function () { return; }; + JPush.prototype.clearAllNotification = function () { return; }; + JPush.prototype.clearNotificationById = function (id) { return; }; + JPush.prototype.setLatestNotificationNum = function (num) { return; }; + JPush.prototype.addLocalNotification = function (builderId, content, title, notificationId, broadcastTime, extras) { return; }; + JPush.prototype.removeLocalNotification = function (notificationId) { return; }; + JPush.prototype.reportNotificationOpened = function (msgId) { return; }; + JPush.prototype.requestPermission = function () { return; }; + JPush.prototype.setSilenceTime = function (startHour, startMinute, endHour, endMinute) { return; }; + JPush.prototype.setPushTime = function (weekdays, startHour, endHour) { return; }; + // Android API - end + JPush.decorators = [ + { type: Injectable }, + ]; + /** @nocollapse */ + JPush.ctorParameters = function () { return []; }; + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "init", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Boolean]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setDebugMode", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getRegistrationID", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "stopPush", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "resumePush", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "isPushStopped", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setTags", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "addTags", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "deleteTags", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "cleanTags", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getAllTags", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "checkTagBindState", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setAlias", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "deleteAlias", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getAlias", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getUserNotificationSettings", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "clearLocalNotifications", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setBadge", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "resetBadge", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setApplicationIconBadgeNumber", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getApplicationIconBadgeNumber", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number, String, Number, String, Object]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "addLocalNotificationForIOS", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "deleteLocalNotificationWithIdentifierKeyInIOS", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Array, String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "addDismissActions", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Array, String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "addNotificationActions", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number, Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setLocation", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "startLogPageView", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "stopLogPageView", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [String, Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "beginLogPageView", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "getConnectionState", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setBasicPushNotificationBuilder", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setCustomPushNotificationBuilder", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "clearAllNotification", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "clearNotificationById", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setLatestNotificationNum", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number, String, String, Number, Number, String]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "addLocalNotification", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "removeLocalNotification", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "reportNotificationOpened", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", []), + __metadata("design:returntype", Promise) + ], JPush.prototype, "requestPermission", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Number, Number, Number, Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setSilenceTime", null); + __decorate([ + Cordova(), + __metadata("design:type", Function), + __metadata("design:paramtypes", [Array, Number, Number]), + __metadata("design:returntype", Promise) + ], JPush.prototype, "setPushTime", null); + JPush = __decorate([ + Plugin({ + pluginName: 'JPush', + plugin: 'jpush-phonegap-plugin', + pluginRef: 'plugins.jPushPlugin', + 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'] + }) + ], JPush); + return JPush; +}(IonicNativePlugin)); +export { JPush }; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/ionic/jpush/index.js.map b/ionic/jpush/index.js.map new file mode 100644 index 0000000..c731ef5 --- /dev/null +++ b/ionic/jpush/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../../../src/@ionic-native/plugins/jpush/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAA,EAAQ,OAAA,EAAS,iBAAA,EAAkB,MAAO,oBAAA,CAAqB;AACxE,OAAO,EAAE,UAAA,EAAW,MAAO,eAAA,CAAgB;AAsB3C;IAA2B,yBAAiB;IAA5C;;IAyJA,CAAC;IAtJC,oBAAI,GAAJ,cAAuB,MAAM,CAAC,CAAC,CAAC;IAGhC,4BAAY,GAAZ,UAAa,MAAe,IAAkB,MAAM,CAAC,CA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C,OAAO,EAAE;;;;8EACoF;IAG9F;QADC,OAAO,EAAE;;yCACiB,KAAK;;kDAAuD;IAGvF;QADC,OAAO,EAAE;;yCACsB,KAAK;;uDAAuD;IAG5F;QADC,OAAO,EAAE;;;;4CACgE;IAG1E;QADC,OAAO,EAAE;;;;iDACkD;IAG5D;QADC,OAAO,EAAE;;;;gDACiD;IAG3D;QADC,OAAO,EAAE;;;;iDACoE;IAO9E;QADC,OAAO,EAAE;;;;mDACoC;IAG9C;QADC,OAAO,EAAE;;;;gEACiD;IAG3D;QADC,OAAO,EAAE;;;;iEACkD;IAG5D;QADC,OAAO,EAAE;;;;qDACsC;IAGhD;QADC,OAAO,EAAE;;;;sDACiD;IAG3D;QADC,OAAO,EAAE;;;;yDACqD;IAG/D;QADC,OAAO,EAAE;;;;qDACuJ;IAGjK;QADC,OAAO,EAAE;;;;wDAC+D;IAGzE;QADC,OAAO,EAAE;;;;yDACuD;IAGjE;QADC,OAAO,EAAE;;;;kDACmC;IAG7C;QADC,OAAO,EAAE;;;;+CAC0G;IAGpH;QADC,OAAO,EAAE;;yCACY,KAAK;;4CAAuE;IAhJvF,KAAK;QAVjB,MAAM,CAAC;YACN,UAAU,EAAE,OAAO;YACnB,MAAM,EAAE,uBAAuB;YAC/B,SAAS,EAAE,qBAAqB;YAChC,IAAI,EAAE,gDAAgD;YACtD,OAAO,EAAE,gFAAgF;YACzF,gBAAgB,EAAE,CAAC,SAAS,CAAC;YAC7B,SAAS,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC;SAC9B,CAAC;OAEW,KAAK,CAyJjB;IAAD,YAAC;CAzJD,AAyJC,CAzJ0B,iBAAiB,GAyJ3C;SAzJY,KAAK","file":"index.js","sourceRoot":"","sourcesContent":["import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';\nimport { Injectable } from '@angular/core';\n\nexport interface TagOptions {\n sequence: number;\n tags?: Array;\n}\n\nexport interface AliasOptions {\n sequence: number;\n alias?: string;\n}\n\n@Plugin({\n pluginName: 'JPush',\n plugin: 'jpush-phonegap-plugin',\n pluginRef: 'plugins.jPushPlugin',\n repo: 'https://github.com/jpush/jpush-phonegap-plugin',\n install: 'ionic cordova plugin add jpush-phonegap-plugin --variable APP_KEY=your_app_key',\n installVariables: ['APP_KEY'],\n platforms: ['Android', 'iOS']\n})\n\nexport class JPush extends IonicNativePlugin {\n\n @Cordova()\n init(): Promise { return; }\n\n @Cordova()\n setDebugMode(enable: boolean): Promise { return; }\n\n @Cordova()\n getRegistrationID(): Promise { return; }\n\n @Cordova()\n stopPush(): Promise { return; }\n\n @Cordova()\n resumePush(): Promise { return; }\n\n @Cordova()\n isPushStopped(): Promise { return; }\n\n @Cordova()\n setTags(params: TagOptions): Promise { return; }\n\n @Cordova()\n addTags(params: TagOptions): Promise { return; }\n\n @Cordova()\n deleteTags(params: TagOptions): Promise { return; }\n\n @Cordova()\n cleanTags(params: TagOptions): Promise { return; }\n\n @Cordova()\n getAllTags(params: TagOptions): Promise { return; }\n\n /**\n * @param params { sequence: number, tag: string }\n */\n @Cordova()\n checkTagBindState(params: object): Promise { return; }\n\n @Cordova()\n setAlias(params: AliasOptions): Promise { return; }\n\n @Cordova()\n deleteAlias(params: AliasOptions): Promise { return; }\n\n @Cordova()\n getAlias(params: AliasOptions): Promise { return; }\n\n /**\n * Determinate whether the application notification has been opened.\n * \n * iOS: 0: closed; >1: opened.\n * UIRemoteNotificationTypeNone = 0,\n * UIRemoteNotificationTypeBadge = 1 << 0,\n * UIRemoteNotificationTypeSound = 1 << 1,\n * UIRemoteNotificationTypeAlert = 1 << 2,\n * UIRemoteNotificationTypeNewsstandContentAvailability = 1 << 3\n * \n * Android: 0: closed; 1: opened.\n */\n @Cordova()\n getUserNotificationSettings(): Promise { return; }\n\n @Cordova()\n clearLocalNotifications(): Promise { return; }\n\n // iOS API - start\n\n @Cordova()\n setBadge(badge: number): Promise { return; }\n\n @Cordova()\n resetBadge(): Promise { return; }\n\n @Cordova()\n setApplicationIconBadgeNumber(badge: number): Promise { return; }\n\n @Cordova()\n getApplicationIconBadgeNumber(): Promise { return; }\n\n @Cordova()\n addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: object): Promise { return; }\n\n @Cordova()\n deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise { return; }\n\n @Cordova()\n addDismissActions(actions: Array, categoryId: string): Promise { return; }\n\n @Cordova()\n addNotificationActions(actions: Array, categoryId: string): Promise { return; }\n\n @Cordova()\n setLocation(latitude: number, longitude: number): Promise { return; }\n\n @Cordova()\n startLogPageView(pageName: string): Promise { return; }\n\n @Cordova()\n stopLogPageView(pageName: string): Promise { return; }\n\n @Cordova()\n beginLogPageView(pageName: string, duration: number): Promise { return; }\n\n // iOS API - end\n\n // Android API - start\n\n @Cordova()\n getConnectionState(): Promise { return; }\n\n @Cordova()\n setBasicPushNotificationBuilder(): Promise { return; }\n\n @Cordova()\n setCustomPushNotificationBuilder(): Promise { return; }\n\n @Cordova()\n clearAllNotification(): Promise { return; }\n\n @Cordova()\n clearNotificationById(id: number): Promise { return; }\n\n @Cordova()\n setLatestNotificationNum(num: number): Promise { return; }\n\n @Cordova()\n addLocalNotification(builderId: number, content: string, title: string, notificationId: number, broadcastTime: number, extras?: string): Promise { return; }\n\n @Cordova()\n removeLocalNotification(notificationId: number): Promise { return; }\n\n @Cordova()\n reportNotificationOpened(msgId: number): Promise { return; }\n\n @Cordova()\n requestPermission(): Promise { return; }\n\n @Cordova()\n setSilenceTime(startHour: number, startMinute: number, endHour: number, endMinute: number): Promise { return; }\n\n @Cordova()\n setPushTime(weekdays: Array, startHour: number, endHour: number): Promise { return; }\n\n // Android API - end\nstatic decorators: DecoratorInvocation[] = [\n{ type: Injectable },\n];\n/** @nocollapse */\nstatic ctorParameters: () => ({type: any, decorators?: DecoratorInvocation[]}|null)[] = () => [\n];\n}\n\ninterface DecoratorInvocation {\n type: Function;\n args?: any[];\n}\n"]} \ No newline at end of file diff --git a/ionic/jpush/index.metadata.json b/ionic/jpush/index.metadata.json new file mode 100644 index 0000000..2cc22fa --- /dev/null +++ b/ionic/jpush/index.metadata.json @@ -0,0 +1 @@ +[{"__symbolic":"module","version":3,"metadata":{"TagOptions":{"__symbolic":"interface"},"AliasOptions":{"__symbolic":"interface"},"JPush":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Plugin"},"arguments":[{"pluginName":"JPush","plugin":"jpush-phonegap-plugin","pluginRef":"plugins.jPushPlugin","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"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"init":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setDebugMode":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getRegistrationID":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"stopPush":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"resumePush":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"isPushStopped":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"cleanTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getAllTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"checkTagBindState":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getUserNotificationSettings":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearLocalNotifications":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setBadge":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"resetBadge":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setApplicationIconBadgeNumber":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getApplicationIconBadgeNumber":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addLocalNotificationForIOS":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteLocalNotificationWithIdentifierKeyInIOS":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addDismissActions":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addNotificationActions":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setLocation":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"startLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"stopLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"beginLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getConnectionState":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setBasicPushNotificationBuilder":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setCustomPushNotificationBuilder":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearAllNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearNotificationById":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setLatestNotificationNum":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addLocalNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"removeLocalNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"reportNotificationOpened":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"requestPermission":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setSilenceTime":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setPushTime":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"TagOptions":{"__symbolic":"interface"},"AliasOptions":{"__symbolic":"interface"},"JPush":{"__symbolic":"class","extends":{"__symbolic":"reference","module":"@ionic-native/core","name":"IonicNativePlugin"},"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Plugin"},"arguments":[{"pluginName":"JPush","plugin":"jpush-phonegap-plugin","pluginRef":"plugins.jPushPlugin","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"]}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"init":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setDebugMode":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getRegistrationID":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"stopPush":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"resumePush":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"isPushStopped":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"cleanTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getAllTags":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"checkTagBindState":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getAlias":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getUserNotificationSettings":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearLocalNotifications":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setBadge":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"resetBadge":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setApplicationIconBadgeNumber":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getApplicationIconBadgeNumber":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addLocalNotificationForIOS":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"deleteLocalNotificationWithIdentifierKeyInIOS":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addDismissActions":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addNotificationActions":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setLocation":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"startLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"stopLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"beginLogPageView":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"getConnectionState":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setBasicPushNotificationBuilder":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setCustomPushNotificationBuilder":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearAllNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"clearNotificationById":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setLatestNotificationNum":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"addLocalNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"removeLocalNotification":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"reportNotificationOpened":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"requestPermission":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setSilenceTime":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}],"setPushTime":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@ionic-native/core","name":"Cordova"}}]}]}}}}] \ No newline at end of file diff --git a/ionic/jpush/package.json b/ionic/jpush/package.json new file mode 100644 index 0000000..8894fd3 --- /dev/null +++ b/ionic/jpush/package.json @@ -0,0 +1,18 @@ +{ + "name": "@jiguang-ionic/jpush", + "version": "1.0.2", + "description": "JPush support for ionic-native", + "module": "index.js", + "typings": "index.d.ts", + "author": "hevin", + "license": "MIT", + "peerDependencies": { + "@ionic-native/core": "^4.2.0", + "@angular/core": "*", + "rxjs": "^5.0.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/jpush/jpush-phonegap-plugin" + } +} diff --git a/src/android/JPushEventReceiver.java b/src/android/JPushEventReceiver.java index d69349c..1cc3035 100644 --- a/src/android/JPushEventReceiver.java +++ b/src/android/JPushEventReceiver.java @@ -96,6 +96,7 @@ public class JPushEventReceiver extends JPushMessageReceiver { } catch (JSONException e) { e.printStackTrace(); } + callback.success(resultJson); } else { try { @@ -103,7 +104,6 @@ public class JPushEventReceiver extends JPushMessageReceiver { } catch (JSONException e) { e.printStackTrace(); } - callback.error(resultJson); } diff --git a/src/ios/Plugins/AppDelegate+JPush.m b/src/ios/Plugins/AppDelegate+JPush.m index 301638e..fcc7026 100644 --- a/src/ios/Plugins/AppDelegate+JPush.m +++ b/src/ios/Plugins/AppDelegate+JPush.m @@ -44,7 +44,8 @@ NSDictionary *_launchOptions; if (notification.userInfo) { if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey]) { - [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[notification.userInfo toJsonString]]; + [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification + jsString:[[self jpushFormatAPNSDic: notification.userInfo[UIApplicationLaunchOptionsRemoteNotificationKey]] toJsonString]]; } if ([notification.userInfo valueForKey:UIApplicationLaunchOptionsLocalNotificationKey]) { @@ -82,6 +83,23 @@ NSDictionary *_launchOptions; [JPushPlugin fireDocumentEvent:JPushDocumentEvent_receiveRegistrationId jsString:[event toJsonString]]; } +- (NSMutableDictionary *)jpushFormatAPNSDic:(NSDictionary *)dic { + NSMutableDictionary *extras = @{}.mutableCopy; + for (NSString *key in dic) { + if([key isEqualToString:@"_j_business"] || + [key isEqualToString:@"_j_msgid"] || + [key isEqualToString:@"_j_uid"] || + [key isEqualToString:@"actionIdentifier"] || + [key isEqualToString:@"aps"]) { + continue; + } + extras[key] = dic[key]; + } + NSMutableDictionary *formatDic = dic.mutableCopy; + formatDic[@"extras"] = extras; + return formatDic; +} + -(void)registerForRemoteNotification{ if ([[UIDevice currentDevice].systemVersion floatValue] >= 10.0) { #ifdef NSFoundationVersionNumber_iOS_9_x_Max @@ -130,26 +148,48 @@ NSDictionary *_launchOptions; default: break; } - [JPushPlugin fireDocumentEvent:eventName jsString:[userInfo toJsonString]]; + + [JPushPlugin fireDocumentEvent:eventName jsString:[[self jpushFormatAPNSDic:userInfo] toJsonString]]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(30 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ completionHandler(UIBackgroundFetchResultNewData); }); } -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(NSInteger))completionHandler{ - NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:notification.request.content.userInfo]; - [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]]; - completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); + NSMutableDictionary *userInfo = @[].mutableCopy; + + if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { + userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; + } else { + UNNotificationContent *content = notification.request.content; + userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body, + @"badge": content.badge, + @"extras": content.userInfo + }]; + userInfo[@"identifier"] = notification.request.identifier; + } + + [JPushPlugin fireDocumentEvent:JPushDocumentEvent_ReceiveNotification jsString:[userInfo toJsonString]]; + completionHandler(UNNotificationPresentationOptionBadge|UNNotificationPresentationOptionSound|UNNotificationPresentationOptionAlert); } -(void)jpushNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler{ - NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithDictionary:response.notification.request.content.userInfo]; - @try { - [userInfo setValue:[response valueForKey:@"userText"] forKey:@"userText"]; - } @catch (NSException *exception) { } - [userInfo setValue:response.actionIdentifier forKey:@"actionIdentifier"]; - [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]]; - completionHandler(); + UNNotification *notification = response.notification; + NSMutableDictionary *userInfo = nil; + + if ([notification.request.trigger isKindOfClass:[UNPushNotificationTrigger class]]) { + userInfo = [self jpushFormatAPNSDic:notification.request.content.userInfo]; + } else { + UNNotificationContent *content = notification.request.content; + userInfo = [NSMutableDictionary dictionaryWithDictionary:@{@"content": content.body, + @"badge": content.badge, + @"extras": content.userInfo + }]; + userInfo[@"identifier"] = notification.request.identifier; + } + + [JPushPlugin fireDocumentEvent:JPushDocumentEvent_OpenNotification jsString:[userInfo toJsonString]]; + completionHandler(); } - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { diff --git a/src/ios/Plugins/JPushPlugin.m b/src/ios/Plugins/JPushPlugin.m index 64d3791..3e62c77 100644 --- a/src/ios/Plugins/JPushPlugin.m +++ b/src/ios/Plugins/JPushPlugin.m @@ -241,7 +241,7 @@ CDVPluginResult* result; if (iResCode == 0) { - [dic setObject:[iTags allObjects] forKey:@"tags"]; + dic[@"tag"] = tag; [dic setObject:[NSNumber numberWithBool:isBind] forKey:@"isBind"]; result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dic]; } else {