apple-sign-in icon indicating copy to clipboard operation
apple-sign-in copied to clipboard

Add android support

Open no-dap opened this issue 5 years ago • 4 comments

Based on Apple's JS support, Add activity with a web view to request authorization && get the result from callback API.

Authorization request will be fired by SignInWithApple.AuthorizeAndroid().

const { SignInWithApple, Device } = Plugins;

const info = await Device.getInfo();
switch (info.platform) {
  case 'ios':
    const appleUser = await SignInWithApple.Authorize();
    // ...
    break;
  case 'android':
    const androidUser = await SignInWithApple.AuthorizeAndroid({
      // Every implementation is same as Apple's JS support
      clientId: [ClientId],
      redirectURI: [RedirectURI],
      responseType: [ResponseType],
      scope: [Scope],
      responseMode: [ResponseMode],
    });
    // ...
    break;
}

Authorization result will be sent to callback API, so I add a javascript interface to handle it inside the web view.

Callback API can simply return a value to android via window.responseHandler, something like

<script>
    window.responseHandler.setResult('{your_result}');
    window.close();
</script>

no-dap avatar Nov 16 '20 08:11 no-dap

Back button handling added

no-dap avatar Nov 16 '20 09:11 no-dap

TODO

  • documentation
  • modify the authorization method name

no-dap avatar Dec 22 '20 03:12 no-dap

@no-dap based on the latest version, this library now has native web support.

Could you update your PR so it's based on the web support that is now already built in? Cheers!

mesqueeb avatar Feb 04 '21 14:02 mesqueeb

@no-dap any updates? I see this PR has not been merged yet

mirko77 avatar Apr 21 '21 14:04 mirko77