Skip to content

Commit

Permalink
feat: 딥링크 전송 로직 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
chansooo committed Aug 23, 2024
1 parent 85bb202 commit ded5910
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
17 changes: 3 additions & 14 deletions Projects/Features/MemeDetail/Sources/MemeDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,9 @@ private extension MemeDetailViewModel {
}
}

@MainActor
func showShareSheet() async {
guard let url = URL(string: self.state.meme.imageUrlString) else {
print("invalid url")
return
}
do {
let (data, _) = try await URLSession.shared.data(from: url)
guard let image = UIImage(data: data) else {
print("invalid image data")
return
}
await self.router?.showShareView(items: [image])
} catch {
print("Failed to load image data: \(error)")
}
let deeplinkUrl = "https://farmeme.onelink.me/RtpU/y09dosru?deep_link_value=\(self.state.meme.id)"
self.router?.showShareView(items: [deeplinkUrl])
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,13 @@ private extension RecommendViewModel {
}
}

@MainActor
func showShareSheet(memeImageUrl: String?) async {
guard let memeImageUrl else { return }

guard let url = URL(string: memeImageUrl) else {
debugPrint("invalid url")
guard let memeId = self.state.recommendMemes.filter({ $0.imageUrlString == memeImageUrl }).first?.id else {
return
}
do {
let (data, _) = try await URLSession.shared.data(from: url)
guard let image = UIImage(data: data) else {
debugPrint("invalid image data")
return
}
await self.router?.showShareView(items: [image])
} catch {
debugPrint("Failed to load image data: \(error)")
}
let deeplinkUrl = "https://farmeme.onelink.me/RtpU/y09dosru?deep_link_value=\(memeId)"
router?.showShareView(items: [deeplinkUrl])
}

func saveMeme(memeId: String?) async {
Expand Down

0 comments on commit ded5910

Please sign in to comment.