Skip to content

Commit

Permalink
Merge pull request #103 from avorra/types
Browse files Browse the repository at this point in the history
Types: Describe event handlers
  • Loading branch information
zxcpoiu authored Jul 26, 2023
2 parents d1feacb + 4db3ecd commit 6239f24
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions index.d.ts
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
}
}

0 comments on commit 6239f24

Please sign in to comment.