How to initiate call of handleRemoteNowPlayingActivity function.
I try to play an audio file with AVAudioPlayer in my iPhone app and I expect that this function will be called on watches.
Maybe I should make some additional call to trigger this function? I cannot find any additional information about this method except what is said in the apple documentation.
Maybe someone faced this problem and will be able to help me.
Code of initialization audio player.
@IBAction func play(_ sender: Any) {
let url = URL(string: Bundle.main.path(forResource: "music", ofType: "mp3") ?? "")!
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default, options: .mixWithOthers)
try AVAudioSession.sharedInstance().setActive(true)
player = try AVAudioPlayer(contentsOf: url)
} catch let error {
print(error)
}
player?.play()
}