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

add createNotificationChannel

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