10

I'm getting error: 'playbackState' is only available in iOS 13.0 or newer

but MPNowPlayingInfoCenter.playbackState was used in my app for iOS 11.

This is issue of iOS 13? Can I handle it now?

was in iOS11:

@available(iOS 5.0, *)
open class MPNowPlayingInfoCenter : NSObject {

    open class func `default`() -> MPNowPlayingInfoCenter

    open var nowPlayingInfo: [String : Any]?

    open var playbackState: MPNowPlayingPlaybackState
}

now in iOS 13:

@available(iOS 5.0, *)
open class MPNowPlayingInfoCenter : NSObject {

    open class func `default`() -> MPNowPlayingInfoCenter

    open var nowPlayingInfo: [String : Any]?

    @available(iOS 13.0, *)
    open var playbackState: MPNowPlayingPlaybackState
}
Dmytro
  • 101
  • 9

1 Answers1

1

I filed a bug report to Apple and below is the response from Apple Engineering:

This API is only supported on macOS and Catalyst. It was mistakenly marked available in a previous release, but it has been corrected. We were requested to not mark this API as available specifically for Catalyst, but macOS platform is the only place where this API works.

X. W
  • 331
  • 2
  • 14
  • Regardless of the response, it seems that setting `playbackState` is necessary for CarPlay to work as expected on versions of iOS before iOS 13, as was documented at the time. The [docs](https://developer.apple.com/documentation/mediaplayer/mpnowplayingplaybackstate?language=objc) also state iOS 11+ – Tad Jan 24 '20 at 12:27