728x90
반응형

일단 해당 작업을 완료하기위해, 백엔드에서 pg 사와 연동이 되어있는 uri 이 필요하다.

 

안드로이드에서

 

boolean java.lang.boolean.booleanvalue()

 

해당 에러때문에 애를 먹었다.

 

일단

 
import SendIntentAndroid from 'react-native-send-intent';

 

해당 npm 에 들어가서 깔아준다.

 

최근 RN 은

compile 을 쓰지않기에

 

로 수정해주고

 

settings.gradle 도 추가하지않았다.

 

MainApplication.java

 

에서도

 

import com.burnweb.rnsendintent.RNSendIntentPackage;

 

임포트만 해주고

 

 

패키지에 따로 추가해주지않았다.

 

<WebView
style={{ flex: 1, width: deviceWidth, height: deviceHeight }}
javaScriptEnabled
javaScriptCanOpenWindowsAutomatically={true}
onShouldStartLoadWithRequest={(event) => {
return onShouldStartLoadWithRequest(event);
}}
setSupportMultipleWindows={false}
source={{ uri: webUrl }}
onError={(err) => console.log('webview ERROR:::', err)}
onMessage={onComplete}
originWhitelist={['*']}
scalesPageToFit={true}
textZoom={100}
/>

 

해당 webview 의 소스코드이다.

 

const onShouldStartLoadWithRequest = useCallback((event) => {
if (event.url.indexOf('wowcomplete') > -1) {
onComplete();
return false;
}
if (
event.url.startsWith('http://') ||
event.url.startsWith('https://') ||
event.url.startsWith('about:blank')
) {
return true;
}
if (Platform.OS === 'android') {
SendIntentAndroid.openAppWithUri(event.url)
.then((isOpened) => {
console.log('isOpened :::::::', isOpened);
})
.catch((err) => {
console.log('openAppWithUri eror ::::', err);
});
return false;
} else {
Linking.openURL(event.url).catch((err) => {
// Alert.alert(
// '앱 실행에 실패했습니다. 설치가 되어있지 않은 경우 설치하기 버튼을 눌러주세요.',
// );
});
return false;
}
}, []);

 

 

onShouldStartLoadWithRequest

 

함수이다.

 

onShouldStartLoadWithRequest

 

callback은 boolean을 리턴해주고, 

 

해당 boolean으로 로딩전에 콜백을 실행하고 로딩을 더 할지말지를 해주는 함수이다.

 

해당 코드들로 하면 안드로이드에서는 정상작동한다.

 

물론 manifest 에 permission들을 추가해줘야한다.

728x90
반응형

+ Recent posts