Apple MusicKit Authorization errors with iOS 12 update - ios

I'm using the Apple MusicKit in my app. I had the authorization setup correctly and everything was working fine for a long time. Recently since the update to iOS 12 I'm seeing these errors
2018-12-02 19:16:46.511567-0500 Project2[30649:3022463] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2018-12-02 19:16:46.512835-0500 Project2[30649:3022463] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2018-12-02 19:16:46.518199-0500 Project2[30649:3022586] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2018-12-02 19:16:46.518407-0500 Project2[30649:3022586] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2018-12-02 19:16:46.524685-0500 Project2[30649:3022586] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
Is anyone else facing the same issue? Is there some change that I'm supposed to make? Or redo the token? I see this asked on the apple developers forum with no response https://forums.developer.apple.com/thread/105635

Related

ImagePicker: Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)"

I'm new to this but, I'm getting this error at the Image Picker and I'm stuck:
Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)"
PHPhotoLibrary.requestAuthorization gives me "authorized", so it seems no permission problem and I have the asset .Album being returned, but I can't load the images...

Making network request from iOS App Extension returns error: "A server with the specified hostname could not be found"

I'm trying to download a language translation model from Google MLKit. I can download the model successfully on the main iOS app, but when I try to download it on the keyboard extension app, I receive an error: "A server with the specified hostname could not be found."
testKeyboard[43687:3987699] [] networkd_settings_read_from_file Sandbox is preventing this process from reading networkd settings file at "/Library/Preferences/com.apple.networkd.plist", please add an exception.
testKeyboard[43542:3979636] [discovery] [d 6BF0C0BD-3B78-43CD-A23F-26023D59A4F3] <PKHost:0x283acc400> Failed discovery: Error Domain=PlugInKit Code=4 "Connection invalid" UserInfo={NSLocalizedDescription=Connection invalid}.
testKeyboard[43542:3979636] [xpc] XPC error sending request to pkd: Connection invalid
testKeyboard[43542:3979662] [] nw_resolver_can_use_dns_xpc_block_invoke Sandbox does not allow access to com.apple.dnssd.service
testKeyboard[43542:3979662] dnssd_clientstub ConnectToServer: connect() failed path:/var/run/mDNSResponder Socket:9 Err:-1 Errno:1 Operation not permitted
testKeyboard[43542:3979662] [connection] nw_resolver_create_dns_service_locked [C1] DNSServiceCreateDelegateConnection failed: ServiceNotRunning(-65563)
testKeyboard[43542:3979662] Task <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1> HTTP load failed, 0/0 bytes (error code: -1003 [10:-72000])
testKeyboard[43542:3979662] Task <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=-72000, NSUnderlyingError=0x2821c14a0 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorCodeKey=-72000, _kCFStreamErrorDomainKey=10}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDownloadTask <38FA4936-22C4-4E80-BECC-1D592945BE52>.<1>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=https://redirector.gvt1.com/edgedl/translate/offline/v5/high/r24/en_es.zip, NSErrorFailingURLKey=https://redirector.gvt1.com/edgedl/translate/offline/v5/high/r24/en_es.zip, _kCFStreamErrorDomainKey=10}
error downloading Optional(Error Domain=com.google.mlkit Code=2 "Failed to download the model from the server." UserInfo={NSLocalizedDescription=Failed to download the model from the server.})
I'm using the same code to download the model according to Google's "Translate Text with MLKit on iOS" documentation in the KeyboardViewController's viewDidLoad() function:
let options = TranslatorOptions(sourceLanguage: .english, targetLanguage: .spanish)
self.translator = Translator.translator(options: options)
let conditions = ModelDownloadConditions(allowsCellularAccess: true, allowsBackgroundDownloading: true )
self.translator!.downloadModelIfNeeded(with: conditions) { error in
guard error == nil else {
print("error downloading", error)
return
}
print("Model downloaded successfully")
}
My Info.plist settings are such:
"RequestsOpenAccess" as 1
"App Transport Security Settings" > "Allow Arbitrary Loads" as YES
I don't understand what is going on here. Why am I able to download the ML Kit language model on the main app, but not on the keyboard extension? Any help appreciated.
The issue is with your project's Sandbox settings. Go to your project page / Signing & Capabilities / App Sandbox (Xcode 13.2) and then enable Outgoing Connections (Client) which will allow your app to make http calls.

Application stop suddenly and getting NSURLErrorDomain error

I am using IOS 13.3 and my application stop suddenly after 6 month.
I have checked my certificate and found no issue in certificate.
i am getting the following error.
NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9816)
2020-04-17 01:38:14.778140+0530 Example[38000:704335] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> HTTP load failed (error code: -1200 [3:-9816])
2020-04-17 01:38:14.779009+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> finished with error - code: -1200
2020-04-17 01:38:14.782985+0530 Example[38000:704332] Task <71350D43-9801-46F2-9F9E-333AF09964CE>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." UserInfo={NSErrorFailingURLStringKey=https://api.example.com:1410/v1.1/users/signin, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, kCFStreamErrorDomainKey=3, NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <71350D43-9801-46F2-9F9E-333AF09964CE>.<1>"
), NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., NSErrorFailingURLKey=https://api.example.com:1410/v1.1/users/signin, NSUnderlyingError=0x600002db3d50 {Error Domain=kCFErrorDomainCFNetwork Code=-1200 "(null)" UserInfo={_kCFStreamPropertySSLClientCertificateState=0, kCFNetworkCFStreamSSLErrorOriginalValue=-9816, kCFStreamErrorDomainKey=3, kCFStreamErrorCodeKey=-9816}}, kCFStreamErrorCodeKey=-9816} [-1200]
Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made.
Here is the screenshot
I'm not sure how to solve it. Any ideas?
You probably need to reconfigure your SSL certificates. I know for TCP/TLS at least, with iOS 13 they imposed more restrictions on the certificates. I created a package to handle sockets on iOS - I also included a lot of good info about making certificates how you need to now.
https://github.com/eamonwhiter73/IOSObjCWebSockets/tree/master

MPMusicPlayerController fails to play from Apple Music

I'm trying to play songs from Apple Music and it is failing with the following logs:
2019-09-26 00:15:57.790999+0200 [1886:463973] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:15:57.791129+0200 [1886:463973] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:15:57.792655+0200 [1886:464074] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:15:57.792770+0200 [1886:464074] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:15:57.794124+0200 [1886:464074] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
2019-09-26 00:15:59.670842+0200 [1886:463973] [SDKPlayback] -[MPMusicPlayerController prependQueueDescriptor] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1 "No commands provided." UserInfo={NSDebugDescription=No commands provided.}
2019-09-26 00:15:59.671051+0200 [1886:463973] [SDKPlayback] -[MPMusicPlayerController prepareToPlay] completed id=applicationMusicPlayer error: Error Domain=MPMusicPlayerControllerErrorDomain Code=1 "prepareToPlay without a queue" UserInfo={NSDebugDescription=prepareToPlay without a queue}
2019-09-26 00:15:59.681627+0200 [1886:464074] [MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x282930a80 name=iPhone uid=LOCAL> origin=Nastasia's iPhone-1280262988 bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}
2019-09-26 00:15:59.681787+0200 [1886:464074] [SDKPlayback] -[MPMusicPlayerController play] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x281319230 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}
2019-09-26 00:16:03.596320+0200 [1886:464071] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.596374+0200 [1886:464071] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.597965+0200 1886:464051] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.598079+0200 [1886:464051] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.599416+0200 [1886:464074] [core] "Error returned from daemon: Error Domain=com.apple.accounts Code=9 "(null)""
2019-09-26 00:16:03.599456+0200 [1886:464074] SSAccountStore: Failed to fetch the backing accounts. error = Error Domain=com.apple.accounts Code=9 "(null)"
2019-09-26 00:16:03.599542+0200 [1886:464074] SSAccountStore: Unable to get the local account. error = Error Domain=SSErrorDomain Code=100 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store}
I also tried the official sample code project from Apple called Adding-Content-to-Apple-Music, and got similar results:
2019-09-25 23:20:37.268162+0200 [1738:432623] [RemoteControl] userIdentityForMediaRemoteOptions -❗️No user identity data. Using active account.
2019-09-25 23:20:37.333703+0200 [1738:432751] [SDKPlayback] -[MPMusicPlayerController prepareToPlayWithCompletionHandler:] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122" UserInfo={NSDebugDescription=Failed to send command 122, NSUnderlyingError=0x282eacff0 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2)" UserInfo={NSDebugDescription=Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=2}}}
2019-09-25 23:20:37.333721+0200 [1738:432562] [SDKPlayback] -[MPMusicPlayerController prepareToPlay] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122" UserInfo={NSDebugDescription=Failed to send command 122, NSUnderlyingError=0x282eacff0 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2)" UserInfo={NSDebugDescription=Failed to send command 122 (MRMediaRemoteCommandHandlerStatus = 2), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=2}}}
2019-09-25 23:20:37.337138+0200 [1738:432546] [MediaRemote] MRC <MPCPlayerPath: route=<MPAVEndpointRoute: 0x281498a80 name=iPhone uid=LOCAL> origin=Nastasia's iPhone-1280262988 bundleID=com.apple.MediaPlayer.RemotePlayerService playerID=MPMusicPlayerApplicationController>: Undo optimistic state [failed] command=Play error=Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}
2019-09-25 23:20:37.337529+0200 [1738:432562] [SDKPlayback] -[MPMusicPlayerController play] completed id=applicationMusicPlayer error: Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0" UserInfo={NSDebugDescription=Failed to send command 0, NSUnderlyingError=0x282ead260 {Error Domain=MPCPlayerRequestErrorDomain Code=1000 "Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1)" UserInfo={NSDebugDescription=Failed to send command 0 (MRMediaRemoteCommandHandlerStatus = 1), MPCPlayerErrorKeyMediaRemoteCommandHandlerStatus=1}}}
2019-09-25 23:20:37.342424+0200 [1738:432623] [Middleware] INVALIDATE: 0x2813842d0: Invalidated before returning a response. Re-requesting items.
2019-09-25 23:20:38.144321+0200 [1738:432323] [SDKPlayback] Failed validators id=applicationMusicPlayer: {(
play
)}
2019-09-25 23:20:38.944291+0200 [1738:432323] [SDKPlayback] Failed to get a valid response. Resetting expectations id=applicationMusicPlayer
The issue is sometimes randomly fixed by playing around with apps, going to Apple Music app, playing something there, killing it, coming back, and so on...
If someone has experienced similar issues then please let me know how to fix it.
Happens on iOS 12 & 13, iPhone 6s and iPhone 11, Apple Music account is in 3 months trial currently. All the music capabilities are present, being able to successfully get the developer token and music user token, both work fine with Apple Music API requests.
Seems like one of the reasons can be that I use musicPlayerController.prepend() function instead of setQueue(). Unfortunately, I was forced to use prepend() because of music player limitations.
Here is a short description of what my app needs to do:
The user starts playing a list of songs.
During the playback the app fetches a new list of songs from backend every 5-10 seconds and sets it as the new song queue. That means it is quite dynamic by means of what plays next.
Now when it comes to setting a new queue during playback, setQueue() is really bad at it. If I just call setQueue() then nothing will happen, the old queue will stay. However, if I call play() or prepareToPlay() after setQueue() then current playback will be stopped and the first song of the new queue will start playing. That's not what I want, I need to change the queue "behind the scenes" so that when the user hits "skip to next" in the app or iOS lock screen, then the new songs are playing. That's why I used prepend() - it works just fine, the current playback is not interrupted. The alternative - calling perform() on applicationQueuePlayer crashes with message "it takes too long" - deleting the old queue of 30 songs manually item-by-item is not that optimal, I guess.
So currently I see only one option - manually store a state which will tell if this is the first run or not. If yes, then call setQueue(), otherwise call prepend(). There is also no way to get the current queue to check myself if it is empty or not.
And regarding play() - it comes out to be not as simple function, as it seems. As I already mentioned above, play() triggers the new queue playback if I ever called setQueue() before. It was bringing me more problems because when I was calling setQueue() without play(), it was not doing anything, however each time I pressed pause/play - the player was jumping to the next song thanks to the earlier "silent" setQueue(). I had to implement another workaround of calling player.currentPlaybackRate = 1 instead of player.play(), which doesn't look nice. It would be great, if all this was somehow documented.

Firebase Connection error when date changed on device

I have setup my app's database on firebase. The app fetches data normally,
but when I change the date on device to 25th march,2019 or after that, it starts show error on console as below. Current date is 14th November, 2018.
Is there any kind of validation on firebase server.
[Firebase/InstanceID][I-IID003009] Failed to fetch default token Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={NSUnderlyingError=0x17025c0e0 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://device-provisioning.googleapis.com/checkin, NSErrorFailingURLKey=https://device-provisioning.googleapis.com/checkin, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=61, NSLocalizedDescription=Could not connect to the server.}
CFNetwork SSLHandshake failed (-9807)
By setting the date too far into the future you are preventing the SSL handshake from completing successfully.
The status code of -9807 indicates that something in the certificate chain is invalid; It is likely that a certificate in the chain expires before the 25th of March 2019. Because a certificate has expired, an SSL connection cannot be made.

Resources