mongodb-realmmongodb-authentication

Authentication fails with error "unsupported URL" in MongoDB Realm iOS SDK


I am trying to authenticate into my MongoDB Realm app anonymously through the Realm iOS SDK, but I am getting the following error:

Task <CFE450BE-FF58-4A89-B310-4DCFCBF692BA>.<1> finished with error [-1002] Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" UserInfo={NSUnderlyingError=0x600000890a50 {Error Domain=kCFErrorDomainCFNetwork Code=-1002 "(null)"}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <CFE450BE-FF58-4A89-B310-4DCFCBF692BA>.<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <CFE450BE-FF58-4A89-B310-4DCFCBF692BA>.<1>"
), NSLocalizedDescription=unsupported URL}

Login failed: Error Domain=realm::app::CustomError Code=-1002 "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, realm::app::CustomError=code -1002}

I installed the Realm iOS SDK with Carthage, and I am using version v10.15.1 of the SDK.

I've tried searching forums online but I can't find anything referencing this error.


Solution

  • I figured out the problem. When creating the realm app like below:

    let realmApp = App(id: getRealmAppID())
    

    I was reading the realm app ID of my Realm app from a text file, which included a newline character at the end. I stripped the newline character from the end of the retrieved ID, and no more error!