forked from AndrewBarba/apns2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
126 lines (116 loc) · 2.91 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
116
117
118
119
120
121
122
123
124
125
126
import { EventEmitter } from 'events'
export class APNS extends EventEmitter {
constructor(options: APNSOptions)
send(notification: Notification): Promise<Notification | ResponseError>
sendMany(notifications: Notification[]): Promise<(Notification | ResponseError)[]>
close(): Promise<void>
}
export class Notification {
constructor(deviceToken: string, options?: NotificationOptions)
static readonly priority: NotificationPriority
static readonly pushType: PushType
readonly deviceToken: string
readonly pushType: string
readonly priority: number
readonly expiration: number
readonly topic: string
readonly collapseId: string
}
export class BasicNotification extends Notification {
constructor(deviceToken: string, message: string, options?: NotificationOptions)
}
export class SilentNotification extends Notification {
constructor(deviceToken: string, options?: NotificationOptions)
}
type ResponseError = {
error: {
reason: string
statusCode: number
notification: Notification
}
}
export const Errors: {
badCertificate: string
badCertificateEnvironment: string
badCollapseId: string
badDeviceToken: string
badExpirationDate: string
badMessageId: string
badPath: string
badPriority: string
badTopic: string
deviceTokenNotForTopic: string
duplicateHeaders: string
error: string
expiredProviderToken: string
forbidden: string
idleTimeout: string
internalServerError: string
invalidProviderToken: string
invalidPushType: string
invalidSigningKey: string
methodNotAllowed: string
missingDeviceToken: string
missingProviderToken: string
missingTopic: string
payloadEmpty: string
payloadTooLarge: string
serviceUnavailable: string
shutdown: string
tooManyProviderTokenUpdates: string
tooManyRequests: string
topicDisallowed: string
unknownError: string
unregistered: string
}
declare interface APNSOptions {
team: string
keyId: string
signingKey: string
defaultTopic?: string
host?: string
port?: number
requestTimeout?: number
pingInterval?: number
}
declare interface NotificationOptions {
alert?:
| string
| {
title?: string
subtitle?: string
body: string
'title-loc-key'?: string
'title-loc-args'?: string[]
'subtitle-loc-key'?: string
'subtitle-loc-args'?: string[]
'loc-key'?: string
'loc-args'?: string[]
'action-loc-key'?: string
'launch-image'?: string
}
aps?: any
badge?: number
category?: string
collapseId?: string
contentAvailable?: boolean
data?: { [key: string]: any }
expiration?: number
priority?: number
pushType?: keyof PushType
sound?: string
threadId?: string
topic?: string
}
declare interface NotificationPriority {
immediate: number
throttled: number
}
declare interface PushType {
alert: string
background: string
voip: string
complication: string
fileprovider: string
mdm: string
}