Merge branch 'ionic' into dev

This commit is contained in:
Hevin 2017-12-11 19:06:43 +08:00
commit 3f1fa1e7ba
13 changed files with 266 additions and 6 deletions

30
.gitignore vendored
View File

@ -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

@ -1 +0,0 @@
Subproject commit 148e087db2e678772a09fa83d3cff17c496acbb6

View File

@ -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);
});
}
}

View File

@ -0,0 +1 @@
<ion-nav [root]="rootPage"></ion-nav>

View File

@ -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 {}

View File

@ -0,0 +1,36 @@
<ion-header>
<ion-navbar>
<ion-title>
JPush Ionic Example
</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<ion-list>
<ion-item>
<div>Registration Id: {{registrationId}}</div>
<button ion-button full (click)="getRegistrationID()">Get Registration Id</button>
</ion-item>
<ion-item>
<button ion-button full (click)="setTags()">Set tags - Tag1, Tag2</button>
<button ion-button full (click)="addTags()">Add tags - Tag3, Tag4</button>
<button ion-button full (click)="checkTagBindState()">Check tag bind state - Tag1</button>
<button ion-button full (click)="deleteTags()">Delete tags - Tag4</button>
<button ion-button full (click)="getAllTags()">Get all tags</button>
<button ion-button full (click)="cleanTags()">Clean tags</button>
</ion-item>
<ion-item>
<button ion-button full (click)="setAlias()">Set Alias - TestAlias</button>
<button ion-button full (click)="getAlias()">Get Alias</button>
<button ion-button full (click)="deleteAlias()">Delete Alias</button>
</ion-item>
<ion-item>
<button ion-button full (click)="addLocalNotification()">Trigger local notification after 5 seconds</button>
</ion-item>
</ion-list>
</ion-content>

View File

@ -0,0 +1,3 @@
page-home {
}

View File

@ -0,0 +1,132 @@
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<string> = 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;
}
console.log('Receive notification: ' + content);
}, false);
document.addEventListener('jpush.openNotification', (event: any) => {
var content;
if (this.devicePlatform == 'Android') {
content = event.alert;
} else {
content = event.aps.alert;
}
alert('Open notification: ' + content);
}, 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, 'noti1');
}
}
}

View File

@ -44,7 +44,7 @@ export declare class JPush extends IonicNativePlugin {
resetBadge(): Promise<any>;
setApplicationIconBadgeNumber(badge: number): Promise<any>;
getApplicationIconBadgeNumber(): Promise<any>;
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, notificationId: number, extras?: string): Promise<any>;
addLocalNotificationForIOS(delayTime: number, content: string, badge: number, identifierKey: string, extras?: string): Promise<any>;
deleteLocalNotificationWithIdentifierKeyInIOS(identifierKey: string): Promise<any>;
addDismissActions(actions: Array<object>, categoryId: string): Promise<any>;
addNotificationActions(actions: Array<object>, categoryId: string): Promise<any>;

View File

@ -61,7 +61,7 @@ var JPush = (function (_super) {
JPush.prototype.resetBadge = function () { return; };
JPush.prototype.setApplicationIconBadgeNumber = function (badge) { return; };
JPush.prototype.getApplicationIconBadgeNumber = function () { return; };
JPush.prototype.addLocalNotificationForIOS = function (delayTime, content, badge, notificationId, extras) { 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; };
@ -218,7 +218,7 @@ var JPush = (function (_super) {
__decorate([
Cordova(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, String, Number, Number, String]),
__metadata("design:paramtypes", [Number, String, Number, String, String]),
__metadata("design:returntype", Promise)
], JPush.prototype, "addLocalNotificationForIOS", null);
__decorate([

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"name": "@jiguang-ionic/jpush",
"version": "1.0.0",
"version": "1.0.1",
"description": "JPush support for ionic-native",
"module": "index.js",
"typings": "index.d.ts",