mirror of
https://github.com/jpush/jpush-phonegap-plugin.git
synced 2025-01-31 22:42:51 +08:00
Merge branch 'ionic' into dev
This commit is contained in:
commit
3f1fa1e7ba
30
.gitignore
vendored
30
.gitignore
vendored
@ -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
|
25
ionic/example/src/app/app.component.ts
Normal file
25
ionic/example/src/app/app.component.ts
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
1
ionic/example/src/app/app.html
Normal file
1
ionic/example/src/app/app.html
Normal file
@ -0,0 +1 @@
|
||||
<ion-nav [root]="rootPage"></ion-nav>
|
34
ionic/example/src/app/app.module.ts
Normal file
34
ionic/example/src/app/app.module.ts
Normal 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 {}
|
36
ionic/example/src/pages/home/home.html
Normal file
36
ionic/example/src/pages/home/home.html
Normal 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>
|
3
ionic/example/src/pages/home/home.scss
Normal file
3
ionic/example/src/pages/home/home.scss
Normal file
@ -0,0 +1,3 @@
|
||||
page-home {
|
||||
|
||||
}
|
132
ionic/example/src/pages/home/home.ts
Normal file
132
ionic/example/src/pages/home/home.ts
Normal 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');
|
||||
}
|
||||
}
|
||||
}
|
2
ionic/jpush/index.d.ts
vendored
2
ionic/jpush/index.d.ts
vendored
@ -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>;
|
||||
|
@ -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
@ -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",
|
||||
|
Loading…
Reference in New Issue
Block a user