Skip to content

Commit

Permalink
Fix Bridge Reload Issue
Browse files Browse the repository at this point in the history
• 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.
  • Loading branch information
Nightsd01 committed Jul 31, 2018
1 parent 76299d1 commit afe2777
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class RNOneSignal extends ReactContextBaseJavaModule implements Lifecycle
private ReactApplicationContext mReactApplicationContext;
private ReactContext mReactContext;
private boolean oneSignalInitDone;
private static boolean registeredEvents = false;
private boolean registeredEvents = false;

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

@Override
public void onHostDestroy() {

OneSignal.removeNotificationOpenedHandler();
OneSignal.removeNotificationReceivedHandler();
}

@Override
Expand Down

0 comments on commit afe2777

Please sign in to comment.