결제 연동 문의 드립니다. (RN)

https://docs.tosspayments.com/guides/v2/webview#react-native
서 android, ios .

후 App.tsx


import React, {useEffect, useRef, useState} from 'react';
import {SafeAreaView, Platform, BackHandler, Alert} from 'react-native';
import {WebView} from 'react-native-webview';
import {ConvertUrl} from '@tosspayments/widget-sdk-react-native/src/utils/convertUrl';

const urlConverter = (url: string) => {
const convertUrl = new ConvertUrl(url);
if (convertUrl.isAppLink()) {
convertUrl.launchApp().then(isLaunch => {
if (isLaunch === false) {
console.log('.');
} else {
console.log('.');
}
});
return false;
} else {
return true;
}
};

... ...

const handleShouldStartLoadWithRequest = (event: any) => {
return urlConverter(event.url);
};

......

return (
<SafeAreaView style={{flex: 1, paddingTop: Platform.OS === 'ios' ? 20 : 0}}>
<WebView
ref={webViewRef}
source={{
uri: '뷰url',
}}
style={{flex: 1}}
onShouldStartLoadWithRequest={handleShouldStartLoadWithRequest}
onNavigationStateChange={onNavigationStateChange}
onMessage={onMessage}
injectedJavaScript={ window.alert = function(message) { window.ReactNativeWebView.postMessage(message); }; }
scalesPageToFit={false}
/>
</SafeAreaView>
);
};

.

.
KakaoTalk_Photo_2025-02-05-18-42-51.jpeg
(App to App) . 과 OS.
웹뷰(WebView) 연동하기 | 토스페이먼츠 개발자센터
Was this page helpful?