I tried this to separate remoteControlEvents and my code looks like
import Foundation
import PluggableApplicationDelegate
final class MusicControlsAppService: NSObject, ApplicationService {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
UIApplication.shared.beginReceivingRemoteControlEvents()
print("It has started!")
return true
}
func applicationDidEnterBackground(_ application: UIApplication) {
print("It has entered background")
}
override func remoteControlReceived(with event: UIEvent?) {
if event?.type == .remoteControl {
switch event!.subtype {
case .remoteControlPlay:
PlayerManager.shared.playTapped()
case .remoteControlPause:
PlayerManager.shared.pauseTapped()
case .remoteControlTogglePlayPause:
if PlayerManager.shared.isPauseActive {
PlayerManager.shared.playTapped()
} else {
PlayerManager.shared.pauseTapped()
}
case .remoteControlNextTrack:
PlayerManager.shared.nextTapped()
case .remoteControlPreviousTrack:
PlayerManager.shared.previousTapped()
default:
break
}
}
}
}
This gives error for the method Method does not override any method from its superclass , also when override keyword is removed it doesn't get calls.
Can you assist to solve this ? As of now I am keeping that method in the main App delegate which is subclass of PluggableApplicationDelegate which works.
I tried this to separate remoteControlEvents and my code looks like
This gives error for the method
Method does not override any method from its superclass, also whenoverridekeyword is removed it doesn't get calls.Can you assist to solve this ? As of now I am keeping that method in the main App delegate which is subclass of
PluggableApplicationDelegatewhich works.