기본적인 웹사이트에서 링크, 즉 싸이트 연결은 <a> 태그를 사용하며, 이후 외부 이동은 JavaScript APIs로 window.history, window.locaton 을 사용합니다. 그러나 앱(App)에서는 Linking Library 또는 Web Browser Library 를 사용합니다.
iOS 계열은 Universal Links 라고 하며, Android 에서는 Deep Links 라고 합니다.
이러한 라이브러리들은 Linking library 도는 Web browser library 로 알려져 있습니다.
React Native 로 개발을 하는 경우는 Linking 이라는 클라스의 내장함수 openURL()이 "react-native" 있으므로 다음 처럼 불러 사용가능합니다.
import { View, Text, StyleSheet,Button, Linking} from "react-native";
<Button title="Korean Usage- 사용법" onPress={()=Linking.openURL("https://bill-splitor.tistory.com/2")} />
별도의 expo 용 라이브러리인, expo-linking 도 사용 할 수 있습니다. 이때는 npm install expo-linking 을 해야 합니다.
import {openURL} from 'expo-linking'
1. 웹 연결
<Button onPress={ ()=> openURL("https://bill-splitor.tistory.com/2")} title="사용법" />
2. email 연결
<Button onPress= { ()=> openURL("mailto:syngyang@gmail.com")} title="이메일" />
'개발관련' 카테고리의 다른 글
useFonts() (0) | 2024.04.04 |
---|---|
export { ErrorBoundary,} from 'expo-router' (0) | 2024.04.04 |
App Store Connect - asc - iOS (0) | 2024.03.20 |
eas submit --p ios (0) | 2024.03.20 |
...Platform.select() (0) | 2024.03.20 |