Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WebBrowser_kotlinVersion=1.3.50
WebBrowser_kotlinVersion=1.6.0
WebBrowser_compileSdkVersion=29
WebBrowser_targetSdkVersion=29
11 changes: 7 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppState, AppStateStatus, Linking, Platform } from 'react-native';
import { AppState, AppStateStatus, Linking, Platform, EmitterSubscription } from 'react-native';
import NativeWebBrowser from './NativeWebBrowser';
import {
RedirectEvent,
Expand Down Expand Up @@ -356,6 +356,9 @@ function _onAppStateChangeAndroid(state: AppStateStatus) {
}
}

// Event Emitter of react native `Linking`
let _linkingSubscription: EmitterSubscription;

async function _openBrowserAndWaitAndroidAsync(
startUrl: string,
browserParams: WebBrowserOpenOptions = {}
Expand Down Expand Up @@ -436,7 +439,7 @@ function _stopWaitingForRedirect() {
);
}

Linking.removeEventListener('url', _redirectHandler);
_linkingSubscription?.remove?.();
_redirectHandler = null;
}

Expand All @@ -450,6 +453,6 @@ function _waitForRedirectAsync(
}
};

Linking.addEventListener('url', _redirectHandler);
_linkingSubscription = Linking.addEventListener('url', _redirectHandler);
});
}
}