UNPKG

rokot-notification

Version:

Rokot - [Rocketmakers](http://www.rocketmakers.com/) TypeScript NodeJs Platform

37 lines (36 loc) 2.4 kB
import { ProviderOptions, Provider, Notification } from "apn"; import * as Logger from "bunyan"; import { IRecipientResolver } from "../core/recipients"; import { INotificationHandler, INotificationTransport, INotification, NotificationRecipients, INotificationDispatchResult } from "../core/core"; import { NotificationDispatchHandler } from "../core/dispatchHandler"; import { ResponseFailure } from "apn"; export declare type INotificationFailureError = Pick<ResponseFailure, "device" | "status" | "error">; export declare type INotificationFailureResponse = Pick<ResponseFailure, "device" | "status" | "response">; declare module "../core/core" { interface INotificationRecipient { apns?: string | string[]; } } export interface IApnsNotificationHandler<T extends INotification> extends INotificationHandler<T> { apns(notification: T, transport: IApnsNotificationTransport): Promise<INotificationDispatchResult>; } export interface IApnsNotificationTransport extends INotificationTransport<Provider> { send(recipients: NotificationRecipients, builder: (notification: Notification) => void): Promise<INotificationDispatchResult>; } export declare function isNotificationFailureError(failure: ResponseFailure): failure is INotificationFailureError; export declare function isNotificationFailureResponse(failure: ResponseFailure): failure is INotificationFailureResponse; export declare class ApnsNotificationDispatchHandler extends NotificationDispatchHandler<IApnsNotificationTransport> { constructor(logger: Logger, transport: IApnsNotificationTransport); } export declare function apnsInitializer(logger: Logger, options: ProviderOptions, recipientResolver?: IRecipientResolver): Promise<ApnsNotificationDispatchHandler>; export declare class ApnsNotificationTransport implements IApnsNotificationTransport { private logger; native: Provider; private recipientResolver; static create(logger: Logger, options: ProviderOptions, recipientResolver: IRecipientResolver): Promise<IApnsNotificationTransport>; constructor(logger: Logger, native: Provider, recipientResolver: IRecipientResolver); resolveTokens(recipients: NotificationRecipients): Promise<string[]>; send(recipients: NotificationRecipients, builder: (notification: Notification) => void): Promise<INotificationDispatchResult>; private sendMessage; shutdown(): void; }