iosdeep-linkingurl-schemeassociated-domains

What's the role of callbackURLScheme in ASWebAuthenticationSession/SFAuthenticationSession?


I am quite surprise I can't fine any more or less clear explanation of how exactly the logic with callbackURLScheme (incl. completionHandler) works.

Yes, in general, it's kind of clear that it has something with the url schema, which can be specified in plist file, and the way Deep Linking works.

However,

Really appreciate the answers!


Solution

  • The ASWebAuthenticationSession is really shrouded in mystery a bit. Swift header can shed some light. (Jump to definition: Command + right click on ASWebAuthenticationSession class in Xcode)

    On completion, the service will send a callback URL with an authentication token, and this URL will be passed to the app by ASWebAuthenticationSessionCompletionHandler. The callback URL usually has a custom URL scheme. For the app to receive the callback URL, it needs to either register the custom URL scheme in its Info.plist, or set the scheme to callbackURLScheme argument in the initializer.

    Actually my test shown that on ios 14 it works as described. You need either register custom URL scheme and provide nil for corresponding argument or just put the argument. Or both. Completion on successful login is called as expected. It is not mentioned in the documentation with such details.