From 6fc34ed35e206b23e1af1465ee8e7446384db618 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Tue, 11 Apr 2017 21:50:29 +0200 Subject: [PATCH] Add typescript definition file (#376) * Add typescript definition file * Update index.d.ts --- index.d.ts | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..e6616e8 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,56 @@ +declare module "react-native-fcm" { + + type FCMEventType = "FCMTokenRefreshed" | "FCMNotificationReceived"; + export module FCMEvent { + const RefreshToken = "FCMTokenRefreshed"; + const Notification = "FCMNotificationReceived"; + } + + export module RemoteNotificationResult { + const NewData = "UIBackgroundFetchResultNewData"; + const NoData = "UIBackgroundFetchResultNoData"; + const ResultFailed = "UIBackgroundFetchResultFailed"; + } + + export module WillPresentNotificationResult { + const All = "UNNotificationPresentationOptionAll"; + const None = "UNNotificationPresentationOptionNone"; + } + + export module NotificationType { + const Remote = "remote_notification"; + const NotificationResponse = "notification_response"; + const WillPresent = "will_present_notification"; + const Local = "local_notification"; + } + + export interface Subscription { + remove(): void; + } + + export class FCM { + static requestPermissions(): void; + static getFCMToken(): Promise; + static on(event: "FCMTokenRefreshed", handler: (token: string) => void): Subscription; + static on(event: "FCMNotificationReceived", handler: (notification: any) => void): Subscription; + static subscribeToTopic(topic: string): void; + static unsubscribeFromTopic(topic: string): void; + static getInitialNotification(): Promise; + static presentLocalNotification(notification: any): void; + + static scheduleLocalNotification(schedule: any): void; + static getScheduledLocalNotifications(): Promise; + + static removeAllDeliveredNotifications(): void; + static removeDeliveredNotification(id: string): void; + + static cancelAllLocalNotifications(): void; + static cancelLocalNotification(id: string): string; + + static setBadgeNumber(badge: number): void; + static getBadgeNumber(): Promise; + static send(id: string, data: any): void; + } + + export default FCM; +} -- 2.26.2