Skip to content

Commit

Permalink
Clean handler before set
Browse files Browse the repository at this point in the history
* Avoid handlers being set more that once, native side will keep reference too all handlers set
  • Loading branch information
Jeasmine committed Jul 26, 2021
1 parent 8539ecb commit 2154c41
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ private void setAppId(MethodCall call, Result reply) {
}

private void addObservers() {
// Clean observers before setting, avoid being call twice
OneSignal.removeSubscriptionObserver(this);
OneSignal.removeEmailSubscriptionObserver(this);
OneSignal.removeSMSSubscriptionObserver(this);
OneSignal.removePermissionObserver(this);

OneSignal.addSubscriptionObserver(this);
OneSignal.addEmailSubscriptionObserver(this);
OneSignal.addSMSSubscriptionObserver(this);
Expand Down

0 comments on commit 2154c41

Please sign in to comment.