-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #103 from avorra/types
Types: Describe event handlers
- Loading branch information
Showing
1 changed file
with
26 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
declare module 'react-native-voip-push-notification' { | ||
export type Events = | ||
'notification' | | ||
'register'| | ||
'didLoadWithEvents'; | ||
export type NativeEvents = { | ||
register: 'RNVoipPushRemoteNotificationsRegisteredEvent'; | ||
notification: 'RNVoipPushRemoteNotificationReceivedEvent'; | ||
didLoadWithEvents: 'RNVoipPushDidLoadWithEvents'; | ||
} | ||
|
||
export type Events = keyof NativeEvents; | ||
export type EventsPayload = { | ||
register: string, | ||
notification: object, | ||
didLoadWithEvents: Array<InitialEvent>, | ||
} | ||
|
||
export type InitialEvent = { | ||
[Event in Events]: { name: NativeEvents[Event], data: EventsPayload[Event] } | ||
}[Events]; | ||
|
||
export default class RNVoipPushNotification { | ||
static addEventListener(type: Events, handler: (args: any) => void): void | ||
static RNVoipPushRemoteNotificationsRegisteredEvent: NativeEvents['register'] | ||
static RNVoipPushRemoteNotificationReceivedEvent: NativeEvents['notification'] | ||
static RNVoipPushDidLoadWithEvents: NativeEvents['didLoadWithEvents'] | ||
|
||
static addEventListener<Event extends Events>( | ||
type: Event, | ||
handler: (args: EventsPayload[Event]) => void, | ||
): void | ||
static removeEventListener(type: Events): void | ||
|
||
static registerVoipToken(): void; | ||
static onVoipNotificationCompleted(uuid: string): void; | ||
static removeEventListener(type: Events): void | ||
} | ||
} |