apple-sign-in
apple-sign-in copied to clipboard
Add android support
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>
Back button handling added
TODO
- documentation
- modify the authorization method name
@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!
@no-dap any updates? I see this PR has not been merged yet