Skip to content

openURL

지정된 URL을 기기의 기본 브라우저나 관련 앱에서 열어요. 이 함수는 react-nativeLinking.openURL 메서드를 사용하여 URL을 열어요.

시그니처

typescript
function openURL(url: string): Promise<any>;

파라미터

  • url필수 · string

    열고자 하는 URL 주소

반환 값

  • Promise<any>

    URL이 성공적으로 열렸을 때 해결되는 Promise

예제

외부 URL 열기

tsx
import { openURL } from '@granite-js/react-native';
import { Button } from 'react-native';

function Page() {
  const handlePress = () => {
    openURL('https://google.com');
  };

  return <Button title="구글 웹사이트 열기" onPress={handlePress} />;
}