Hey,
I’m having hard time importing a SDK file written in JS code.
I’m using React Native and Expo to make an app, and there’s no html file or native code in this project.
1. First Attempt :
import * as kakao from "./kakao_sdk/KakaoSdk.js"
this caused an error saying
kakao can’t find variable: location error
2. Second Attempt :
I tried to use WebView, but in this case, I’m not sure how to make this codes working in my environment.
Below is the code I tried.
import * as React from "react";
import { WebView } from "react-native-webview";
export default class WebViewSample extends React.Component {
render() {
const html = `
<html>
<head>
<script type="text/javascript" src='./kakao_sdk/KaKaoSdk.js'></script>
<script>
Kakao.init('personal key will be here');
console.log(Kakao.isInitialized());
</script>
</head>
<body>
some text that is not important now
</body>
</html>
`;
return (
<WebView
originWhitelist={["*"]}
source={{ html, baseUrl: "" }}
style={{ flex: 1 }}
javaScriptEnabled={true}
mixedContentMode='always'
/>
);
}
}
This gives no error, but seems like script tag is not working at all.
Any help would be appreciated. Thank you.