Notice
Recent Posts
Recent Comments
10-19 22:05
«   2025/10   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

YESHTML5

Linking 작업에서 React-Native코드 적용예 본문

React,React-Native

Linking 작업에서 React-Native코드 적용예

슬/도/아/밤/ 2022. 2. 10. 18:57
반응형
 
  const linkHandler = async (param) => {
    //Alert.alert('linkHandler', JSON.stringify(param, null, 1))
    const url = param?.replace(/.*?:\/\//g, '');
    const route = url.split('/')
    //*---페이지분기
    if (url.indexOf('board') !== -1) navigate(MENU.BOARD_VIEW, { 'comm_seq': 0, 'board_seq': route[1], user_seq: user_seq() });

    // 초기화
    Linking.removeEventListener('url', (event) => { linkHandler(event) });
  }
  useEffect(() => {
    Linking.getInitialURL()			// 최초 실행 시에 Universal link 또는 URL scheme요청이 있었을 때 여기서 찾을 수 있음 
      .then(value => { if (value) linkHandler(value) })
    Linking.addEventListener('url', (event) => {
      linkHandler(event.url?.replace(/.*?:\/\//g, ''));
    });
    return () => {
      Linking.removeEventListener('url', (event) => { linkHandler(event) });
    };
  }, [])
반응형
Comments