ios-sdk
ios-sdk copied to clipboard
isContainer instance method on SPTAppRemoteContentItem always returning false
Hi Spotify,
Either I'm misundertstanding the functionality of the container property and the isContainer instance function, but album and playlists returned from fetchRecommendedContentItems.
For example, items with the following URIs: spotify:album:2eV6DIPDnGl1idcjww6xyX spotify:playlist:37i9dQZF1E36hcdEVedX5L
both return false for SPTAppRemoteContentItem#isContainer
This can also be demonstrated in the NowPlaying demo app from this repo. Playlists and Albums selected in the Content view NEVER open a new UICollectionViewController but play the first track from the collection instead.
Am I missing something? Is the container property meant for a different type of ContentItem that is NOT an album or playlist?
Hi. I understand your confusion around this. The documentation around the container concept is lacking.
From digging around a bit I understand that isContainer
will be true if the content item itself is not directly playable. An album or a playlist is playable as opposed to a "container" that holds an arbitrary list of playable or non playable children.
So, you should not use isContainer
as a source of truth on whether or not a content item holds any children.
You might want to consider explicitly fetching children for certain content items.
Regarding the NowPlaying sample app. The reason that you're not getting any containers in the default implementation is that the initial fetch is performed with the flattenContainers
flag set to true
.
appRemote?.contentAPI?.fetchRecommendedContentItems(forType: SPTAppRemoteContentTypeDefault,
flattenContainers: true) { ... }
Flattening containers will fetch all of the top content items' children and return a list of all of the children instead of returning just the top content items.
Thanks for the clarification! Yes, the documentation is severely lacking; I poked around for quite some time to understand what container meant in the SDK context and could find nothing so I had to rely on my own understanding. Anything I can do to help remedy this for others?