forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node-gcm.d.ts
90 lines (76 loc) · 2.71 KB
/
node-gcm.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
// Type definitions for node-gcm 0.14.0
// Project: https://www.npmjs.org/package/node-gcm
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "node-gcm" {
export interface INotificationOptions {
title: string;
body?: string;
icon: string;
sound?: string;
badge?: string;
tag?: string;
color?: string;
click_action?: string;
}
export interface IMessageOptions {
collapseKey?: string;
priority?: string;
contentAvailable?: boolean;
delayWhileIdle?: boolean;
timeToLive?: number;
restrictedPackageName?: string;
dryRun?: boolean;
data?: {
[key: string]: string;
};
notification?: INotificationOptions;
}
export class Message {
constructor(options?: IMessageOptions);
collapseKey: string;
delayWhileIdle: boolean;
timeToLive: number;
dryRun: boolean;
addData(key: string, value: string): void;
addData(data: { [key: string]: string }): void;
addNotification(value: INotificationOptions): void;
addNotification(key: string, value:INotificationOptions): void;
}
export interface ISenderOptions {
proxy?: any;
maxSockets?: number;
timeout?: number;
}
export interface ISenderSendOptions {
retries?: number;
backoff?: number;
}
export interface IRecipient {
to?: string,
topic?: string,
notificationKey?: string,
registrationIds?: string[],
registrationTokens?: string[]
}
export class Sender {
constructor(key: string, options?: ISenderOptions);
key: string;
options: ISenderOptions;
send(message: Message, registrationIds: string|string[]|IRecipient, callback: (err: any, resJson: IResponseBody) => void): void;
send(message: Message, registrationIds: string|string[]|IRecipient, retries: number, callback: (err: any, resJson: IResponseBody) => void): void;
send(message: Message, registrationIds: string|string[]|IRecipient, options: ISenderSendOptions, callback: (err: any, resJson: IResponseBody) => void): void;
sendNoRetry(message: Message, registrationIds: string|string[]|IRecipient, callback: (err: any, resJson: IResponseBody) => void): void;
}
export interface IResponseBody {
success: number;
failure: number;
canonical_ids: number;
multicast_id?: number;
results?: {
message_id?: string;
registration_id?: string;
error?: string;
}[];
}
}