diff --git a/src/@ionic-native/plugins/push/index.ts b/src/@ionic-native/plugins/push/index.ts index afef7c49d6..d184b14bb3 100644 --- a/src/@ionic-native/plugins/push/index.ts +++ b/src/@ionic-native/plugins/push/index.ts @@ -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 @@ -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 = { @@ -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)); @@ -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 { return; } + + /** + * Delete a notification channel for Android O and above. + * @param id + */ + @Cordova() + deleteChannel(id: string): Promise { return; } + + /** + * Returns a list of currently configured channels. + * @return {Promise} + */ + @Cordova() + listChannels(): Promise { return; } + } /** @@ -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 { return; } + finish(id?: string): Promise { return; } /** * Tells the OS to clear all notifications from the Notification Center