Skip to content

Commit afe2777

Browse files
committed
Fix Bridge Reload Issue
• When react-native apps get reloaded, the existing bridge is destroyed and a new bridge is created. • Our SDK was not properly registering the new bridge to receive onReceived and onOpened events for notifications • Changes the 'registeredEvents' boolean to be an instance variable instead of a static variable. • Also adds code to remove event listeners when the bridge gets destroyed.
1 parent 76299d1 commit afe2777

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

android/src/main/java/com/geektime/rnonesignalandroid/RNOneSignal.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public class RNOneSignal extends ReactContextBaseJavaModule implements Lifecycle
4848
private ReactApplicationContext mReactApplicationContext;
4949
private ReactContext mReactContext;
5050
private boolean oneSignalInitDone;
51-
private static boolean registeredEvents = false;
51+
private boolean registeredEvents = false;
5252

5353
//ensure only one callback exists at a given time due to react-native restriction
5454
private Callback pendingGetTagsCallback;
@@ -434,7 +434,8 @@ public String getName() {
434434

435435
@Override
436436
public void onHostDestroy() {
437-
437+
OneSignal.removeNotificationOpenedHandler();
438+
OneSignal.removeNotificationReceivedHandler();
438439
}
439440

440441
@Override

0 commit comments

Comments
 (0)