Skip to content

Commit

Permalink
feat(fcm): add requestPushPermissionIOS and createNotificationChannel…
Browse files Browse the repository at this point in the history
…Android functions (#3430)
  • Loading branch information
andrehtissot committed Jun 11, 2020
1 parent 324334e commit ef17dc5
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/@ionic-native/plugins/fcm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,60 @@ export interface NotificationData {
[name: string]: any;
}

export interface IRequestPushPermissionIOSOptions {
/**
* Options exclusive for iOS 9 support
*/
ios9Support?: {
/**
* How long it will wait for a decision from the user before returning `false`, defaults to 10
*/
timeout?: number;
/**
* How long between each permission verification, defaults to 0.3
*/
interval?: number;
};
}

export interface IChannelConfiguration {
/**
* Channel id, used in the android_channel_id push payload key
*/
id: string;
/**
* Channel name, visible for the user
*/
name: string;
/**
* Channel description, visible for the user
*/
description?: string;
/**
* Importance for notifications of this channel
* https://developer.android.com/guide/topics/ui/notifiers/notifications#importance
*/
importance?: 'none' | 'min' | 'low' | 'default' | 'high';
/**
* Visibility for notifications of this channel
* https://developer.android.com/training/notify-user/build-notification#lockscreenNotification
*/
visibility?: 'public' | 'private' | 'secret';
/**
* Default sound resource for notifications of this channel
* The file should located as resources/raw/[resource name].mp3
*/
sound?: string;
/**
* Enable lights for notifications of this channel
*/
lights?: boolean;
/**
* Enable vibration for notifications of this channel
*/
vibration?: boolean;
}

/**
* @name FCM
* @capacitorincompatible true
Expand Down Expand Up @@ -61,6 +115,8 @@ export interface NotificationData {
* ```
* @interfaces
* NotificationData
* IRequestPushPermissionIOSOptions
* IChannelConfiguration
*/
@Plugin({
pluginName: 'FCM',
Expand Down Expand Up @@ -163,4 +219,32 @@ export class FCM extends IonicNativePlugin {
clearAllNotifications(): void {
return;
}

/**
* Request push notification permission, alerting the user if it not have yet decided
*
* @param {IRequestPushPermissionIOSOptions} options Options for push request
*
* @returns {Promise<boolean>} Returns a Promise that resolves with the permission status
*/
@Cordova()
requestPushPermissionIOS(options?: IRequestPushPermissionIOSOptions): Promise<boolean> {
return;
}

/**
* For Android, some notification properties are only defined programmatically.
*
* Channel can define the default behavior for notifications on Android 8.0+.
*
* Once a channel is created, it stays unchangeable until the user uninstalls the app.
*
* @param channelConfig
*
* @returns {Promise<void>}
*/
@Cordova()
createNotificationChannelAndroid(channelConfig: IChannelConfiguration): void {
return;
}
}

0 comments on commit ef17dc5

Please sign in to comment.