From cdaf2e6a194fd7cead3541b0114166d126779886 Mon Sep 17 00:00:00 2001 From: Gary Tokman Date: Sat, 10 Feb 2024 08:12:35 -0500 Subject: [PATCH] fix: updates --- src/index.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index cd270a3..b24142d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,12 +1,19 @@ import { NativeModules, Platform, NativeEventEmitter } from 'react-native'; +export type NotificationType = + | 'notificationReceived' + | 'deviceTokenReceived' + | 'errorReceived'; + class Push { - module = NativeModules.Push; + module: any; private bridge?: NativeEventEmitter; public constructor() { if (Platform.OS === 'ios') { - this.bridge = new NativeEventEmitter(this.module); + const module = NativeModules.Push; + this.module = module; + this.bridge = new NativeEventEmitter(module); } } @@ -31,11 +38,14 @@ class Push { return false; } - public addListener(event: string, callback: (data: any) => void): void { + public addListener( + event: NotificationType, + callback: (data: any) => void + ): void { this.bridge?.addListener(event, callback); } - public removeListener(event: string): void { + public removeListener(event: NotificationType): void { this.bridge?.removeAllListeners(event); }