DefinitelyTyped/types/node-pushnotifications/index.d.ts
2018-03-20 08:32:07 -04:00

170 lines
6.1 KiB
TypeScript

// Type definitions for node-pushnotifications 1.0
// Project: https://github.com/appfeel/node-pushnotifications
// Definitions by: Menushka Weeratunga <https://github.com/menushka>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class PushNotifications {
constructor(settings: PushNotifications.ISettings);
setOptions(opts: PushNotifications.ISettings): void;
sendWith(method: PushNotifications.IPushMethod, regIds: string[], data: PushNotifications.IData, cb: PushNotifications.ICallback): void;
send(registrationIds: string[], data: PushNotifications.IData, cb: PushNotifications.ICallback): void;
send(registrationIds: string[], data: PushNotifications.IData): Promise<any>;
}
declare module PushNotifications {
interface ISettings {
/** Google Cloud Messaging */
gcm?: {
/** GCM or FCM token */
id?: string
},
/** Apple Push Notifications */
apn?: {
/** APN Token */
token?: {
/** The filename of the provider token key (as supplied by Apple) to load from disk, or a Buffer/String containing the key data. */
key?: Buffer | string,
/** The ID of the key issued by Apple */
keyId?: string,
/** ID of the team associated with the provider token key */
teamId?: string
}
/** The filename of the connection certificate to load from disk, or a Buffer/String containing the certificate data. */
cert?: string,
/** The filename of the connection key to load from disk, or a Buffer/String containing the key data. */
key?: string,
/** An array of trusted certificates. Each element should contain either a filename to load, or a Buffer/String (in PEM format) to be used directly. If this is omitted several well known "root" CAs will be used. - You may need to use this as some environments don't include the CA used by Apple (entrust_2048). */
ca?: (Buffer | string)[],
/** File path for private key, certificate and CA certs in PFX or PKCS12 format, or a Buffer containing the PFX data. If supplied will always be used instead of certificate and key above. */
pfx?: Buffer | string,
/** The passphrase for the connection key, if required */
passphrase?: string,
productionv?: boolean,
voip?: boolean,
address?: string,
port?: number,
rejectUnauthorized?: boolean,
connectionRetryLimit?: number,
cacheLength?: number,
connectionTimeout?: number,
autoAdjustCache?: boolean,
maxConnections?: number,
minConnections?: number,
connectTimeout?: number,
buffersNotifications?: boolean,
fastMode?: boolean,
disableNagle?: boolean,
disableEPIPEFix?: boolean
},
/** Amazon Device Messaging */
adm?: {
client_id?: string,
client_secret?: string
},
/** Windows Push Notifications */
wns?: {
client_id?: string,
client_secret?: string,
accessToken?: string,
headers?: string,
notificationMethod?: string
},
/** Microsoft Push Notification Service */
mpns?: {
options?: {
client_id?: string,
client_secret?: string
}
}
}
interface IData {
/** REQUIRED */
title: string,
/** REQUIRED */
body: string,
custom?: {
sender?: string,
},
/** gcm, apn. Supported values are 'high' or 'normal' (gcm). Will be translated to 10 and 5 for apn. Defaults to 'high' */
priority?: string,
/** gcm for android, used as collapseId in apn */
collapseKey?: string,
/** gcm for android */
contentAvailable?: boolean | string,
/** gcm for android */
delayWhileIdle?: boolean,
/** gcm for android */
restrictedPackageName?: string,
/** gcm for android */
dryRun?: boolean,
/** gcm for android */
icon?: string,
/** gcm for android */
tag?: string,
/** gcm for android */
color?: string,
/** gcm for android. In ios, category will be used if not supplied */
clickAction?: string,
/** gcm, apn */
locKey?: string,
/** gcm, apn */
bodyLocArgs?: string,
/** gcm, apn */
titleLocKey?: string,
/** gcm, apn */
titleLocArgs?: string,
/** gcm, apn */
retries?: number,
/** apn */
encoding?: string,
/** gcm for ios, apn */
badge?: number,
/** gcm, apn */
sound?: string,
/** apn, will take precedence over title and body. It is also accepted a text message in alert */
alert?: {} | string,
/** apn and gcm for ios */
launchImage?: string,
/** apn and gcm for ios */
action?: string,
/** apn and gcm for ios */
topic?: string,
/** apn and gcm for ios */
category?: string,
/** apn and gcm for ios */
mdm?: string,
/** apn and gcm for ios */
urlArgs?: string,
/** apn and gcm for ios */
truncateAtWordEnd?: boolean,
/** apn */
mutableContent?: number,
/** seconds */
expiry?: number,
/** if both expiry and timeToLive are given, expiry will take precedency */
timeToLive?: number,
/** wns */
headers?: string[],
/** wns */
launch?: string,
/** wns */
duration?: string,
/** ADM */
consolidationKey?: string
}
interface IPushMethod {
(regIds: string[], data: IData, settings: ISettings): void
}
interface ICallback {
(err: any, result: any): void
}
}
declare module 'node-pushnotifications' {
export = PushNotifications;
}