I don't know if this is related to the OS version (iPadOS 16.1) but this used to work for me before on this particular device.
I'm doing this: try await MPMediaLibrary.default().addItem(withProductID: catalogId)
where catalogId
is a valid ID I got from MusicKit.
This throws the following error:
Error Domain=MPErrorDomain Code=0 "An unknown error occurred." UserInfo={NSLocalizedDescription=An unknown error occurred., NSUnderlyingError=0x2814a1b60 {Error Domain=ICCloudClientErrorDomain Code=2003 "Attempting to retrieve handler for an unsupported configuration" UserInfo={NSLocalizedFailureReason=An ICCloudClient (or HSCloudClient) instance is using a signed-out user identity., NSLocalizedRecoverySuggestion=Listen to ICActiveUserIdentityDidChangeNotification and either update ICCloudClient with the new active account or recreate it, NSLocalizedDescription=Attempting to retrieve handler for an unsupported configuration}}}
Not a single Google result for that.
The same code on an iPhone with iOS 16.0 works just fine.
I tried observing for Notification.Name("ICActiveUserIdentityDidChangeNotification")
but that doesn't seem to be fired.