While setting up the controls for my notification,...
# ios
y
While setting up the controls for my notification, I'm struggling to understand why
addTargetWithHandler
requires a return type of
Long
, specifically
MPRemoteCommandHandlerStatus
. I’ve tried returning different values, and it seems to work regardless, but I’m unsure about what should actually be returned there. Can anyone explain?
Copy code
val commandCenter = MPRemoteCommandCenter.sharedCommandCenter()
with(commandCenter) {
    pauseCommand.addTargetWithHandler { event ->
        scope.launch {
            pause()
        }
        1
    }
}
r
https://developer.apple.com/documentation/mediaplayer/mpremotecommand/1622910-addtargetwithhandler > Call the addTargetWithHandler: method to add a block to be called. Remove the handler by calling the removeTarget: method, passing in the object returned by this method. It's just an ID to be able to call the sibling
remove
method
👍 1