millo-L / react-native-kakao-share-link

리액트 네이티브 카카오 링크 오픈 소스
MIT License
30 stars 24 forks source link

카카오톡이 설치되어 있지 않은 경우 #5

Closed BeingApple closed 2 years ago

BeingApple commented 2 years ago

안녕하세요 개발자님

카카오 SDK 업데이트 후 사용할 마땅한 카카오 링크 라이브러리를 찾고 있는 찰나에 해당 라이브러리를 발견하여 유용하게 사용 중에 있습니다. 유용한 라이브러리 제작 감사드립니다!

공유드리고 싶은 이슈는 현재 라이브러리에서는 카카오톡 설치가 안 되어있는 경우 카카오톡 설치가 안 되어있다는 에러를 반환하고 있는데요, 카카오 링크는 웹을 통한 공유 역시 지원하고 있어서 그 부분에 맞춰 수정을 하면 어떨까 건의 드립니다.

다음과 같이 설치되어있지 않은 경우에 대한 예제가 기술되어있습니다. 링크 참고 부탁드립니다.

// 카카오톡 설치여부 확인
if LinkApi.isKakaoLinkAvailable() {
    // 카카오톡으로 카카오링크 공유 가능
    // templatable은 메시지 만들기 항목 참고
    LinkApi.shared.defaultLink(templatable: templatable) {(linkResult, error) in
    if let error = error {
        print(error)
    }
    else {
        print("defaultLink() success.")

        if let linkResult = linkResult {
            UIApplication.shared.open(linkResult.url, 
                            options: [:], completionHandler: nil)
        }
    }
}
else {
    // 카카오톡 미설치: 웹 공유 사용 권장
    // Custom WebView 또는 디폴트 브라우져 사용 가능
    // 웹 공유 예시 코드
    if let url = LinkApi.shared.makeSharerUrlforDefaultLink(templatable: templatable) {
        self.safariViewController = SFSafariViewController(url: url)
        self.safariViewController?.modalTransitionStyle = .crossDissolve
        self.safariViewController?.modalPresentationStyle = .overCurrentContext
        self.present(self.safariViewController!, animated: true) {
            print("웹 present success")
        }
    }
}
millo-L commented 2 years ago

업데이트 됐습니다~~ 1.0.5 버전으로 업데이트 해주세요. 다만 ios의 경우 시뮬레이터에서는 제대로 작동하지 않고 기기에서만 정상작동합니다.

BeingApple commented 2 years ago

@millo-L 빠른 수정 감사합니다~ 적용해볼게요!