Skip to content

Commit

Permalink
feat(push): add support for version 2.1.0 (#2064)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Garcia authored and ihadeed committed Dec 2, 2017
1 parent 091ac7a commit c1ce5da
Showing 1 changed file with 47 additions and 2 deletions.
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

0 comments on commit c1ce5da

Please sign in to comment.