Linking 을 통해 문자 애플리케이션 열기

minsoo-web·2021년 12월 3일
1

react-native

목록 보기
1/1
post-thumbnail
import { Linking } from "react-native";

최상단에서 Linking 을 가져온 뒤

<Styled.AlertButtonWrapper
	onPress={() =>
  		Linking.openURL(`sms:112${SMSDivider}body=문자내용`)}
  	style={{ marginLeft: vw(19) }}>
	<Styled.AlertButtonLabel>112 문자 신고</Styled.AlertButtonLabel>
</Styled.AlertButtonWrapper>

이렇게 onPress 이벤트와 연결시켜줍니다.
여기서 주목해야 하는 점이 (제가 이 글을 적고 있는 이유)
SMSDivider 입니다.

컴포넌트 최상단에 다음과 같은 상수 값을 선언해주세요

import { Linking, Platform } from 'react-native';

const SMSDivider: string = Platform.OS === 'android' ? '?' : '&';

aos와 ios는 이렇게 또 저희를 괴롭혔습니다.

profile
개인 공부 정리 블로그 입니다.

0개의 댓글