Commit 7557b00e authored by Libin Lu's avatar Libin Lu

add createNotificationChannel

parent b884852e
declare module "react-native-fcm" { declare module "react-native-fcm" {
type FCMEventType =
type FCMEventType = "FCMTokenRefreshed" | "FCMNotificationReceived" | 'FCMDirectChannelConnectionChanged'; | "FCMTokenRefreshed"
export module FCMEvent { | "FCMNotificationReceived"
| "FCMDirectChannelConnectionChanged";
export namespace FCMEvent {
const RefreshToken = "FCMTokenRefreshed"; const RefreshToken = "FCMTokenRefreshed";
const Notification = "FCMNotificationReceived"; const Notification = "FCMNotificationReceived";
const DirectChannelConnectionChanged: 'FCMDirectChannelConnectionChanged' const DirectChannelConnectionChanged: "FCMDirectChannelConnectionChanged";
} }
export module RemoteNotificationResult { export namespace RemoteNotificationResult {
const NewData = "UIBackgroundFetchResultNewData"; const NewData = "UIBackgroundFetchResultNewData";
const NoData = "UIBackgroundFetchResultNoData"; const NoData = "UIBackgroundFetchResultNoData";
const ResultFailed = "UIBackgroundFetchResultFailed"; const ResultFailed = "UIBackgroundFetchResultFailed";
} }
export module WillPresentNotificationResult { export namespace WillPresentNotificationResult {
const All = "UNNotificationPresentationOptionAll"; const All = "UNNotificationPresentationOptionAll";
const None = "UNNotificationPresentationOptionNone"; const None = "UNNotificationPresentationOptionNone";
} }
export module NotificationType { export namespace NotificationType {
const Remote = "remote_notification"; const Remote = "remote_notification";
const NotificationResponse = "notification_response"; const NotificationResponse = "notification_response";
const WillPresent = "will_present_notification"; const WillPresent = "will_present_notification";
...@@ -26,23 +28,23 @@ declare module "react-native-fcm" { ...@@ -26,23 +28,23 @@ declare module "react-native-fcm" {
} }
export enum NotificationCategoryOption { export enum NotificationCategoryOption {
CustomDismissAction = 'UNNotificationCategoryOptionCustomDismissAction', CustomDismissAction = "UNNotificationCategoryOptionCustomDismissAction",
AllowInCarPlay = 'UNNotificationCategoryOptionAllowInCarPlay', AllowInCarPlay = "UNNotificationCategoryOptionAllowInCarPlay",
PreviewsShowTitle = 'UNNotificationCategoryOptionHiddenPreviewsShowTitle', PreviewsShowTitle = "UNNotificationCategoryOptionHiddenPreviewsShowTitle",
PreviewsShowSubtitle = 'UNNotificationCategoryOptionHiddenPreviewsShowSubtitle', PreviewsShowSubtitle = "UNNotificationCategoryOptionHiddenPreviewsShowSubtitle",
None = 'UNNotificationCategoryOptionNone' None = "UNNotificationCategoryOptionNone"
} }
export enum NotificationActionOption { export enum NotificationActionOption {
AuthenticationRequired = 'UNNotificationActionOptionAuthenticationRequired', AuthenticationRequired = "UNNotificationActionOptionAuthenticationRequired",
Destructive = 'UNNotificationActionOptionDestructive', Destructive = "UNNotificationActionOptionDestructive",
Foreground = 'UNNotificationActionOptionForeground', Foreground = "UNNotificationActionOptionForeground",
None = 'UNNotificationActionOptionNone' None = "UNNotificationActionOptionNone"
} }
export enum NotificationActionType { export enum NotificationActionType {
Default = 'UNNotificationActionTypeDefault', Default = "UNNotificationActionTypeDefault",
TextInput = 'UNNotificationActionTypeTextInput', TextInput = "UNNotificationActionTypeTextInput"
} }
export interface Notification { export interface Notification {
...@@ -50,7 +52,7 @@ declare module "react-native-fcm" { ...@@ -50,7 +52,7 @@ declare module "react-native-fcm" {
opened_from_tray: boolean; opened_from_tray: boolean;
from: string; from: string;
notification: { notification: {
title?: string title?: string;
body: string; body: string;
icon: string; icon: string;
}; };
...@@ -100,7 +102,7 @@ declare module "react-native-fcm" { ...@@ -100,7 +102,7 @@ declare module "react-native-fcm" {
export interface ScheduleLocalNotification extends LocalNotification { export interface ScheduleLocalNotification extends LocalNotification {
id: string; id: string;
fire_date: number; fire_date: number;
repeat_interval?: "week" | "day" | "hour" repeat_interval?: "week" | "day" | "hour";
} }
export interface Subscription { export interface Subscription {
...@@ -127,8 +129,14 @@ declare module "react-native-fcm" { ...@@ -127,8 +129,14 @@ declare module "react-native-fcm" {
export class FCM { export class FCM {
static requestPermissions(): Promise<void>; static requestPermissions(): Promise<void>;
static getFCMToken(): Promise<string>; static getFCMToken(): Promise<string>;
static on(event: "FCMTokenRefreshed", handler: (token: string) => void): Subscription; static on(
static on(event: "FCMNotificationReceived", handler: (notification: Notification) => void): Subscription; event: "FCMTokenRefreshed",
handler: (token: string) => void
): Subscription;
static on(
event: "FCMNotificationReceived",
handler: (notification: Notification) => void
): Subscription;
static subscribeToTopic(topic: string): void; static subscribeToTopic(topic: string): void;
static unsubscribeFromTopic(topic: string): void; static unsubscribeFromTopic(topic: string): void;
static getInitialNotification(): Promise<Notification>; static getInitialNotification(): Promise<Notification>;
...@@ -147,11 +155,17 @@ declare module "react-native-fcm" { ...@@ -147,11 +155,17 @@ declare module "react-native-fcm" {
static getBadgeNumber(): Promise<number>; static getBadgeNumber(): Promise<number>;
static send(id: string, data: any): void; static send(id: string, data: any): void;
static enableDirectChannel(): void static enableDirectChannel(): void;
static isDirectChannelEstablished(): Promise<boolean> static isDirectChannelEstablished(): Promise<boolean>;
static getAPNSToken(): Promise<string> static getAPNSToken(): Promise<string>;
static setNotificationCategories(categories: NotificationCategory[]): void; static setNotificationCategories(categories: NotificationCategory[]): void;
static createNotificationChannel(config: {
id: string;
name: string;
description?: string;
priority?: string;
});
} }
export default FCM; export default FCM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment