Skip to content
This repository has been archived by the owner on Sep 14, 2024. It is now read-only.

Commit

Permalink
fix: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gtokman committed Feb 10, 2024
1 parent 77911ab commit cdaf2e6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -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);
}
}

Expand All @@ -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);
}

Expand Down

0 comments on commit cdaf2e6

Please sign in to comment.