rokot-notification
Version:
Rokot - [Rocketmakers](http://www.rocketmakers.com/) TypeScript NodeJs Platform
35 lines (34 loc) • 1.9 kB
TypeScript
import { Sender, IMessageOptions } from "node-gcm";
import * as Logger from "bunyan";
import { IRecipientResolver } from "../core/recipients";
import { INotification, NotificationRecipients, INotificationDispatchResult, INotificationHandler, INotificationTransport } from "../core/core";
import { NotificationDispatchHandler } from "../core/dispatchHandler";
declare module "../core/core" {
interface INotificationRecipient {
gcm?: string | string[];
}
}
export interface IGcmNotificationHandler<T extends INotification> extends INotificationHandler<T> {
gcm(notification: T, transport: IGcmNotificationTransport): Promise<any>;
}
export interface IGcmNotificationTransport extends INotificationTransport<Sender> {
sendMessage(recipients: NotificationRecipients, options: IMessageOptions): Promise<INotificationDispatchResult>;
}
export interface IGcmProviderOptions {
apiKey: string;
}
export declare function gcmInitializer(logger: Logger, options: IGcmProviderOptions, recipientResolver?: IRecipientResolver): Promise<GcmNotificationDispatchHandler>;
export declare class GcmNotificationDispatchHandler extends NotificationDispatchHandler<IGcmNotificationTransport> {
constructor(logger: Logger, transport: IGcmNotificationTransport);
}
export declare class GcmNotificationTransport implements IGcmNotificationTransport {
private logger;
native: Sender;
recipientResolver: IRecipientResolver;
static create(logger: Logger, options: IGcmProviderOptions, recipientResolver: IRecipientResolver): Promise<IGcmNotificationTransport>;
constructor(logger: Logger, native: Sender, recipientResolver: IRecipientResolver);
resolveTokens(recipients: NotificationRecipients): Promise<string[]>;
sendMessage(recipients: NotificationRecipients, options: IMessageOptions): Promise<INotificationDispatchResult>;
private send;
shutdown(): void;
}