Skip to content

Commit

Permalink
feat/#273 카카오톡 딥링크 구현성공
Browse files Browse the repository at this point in the history
  • Loading branch information
hooni0918 committed Aug 2, 2024
1 parent e53ad5e commit 0629af8
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
2 changes: 1 addition & 1 deletion KkuMulKum/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
DispatchQueue.main.async {
if success {
print("Auto login successful, showing main screen")
self?.showLoginScreen()
self?.showMainScreen()
} else {
print("Auto login failed, showing login screen")
self?.showLoginScreen()
Expand Down
5 changes: 4 additions & 1 deletion KkuMulKum/Source/MyPage/View/MyPageEtcSettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import SnapKit
import Then

class MyPageEtcSettingView: BaseView {

let kakaoShareTapped = ObservablePattern<Void?>(nil)

let stackView = UIStackView(axis: .vertical).then {
$0.spacing = 24
$0.distribution = .fillEqually
Expand Down Expand Up @@ -74,7 +77,7 @@ class MyPageEtcSettingView: BaseView {

switch index {
case 0:
print("버전정보 탭됨")
kakaoShareTapped.value = ()
case 1:
print("이용약관 탭됨")
case 2:
Expand Down
2 changes: 1 addition & 1 deletion KkuMulKum/Source/MyPage/View/MyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MyPageView: BaseView {
private let topBackgroundView = UIView(backgroundColor: .white)
private let contentView = MyPageContentView()
private let alarmView = MyPageAlarmSettingView()
private let etcSettingView = MyPageEtcSettingView()
let etcSettingView = MyPageEtcSettingView()

override func setupView() {
backgroundColor = .green1
Expand Down
47 changes: 44 additions & 3 deletions KkuMulKum/Source/MyPage/ViewController/MyPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//

import UIKit
import KakaoSDKCommon
import KakaoSDKTemplate
import KakaoSDKShare

class MyPageViewController: BaseViewController {
private let rootView = MyPageView()
Expand All @@ -14,8 +17,46 @@ class MyPageViewController: BaseViewController {
view = rootView
}


override func setupView() {
view.backgroundColor = .green1
setupNavigationBarTitle(with: "마이페이지")
}
view.backgroundColor = .green1
setupNavigationBarTitle(with: "마이페이지")

bindViewModel()
}

private func bindViewModel() {
rootView.etcSettingView.kakaoShareTapped.bind { [weak self] _ in
self?.shareKakaoTemplate()
}
}

private func shareKakaoTemplate() {
let templateId = 110759

if ShareApi.isKakaoTalkSharingAvailable() {
ShareApi.shared.shareCustom(templateId: Int64(templateId)) { [weak self] (sharingResult, error) in
if let error = error {
print("카카오톡 공유 실패: \(error)")
self?.showAlert(title: "공유 실패", message: "카카오톡 공유에 실패했습니다.")
}
else {
print("카카오톡 공유 성공")
if let sharingResult = sharingResult {
UIApplication.shared.open(sharingResult.url, options: [:], completionHandler: nil)
}
}
}
}
else {
print("카카오톡 미설치")
self.showAlert(title: "알림", message: "카카오톡이 설치되어 있지 않습니다.")
}
}

private func showAlert(title: String, message: String) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: "확인", style: .default, handler: nil))
present(alertController, animated: true, completion: nil)
}
}

0 comments on commit 0629af8

Please sign in to comment.