forked from evollu/react-native-fcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
115 lines (100 loc) · 3.71 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
declare module "react-native-fcm" {
type FCMEventType = "FCMTokenRefreshed" | "FCMNotificationReceived" | 'FCMDirectChannelConnectionChanged';
export module FCMEvent {
const RefreshToken = "FCMTokenRefreshed";
const Notification = "FCMNotificationReceived";
const DirectChannelConnectionChanged: 'FCMDirectChannelConnectionChanged'
}
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 Notification {
collapse_key: string;
opened_from_tray: boolean;
from: string;
notification: {
title?: string
body: string;
icon: string;
};
fcm: {
action?: string;
tag?: string;
icon?: string;
color?: string;
body: string;
title?: string;
};
local_notification?: boolean;
_notificationType: string;
finish(type?: string): void;
[key: string]: any;
}
export interface LocalNotification {
id?: string;
title?: string;
body: string;
icon?: string;
vibrate?: number;
sound?: string;
big_text?: string;
sub_text?: string;
color?: string;
large_icon?: string;
priority?: string;
show_in_foreground?: boolean;
click_action?: string;
badge?: number;
number?: number;
ticker?: string;
auto_cancel?: boolean;
group?: string;
picture?: string;
ongoing?: boolean;
lights?: boolean;
[key: string]: any;
}
export interface ScheduleLocalNotification extends LocalNotification {
id: string;
fire_date: number;
repeat_interval?: "week" | "day" | "hour"
}
export interface Subscription {
remove(): void;
}
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 subscribeToTopic(topic: string): void;
static unsubscribeFromTopic(topic: string): void;
static getInitialNotification(): Promise<Notification>;
static presentLocalNotification(notification: LocalNotification): void;
static scheduleLocalNotification(schedule: ScheduleLocalNotification): void;
static getScheduledLocalNotifications(): Promise<LocalNotification>;
static removeAllDeliveredNotifications(): void;
static removeDeliveredNotification(id: string): void;
static cancelAllLocalNotifications(): void;
static cancelLocalNotification(id: string): string;
static setBadgeNumber(badge: number): void;
static getBadgeNumber(): Promise<number>;
static send(id: string, data: any): void;
static enableDirectChannel(): void
static isDirectChannelEstablished(): Promise<boolean>
static getAPNSToken(): Promise<string>
}
export default FCM;
}