EddyVerbruggen / cordova-plugin-safariviewcontroller

:tiger: :elephant: :crocodile: Forget InAppBrowser for iOS - this is way better for displaying read-only web content in your PhoneGap app
MIT License
282 stars 144 forks source link

Sign In With Apple - CompletionHandler #185

Closed snblackout closed 2 years ago

snblackout commented 2 years ago

Hello, I'm being forced to introduce a "Sign In With Apple" feature on a new app update. Since this is legacy still, I need a solution.

I've been able to implement the Sign In With Apple so far. But after Apple authenticates, it hits the redirect URL where we are suppose to handle the authentication data for handoff back to the app.

Problem is, Apple basically just loads the response from our API into the View. I've provided basic HTML response that I can format easily enough. I put in a "Close Window" button for Javascript, but tapping that, doesn't work. Safari View still remains open.

The only way that I can see is tapping "Done". That works if I instruct the user that yes, sign in is complete, you can now tap Done. Works, but would be better to be able to close the View after this redirect is called.

From what I can see, the events fired do not cover the final step of the navigation to the redirect url.

Any ideas to accomplish this? Anyone still around? :)

snblackout commented 2 years ago

For future visitors, this is basic pseudo code flow that I used:

  1. create a guid
  2. start a new persistent sign in session on your server
  3. pass guid as state value in apple ID authorize url
  4. open safari view to apple ID authorize url
  5. user does sign in flow
  6. in background, poll server for status on session guid
  7. depending on status of session guid on server (apple called your redirect URL), close View
  8. continue create account or sign in user in client/app side