tony-yun
tony-yun6mo ago

@tosspayments/widget-sdk-react-native/src/utils/convertUrl 문의드립니다.

"react-native": "0.73.5", "@tosspayments/widget-sdk-react-native": "^1.2.7", ConvertUrl 함수 관련 문의 드립니다. (react native 의 iOS 플랫폼 코드) 예를 들어 페이북으로 결제 시도 시 웹뷰에서 앱으로 ispmobile 스킴이 넘어오는데,(url: ispmobile://vp?TID=NICETOKN......) 귀사 라이브러리의 launchApp 함수는 아래와 같이 구현이 되어있습니다.
else if (Platform.OS === 'ios') {
try {
const appLink = await this.getAppLink();
if (appLink) {
return Linking.openURL(appLink);
} else {
const marketUrl = await this.getMarketUrl();
return Linking.openURL(marketUrl);
}
else if (Platform.OS === 'ios') {
try {
const appLink = await this.getAppLink();
if (appLink) {
return Linking.openURL(appLink);
} else {
const marketUrl = await this.getMarketUrl();
return Linking.openURL(marketUrl);
}
appLink 가 기존의 스킴 주소 즉: ispmobile://... 로 설정되어 Linking.openURL 을 시도합니다. 만약 해당 페이북앱이 설치가 되어 있지 않을 경우, 열리지 않습니다. 즉 getAppLink 에서 ,
} else if (Platform.OS === 'ios') {
this.appLink =
this.appScheme === 'itmss' ? `https://${splitUrl[1]}` : this.url;
}
}

async getAppLink(): Promise<string | undefined> {
console.log('this.appLink:',this.appLink)
return this.appLink;
}
} else if (Platform.OS === 'ios') {
this.appLink =
this.appScheme === 'itmss' ? `https://${splitUrl[1]}` : this.url;
}
}

async getAppLink(): Promise<string | undefined> {
console.log('this.appLink:',this.appLink)
return this.appLink;
}
this.appLink = this.url 이며, Linking.openURL(ispmobile://...) 를 시도하기 때문에, 앱에서는 마켓으로 이동을 못합니다. 호출하는 부분은 아래와 같이 '웹뷰 연동하기' 페이지의 제시된 코드를 그대로 사용하고 있습니다.
const convertUrl = new ConvertUrl(url)

if (convertUrl.isAppLink()) {
convertUrl.launchApp().then((isLaunch) => {
if (isLaunch === false) {
}
})
} else {
return true
}
const convertUrl = new ConvertUrl(url)

if (convertUrl.isAppLink()) {
convertUrl.launchApp().then((isLaunch) => {
if (isLaunch === false) {
}
})
} else {
return true
}
사용자가 페이북앱을 설치 하지 않았을 때 마켓 페이지로 이동하게 하는 것이 목표입니다. Linking.openURL 로 열리지 않을때 catch 문으로 안넘어가고 그 자리에서 Promise Rejection 을 반환합니다. Possible Unhandled Promise Rejection (id: 16): Error: Unable to open URL: ispmobile://vp?TID=NICETOKN......
12 Replies
토스페이먼츠 BOT
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) : - 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요. * 주말/공휴일에는 답변이 늦을 수 있어요.
이실장
이실장6mo ago
if (convertUrl.isAppLink()) {
convertUrl.launchApp().then((isLaunch) => {
if (isLaunch === false) {
}
})
} else {
return true
}
if (convertUrl.isAppLink()) {
convertUrl.launchApp().then((isLaunch) => {
if (isLaunch === false) {
}
})
} else {
return true
}
여기서 else로 절대 안떨어진다는 말씀이신가요?
Kimoon Lee
Kimoon Lee6mo ago
이페이지에서 "앱다운로드" 를 누르시면 마켓으로 이동하지 않으시나요?
Kimoon Lee
Kimoon Lee6mo ago
No description
tony-yun
tony-yun6mo ago
네 맞습니다 앱다운로드를 누르면 이동합니다. 다만 유저가 자기 폰에 '페이북'앱이 설치가 안된걸 인지 못했을 경우 '결제하기' 버튼을 누르는데, 그 상황에서 설치안됐을 시 앱스토어로 이동시키고 싶어서 각종 방법을 찾고 있었습니다.
Kimoon Lee
Kimoon Lee6mo ago
네 이부분은 저희 가이드 코드에서 제공하고 있지 않은 내용입니다.
이실장
이실장6mo ago
그럼 이거보고 한번 해보시겠어요. 조건문 받아서, market url에 packagename담아서 보내면됩니다.
이실장
이실장6mo ago
아 지금 ios 문의주시는군요 ios는 절대 불가합니다. ios는 앱스킴이 앱스토어 정보를 가지고 있지 않습니다. 이에 구현을 하더라도 하드코딩으로 일일히 구현해주셔야해요
tony-yun
tony-yun6mo ago
네 react native 에서 ios 부분입니다. widget-sdk-react-native의 ConvertUrl클라스 launchApp함수에서 Linking.canOpenUrl 로 판단 (url 주소가 앱스킴일 경우 당연히 false 반환) 하면 안될까요?
const appLink = await this.getAppLink();
if (Linking.canOpenURL(appLink)) {
return Linking.openURL(appLink);
} else {
const marketUrl = await this.getMarketUrl();
return Linking.openURL(marketUrl);
}
const appLink = await this.getAppLink();
if (Linking.canOpenURL(appLink)) {
return Linking.openURL(appLink);
} else {
const marketUrl = await this.getMarketUrl();
return Linking.openURL(marketUrl);
}
이실장
이실장6mo ago
false로 반환해도 getMarketUrl() 로직에 이슈가 있어서 저희쪽에서 제거될 예정이에요.ㅣ 우선 당장 지원은 어려운 점 양해바라며, 대부분 가맹점도 ios 이용시 별도 appstore링크를 제공하지 않습니다.
tony-yun
tony-yun6mo ago
넵 우선은 상황 알겠습니다. 답변 감사드립니다.
토스페이먼츠 BOT
❤️ 기술문의 경험이 어떠셨나요?!
간단히 코멘트 남겨주세요! 제품 발전에 큰 힘이 됩니다.