chore(tslint): add tslint & clean up code

This commit is contained in:
Ibrahim Hadeed
2016-04-29 23:56:49 -04:00
parent 8b6d9f33f6
commit 06146b322f
58 changed files with 1014 additions and 941 deletions
+112 -112
View File
@@ -1,41 +1,41 @@
import {Plugin, Cordova} from './plugin';
export type EventResponse = RegistrationEventResponse | NotificationEventResponse | Error
export type EventResponse = RegistrationEventResponse | NotificationEventResponse | Error;
export interface RegistrationEventResponse {
/**
* The registration ID provided by the 3rd party remote push service.
*/
registrationId: string
registrationId: string;
}
export interface NotificationEventResponse {
/**
* The text of the push message sent from the 3rd party service.
*/
message: string
/**
* The optional title of the push message sent from the 3rd party service.
*/
title?: string
/**
* The number of messages to be displayed in the badge iOS or message count in the notification shade in Android.
* For windows, it represents the value in the badge notification which could be a number or a status glyph.
*/
count: string
/**
* The name of the sound file to be played upon receipt of the notification.
*/
sound: string
/**
* The path of the image file to be displayed in the notification.
*/
image: string
/**
* An optional collection of data sent by the 3rd party push service that does not fit in the above properties.
*/
additionalData: NotificationEventAdditionalData
/**
* The text of the push message sent from the 3rd party service.
*/
message: string;
/**
* The optional title of the push message sent from the 3rd party service.
*/
title?: string;
/**
* The number of messages to be displayed in the badge iOS or message count in the notification shade in Android.
* For windows, it represents the value in the badge notification which could be a number or a status glyph.
*/
count: string;
/**
* The name of the sound file to be played upon receipt of the notification.
*/
sound: string;
/**
* The path of the image file to be displayed in the notification.
*/
image: string;
/**
* An optional collection of data sent by the 3rd party push service that does not fit in the above properties.
*/
additionalData: NotificationEventAdditionalData;
}
/**
@@ -47,96 +47,96 @@ export interface NotificationEventResponse {
* so that he could specify any custom code without having to use array notation (map['prop']) for all of them.
*/
export interface NotificationEventAdditionalData {
[name: string]: any
[name: string]: any;
/**
* Whether the notification was received while the app was in the foreground
*/
foreground?: boolean
collapse_key?: string
from?: string
notId?: string
/**
* Whether the notification was received while the app was in the foreground
*/
foreground?: boolean;
collapse_key?: string;
from?: string;
notId?: string;
}
export interface PushNotification {
/**
* The event registration will be triggered on each successful registration with the 3rd party push service.
* @param event
* @param callback
*/
on(event: "registration", callback: (response: RegistrationEventResponse) => any): void
/**
* The event notification will be triggered each time a push notification is received by a 3rd party push service on the device.
* @param event
* @param callback
*/
on(event: "notification", callback: (response: NotificationEventResponse) => any): void
/**
* The event error will trigger when an internal error occurs and the cache is aborted.
* @param event
* @param callback
*/
on(event: "error", callback: (response: Error) => any): void
/**
*
* @param event Name of the event to listen to. See below(above) for all the event names.
* @param callback is called when the event is triggered.
* @param event
* @param callback
*/
on(event: string, callback: (response: EventResponse) => any): void
/**
* The event registration will be triggered on each successful registration with the 3rd party push service.
* @param event
* @param callback
*/
on(event: "registration", callback: (response: RegistrationEventResponse) => any): void;
/**
* The event notification will be triggered each time a push notification is received by a 3rd party push service on the device.
* @param event
* @param callback
*/
on(event: "notification", callback: (response: NotificationEventResponse) => any): void;
/**
* The event error will trigger when an internal error occurs and the cache is aborted.
* @param event
* @param callback
*/
on(event: "error", callback: (response: Error) => any): void;
/**
*
* @param event Name of the event to listen to. See below(above) for all the event names.
* @param callback is called when the event is triggered.
* @param event
* @param callback
*/
on(event: string, callback: (response: EventResponse) => any): void;
off(event: "registration", callback: (response: RegistrationEventResponse) => any): void
off(event: "notification", callback: (response: NotificationEventResponse) => any): void
off(event: "error", callback: (response: Error) => any): void
/**
* As stated in the example, you will have to store your event handler if you are planning to remove it.
* @param event Name of the event type. The possible event names are the same as for the push.on function.
* @param callback handle to the function to get removed.
* @param event
* @param callback
*/
off(event: string, callback: (response: EventResponse) => any): void
off(event: "registration", callback: (response: RegistrationEventResponse) => any): void;
off(event: "notification", callback: (response: NotificationEventResponse) => any): void;
off(event: "error", callback: (response: Error) => any): void;
/**
* As stated in the example, you will have to store your event handler if you are planning to remove it.
* @param event Name of the event type. The possible event names are the same as for the push.on function.
* @param callback handle to the function to get removed.
* @param event
* @param callback
*/
off(event: string, callback: (response: EventResponse) => any): void;
/**
* The unregister method is used when the application no longer wants to receive push notifications.
* Beware that this cleans up all event handlers previously registered,
* so you will need to re-register them if you want them to function again without an application reload.
* @param successHandler
* @param errorHandler
*/
unregister(successHandler: () => any, errorHandler?: () => any): void
/**
* The unregister method is used when the application no longer wants to receive push notifications.
* Beware that this cleans up all event handlers previously registered,
* so you will need to re-register them if you want them to function again without an application reload.
* @param successHandler
* @param errorHandler
*/
unregister(successHandler: () => any, errorHandler?: () => any): void;
/**
* Set the badge count visible when the app is not running
*
* The count is an integer indicating what number should show up in the badge.
* Passing 0 will clear the badge.
* Each notification event contains a data.count value which can be used to set the badge to correct number.
* @param successHandler
* @param errorHandler
* @param count
*/
setApplicationIconBadgeNumber(successHandler: () => any, errorHandler: () => any, count?: number): void
/**
* Get the current badge count visible when the app is not running
* successHandler gets called with an integer which is the current badge count
* @param successHandler
* @param errorHandler
*/
getApplicationIconBadgeNumber(successHandler: (count: number) => any, errorHandler: () => any): void
/**
* Set the badge count visible when the app is not running
*
* The count is an integer indicating what number should show up in the badge.
* Passing 0 will clear the badge.
* Each notification event contains a data.count value which can be used to set the badge to correct number.
* @param successHandler
* @param errorHandler
* @param count
*/
setApplicationIconBadgeNumber(successHandler: () => any, errorHandler: () => any, count?: number): void;
/**
* Get the current badge count visible when the app is not running
* successHandler gets called with an integer which is the current badge count
* @param successHandler
* @param errorHandler
*/
getApplicationIconBadgeNumber(successHandler: (count: number) => any, errorHandler: () => any): void;
/**
* iOS only
* Tells the OS that you are done processing a background push notification.
* successHandler gets called when background push processing is successfully completed.
* @param successHandler
* @param errorHandler
*/
finish(successHandler: () => any, errorHandler: () => any): void
/**
* iOS only
* Tells the OS that you are done processing a background push notification.
* successHandler gets called when background push processing is successfully completed.
* @param successHandler
* @param errorHandler
*/
finish(successHandler: () => any, errorHandler: () => any): void;
}
export interface iOSPushOptions {
export interface IOSPushOptions {
/**
* Maps to the project number in the Google Developer Console. Setting this
* uses GCM for notifications instead of native.
@@ -236,14 +236,14 @@ export interface AndroidPushOptions {
}
export interface PushOptions {
ios?: iOSPushOptions;
ios?: IOSPushOptions;
android?: AndroidPushOptions;
windows?: {};
}
declare var PushNotification: {
new(): PushNotification
}
};
/**
* @name Push
@@ -292,13 +292,13 @@ export class Push {
@Cordova({
sync: true
})
static init(options: PushOptions): PushNotification { return }
static init(options: PushOptions): PushNotification { return; }
/**
* Check whether the push notification permission has been granted.
* @return {Promise} Returns a Promise that resolves with an object with one property: isEnabled, a boolean that indicates if permission has been granted.
*/
@Cordova()
static hasPermission(): Promise<{ isEnabled: boolean }> { return }
static hasPermission(): Promise<{ isEnabled: boolean }> { return; }
}