Reputation: 31
I have an auth flow using react-native-inappbrowser-reborn. I have the redirect deeplink set up and working for both Android and iOS debug build. However on android when I build release, after login success the browser instantly dismiss and response:
{"message": "chrome tabs activity destroyed", "type": "dismiss"}
the redirect deeplink is demo://success?token='abc'
it work fine both iOS and android debug build and also iOS release build except android
AndroidManifest.xml
<intent-filter android:label="demo app">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="demo" android:host="success"/>
</intent-filter>
My login
onPress={async () => {
try {
//when login success web will redirect to this demo://sucess?token='abc'
//Config.baseUrlTwo = "https://demo.com/"
const browser = await InAppBrowser.openAuth(Config.baseUrlTwo + "oauth/authenticate",
"demo://success",
{ forceCloseOnRedirection: false, showInRecents: true }
);
if (browser && browser.type === "success") {
let token = "";
let getToken = browser.url.match(/'([^']+)'/g) || [];
if (getToken.length) {
getToken = getToken.map((match) => match.slice(1, -1));
token = getToken[0];
} else if (browser.url.includes("%27")) {
getToken = browser.url.split("%27") || [];
if (getToken.length) {
token = getToken[1];
}
}
if (token !== "") {
props.dispatch(Login({ token, ...props }));
}
} else {
Alert.alert(JSON.stringify(browser));
}
} catch (error) {
Alert.alert(error.message);
}
}}
I have no idea where this bug come from
Upvotes: 2
Views: 530
Reputation: 143
Please make sure:
await InAppBrowser.isAvailable()
demo://success
is working in Release App. Try enter that url in a note app and press the link if it can start the AppforceCloseOnRedirection
to true or false.Bonus: As per their document, please also try adding RNInAppBrowserModule.onStart(this);
, it will helps checking if the browser is supported/available and starting it as soon as the App start.
Upvotes: 0