How to remove my app from Now Playing Info?

Viewed 732

My app start playing music and it appears in Now Playing Info, but i can't find how to clean it all: destroy the player and remove my app from Now Playing Info.

The lib that i'm using have not implemented this and i know almost nothing about ios/swift. Here is the code.

This is the issue in the repo, if some mantainer see this.

And this is an ilustrative image of Now Playing Info

enter image description here

2 Answers

You have to call:

UIApplication.shared.endReceivingRemoteControlEvents()

This will remove the now playing info from your lock screen.

Swift

MPNowPlayingInfoCenter.default().nowPlayingInfo = nil

Source from the official Apple documentation:

/// The current now playing info for the center.
/// Setting the info to nil will clear it.
open var nowPlayingInfo: [String : Any]?
Related