Skip to content

Commit

Permalink
[feat] AppleMusic destination 권한 추가 (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
BAEKYUJEONG committed Aug 23, 2024
1 parent 3638136 commit 0a0a1a8
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions PLUV/Move/MovePlaylistViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import UIKit
import MusicKit
import MediaPlayer

class MovePlaylistViewController: UIViewController {

Expand Down Expand Up @@ -230,13 +231,26 @@ class MovePlaylistViewController: UIViewController {
}

private func searchAPI() {
if sourcePlatform == .AppleMusic {
if sourcePlatform == .AppleMusic && destinationPlatform == .Spotify {
Task {
await self.searchAppleToSpotifyAPI(musics: self.viewModel.musicItems)
}
} else if sourcePlatform == .Spotify {
Task {
await self.searchSpotifyToAppleAPI(musics: self.viewModel.musicItems)
} else if sourcePlatform == .Spotify && destinationPlatform == .AppleMusic {
MPMediaLibrary.requestAuthorization { status in
switch status {
case .authorized:
// 권한이 부여된 경우
print("Apple Music authorization granted")
Task {
await self.searchSpotifyToAppleAPI(musics: self.viewModel.musicItems)
}
default:
DispatchQueue.main.async {
AlertController(message: "미디어 권한을 허용해야 사용할 수 있습니다.") {
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
}.show()
}
}
}
}
}
Expand Down

0 comments on commit 0a0a1a8

Please sign in to comment.