File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
android/src/main/java/com/onesignal/flutter Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 11os :
22 - linux
33sudo : false
4+ dist : trusty
45addons :
56 apt :
67 # Flutter depends on /usr/lib/x86_64-linux-gnu/libstdc++.so.6 version GLIBCXX_3.4.18
@@ -16,4 +17,4 @@ script:
1617 - ./flutter/bin/flutter test
1718cache :
1819 directories :
19- - $HOME/.pub-cache
20+ - $HOME/.pub-cache
Original file line number Diff line number Diff line change 3030import io .flutter .plugin .common .MethodChannel ;
3131import io .flutter .plugin .common .MethodChannel .MethodCallHandler ;
3232import io .flutter .plugin .common .MethodChannel .Result ;
33+ import io .flutter .plugin .common .PluginRegistry ;
3334import io .flutter .plugin .common .PluginRegistry .Registrar ;
35+ import io .flutter .view .FlutterNativeView ;
3436
3537/** OnesignalPlugin */
3638public class OneSignalPlugin
@@ -61,6 +63,18 @@ public static void registerWith(Registrar registrar) {
6163 plugin .channel .setMethodCallHandler (plugin );
6264 plugin .flutterRegistrar = registrar ;
6365
66+ // Create a callback for the flutterRegistrar to connect the applications onDestroy
67+ plugin .flutterRegistrar .addViewDestroyListener (new PluginRegistry .ViewDestroyListener () {
68+ @ Override
69+ public boolean onViewDestroy (FlutterNativeView flutterNativeView ) {
70+ // Remove all handlers so they aren't triggered with wrong context
71+ OneSignal .removeNotificationReceivedHandler ();
72+ OneSignal .removeNotificationOpenedHandler ();
73+ OneSignal .removeInAppMessageClickHandler ();
74+ return false ;
75+ }
76+ });
77+
6478 OneSignalTagsController .registerWith (registrar );
6579 }
6680
You can’t perform that action at this time.
0 commit comments