Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(push) add support for version 2.1.0 #2064

Merged
merged 1 commit into from
Dec 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 47 additions & 2 deletions src/@ionic-native/plugins/push/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,15 @@ export interface PushOptions {
browser?: BrowserPushOptions;
}

export type PushEvent = 'registration' | 'error' | 'notification';
export type Priority = 1 | 2 | 3 | 4 | 5;

export interface Channel {
id: string;
description: string;
importance: Priority;
}

export type PushEvent = string;

/**
* @name Push
Expand Down Expand Up @@ -240,6 +248,20 @@ export type PushEvent = 'registration' | 'error' | 'notification';
*
* });
*
* // Create a channel (Android O and above). You'll need to provide the id, description and importance properties.
* this.push.createChannel({
* id: "testchannel1",
* description: "My first test channel",
* // The importance property goes from 1 = Lowest, 2 = Low, 3 = Normal, 4 = High and 5 = Highest.
* importance: 3
* }).then(() => console.log('Channel created'));
*
* // Delete a channel (Android O and above)
* this.push.deleteChannel('testchannel1').then(() => console.log('Channel deleted));
*
* // Return a list of currently configured channels
* this.push.listChannels().then((channels) => console.log('List of channels', channels))
*
* // to initialize push notifications
*
* const options: PushOptions = {
Expand All @@ -257,6 +279,7 @@ export type PushEvent = 'registration' | 'error' | 'notification';
*
* const pushObject: PushObject = this.push.init(options);
*
*
* pushObject.on('notification').subscribe((notification: any) => console.log('Received a notification', notification));
*
* pushObject.on('registration').subscribe((registration: any) => console.log('Device registered', registration));
Expand Down Expand Up @@ -302,6 +325,27 @@ export class Push extends IonicNativePlugin {
@Cordova()
hasPermission(): Promise<{ isEnabled: boolean }> { return; }

/**
* Create a new notification channel for Android O and above.
* @param channel {Channel}
*/
@Cordova()
createChannel(channel: Channel): Promise<any> { return; }

/**
* Delete a notification channel for Android O and above.
* @param id
*/
@Cordova()
deleteChannel(id: string): Promise<any> { return; }

/**
* Returns a list of currently configured channels.
* @return {Promise<Channel[]>}
*/
@Cordova()
listChannels(): Promise<Channel[]> { return; }

}

/**
Expand Down Expand Up @@ -365,9 +409,10 @@ export class PushObject {
* iOS only
* Tells the OS that you are done processing a background push notification.
* successHandler gets called when background push processing is successfully completed.
* @param id
*/
@CordovaInstance()
finish(): Promise<any> { return; }
finish(id?: string): Promise<any> { return; }

/**
* Tells the OS to clear all notifications from the Notification Center
Expand Down