does anyone know how to use React navite Webview and expo intent-launcher to open an app (kakaopay, naver pay, payco…?).
I have no idea why this doesn’t work (it works on iOS with just Linking.openURL(url)), but on android nothing works yet
Here my basic config: (“react-native”: “0.74.3”, “expo”: “~51.0.22”)
import * as IntentLauncher from "expo-intent-launcher";
const payUrl = "https://......."
pay
const onShouldStartLoadWithRequest = (event: any) => {
console.log(event);
const url = event.url || "";
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("about:blank")) {
return true;
}
console.log("url", url);
if (Platform.OS === "android") {
try {
IntentLauncher.startActivityAsync("android.intent.action.VIEW", {
data: url,
})
.then(() => {
console.log("Payment gateway opened successfully");
})
.catch((error) => {
console.error("Failed to open payment gateway:", error);
});
} catch (error) {
console.error("Error launching intent:", error);
}
return false;
} else {
Linking.openURL(url).catch((err) => {
console.log({ err });
Alert.alert(
"App execution failed. If it is not installed, please press the install button."
);
});
return false;
}
};
return (
<View className="flex-1">
<WebView
ref={handleSetRef}
useWebKit={false}
scalesPageToFit={Platform.OS !== "ios"}
originWhitelist={["*"]}
source={{ uri: payU`your text`rl }}
javaScriptEnabled={true}
onLoad={NativeToWeb}
onError={errorHandler}
onMessage={WebToNative}
onNavigationStateChange={onNavigationStateChange}
onShouldStartLoadWithRequest={onShouldStartLoadWithRequest}
setSupportMultipleWindows={false}
javaScriptCanOpenWindowsAutomatically={true}
/>
</View>
);
I tried with the react-native-send-intent library
library, but as it’s not compatible with expo, I thought I’d try theirs (Expo IntentLauncher).
On iOS I have no problem, but when I launch with my android (device) after building an .apk, I get an error.
So I added packagaes in my AndroidManifest.xml for example:
<package android:name=“com.kakao.talk” />
<package android:name=“com.samsung.android.spay” />
But nothing works
Benjamin RAYMOND is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.