React-native-apple-authentication: Android Support

Created on 6 Apr 2020  路  23Comments  路  Source: invertase/react-native-apple-authentication

What's the best way to do sign-up/sign-in with Apple on Android?
Is there a plan to add Android support via webview in this project?

enhancement help wanted

Most helpful comment

If your app is available on multiple platforms (iOS, Android, web) and you add Sign-In with Apple on iOS, you will have to add it to all your platforms otherwise your users won't be able to sign in on other devices like an Android phone or web.

All 23 comments

How could you have a Apple ID set up in your Android phone ??

If your app is available on multiple platforms (iOS, Android, web) and you add Sign-In with Apple on iOS, you will have to add it to all your platforms otherwise your users won't be able to sign in on other devices like an Android phone or web.

There is support on the Apple side for other platforms, and documentation about it etc - but no plans within the maintainers here currently to implement them. I would love to see it personally, so it's more a matter of maintainer time + priorities than any specific reason. It's worth mentioning that the library (and it's integration with sister projects like react-native-firebase is to meet the hard requirement from Apple that you implement Apple Sign-in in your iOS app or you lose access to the store - so it's the most professional job possible to meet the minimum requirement possible

Building on other features (web support, android support) then is "nice to have" (maybe even "really nice to have") but hasn't received attention for that reason

PRs more than welcome!

This is not really an issue, it's just something the module doesn't do. PRs welcome but I don't want the issues list to turn into a todo list

Someone posted a comment to this but then perhaps deleted it? I got mail and I thought it was a great comment - there is an android library that we could probably wrap in a react-native module (either separate or under here) - the android library appears to be reasonably well maintained if someone wants to try it? https://github.com/willowtreeapps/sign-in-with-apple-button-android

Re-opening provisionally as the availability of an existing android implementation means the react-native side is infinitely more doable, wrapping an android library for use in react-native is not so hard

Hey @mikehardy i made the comment and deleted it since i stupidly thought it was irrelevant to the subject. Sorry about this. I really hope someone can port that library to rn.

I don't believe it would be a port, we would just wrap it here if someone proposed a PR. That library would become a gradle dependency of the project and we would just use it - PRs happily accepted. I thought your comment was great anyway :-)

Is it an idea to use a general purpose oAuth package, such as https://github.com/FormidableLabs/react-native-app-auth, and use that to implement login flows for all social providers? This saves installing an SDK for each provider. And works on both android and iOS.

That's definitely an idea and was first on my list for auth-related ideas but with this module integrated well enough in my project to get past apple app review, none of the auth-related list has priority for me now, but it's where I'd look if I were going to extend my projects sign-in coverage (either apple sign in available on android, or any other provider). Seems like that would be best done as a binding in react-native-firebase itself though (a related project) as there would be no real benefit to doing it here when your linked module already exists for the general react-native case, and this module exists for the specific case of intentionally exposing a wrapping of the native lib

We'd welcome a PR though that adds support for this on Android if anyone is interested in contributing :)

I'd like to see this happen soon.
Tried https://github.com/axxag/react-native-apple-authentication-android
which is react native wrapper of https://github.com/willowtreeapps/sign-in-with-apple-button-android
Had no luck configuring build.gradle file due to lack of android knowlege.

Any update for this?

@pacc-27 propose a PR and we'll merge it

For anyone else: there is no one working on this, unless they have said so here. No need to spam everyone asking for updates.

If someone starts work on it though, go ahead and comment here

There appears to be a working solution for Android, if someone (perhaps its author @spezzino ?) wanted to shape it up for PR here we could have Android support integrated:

https://github.com/invertase/react-native-firebase/pull/4188#issuecomment-685365205

@mikehardy Working on an integration now @ dburdan/react-native-apple-authentication based on the repo mentioned above. Have been running it in our staging environment for several days and no issues so far.

I namespaced all the Android functionality underneath a named export, which is a bit obtuse, but allows for full backwards compatibility. I also created a JS AppleButton implementation so the AppleButton import is cross-compatible without the need for an appleAuth.isSupported() check.

import { appleAuthAndroid } from '@invertase/react-native-apple-authentication';

const handleAppleLogin = async () => {
  appleAuthAndroid.configure({
    clientId: 'Client id',
    redirectUri: 'https://example.com/auth/callback',
    responseType: appleAuthAndroid.ResponseType.ALL,
    scope: appleAuthAndroid.Scope.ALL,
    nonce: 'Random nonce value, will be SHA256 hashed before sending to Apple',
    state: 'State',
  });
  const response = await appleAuthAndroid.signIn(); // user, state, id_token, code
  // Can now send the authorization code to your backend for verification
}
...

<AppleButton
  buttonType={AppleButton.Type.SIGN_IN}
  buttonStyle={AppleButton.Style.BLACK}
  cornerRadius={3}
  onPress={handleAppleLogin}
/>

Still a few things I need to finish before I send a PR, such as documenting the new functionality and clarifying the Apple-side setup process.

That's amazing! Just for reference I personally have a similar policy to react-native-webview where I do not mind releasing breaking change, but I will always follow sem-ver (with a major version) if I/we issue it. So if you think maintaining backwards compatibility isn't worth the tradeoff, it's okay to do something breaking - we'll just post a migration doc with easy to follow steps and do a major version. I am not advocating that, just saying it is a possible path.

All in all though this seems like a fine approach and it's really exciting that it's happening! :-). Cheers

Fixed in #136 beta coming shortly

We need testers! https://github.com/invertase/react-native-apple-authentication/releases/tag/v2.0.0-beta.0

Please try v2.0.0-beta.0 post success reports or noticed issues (ideally with PRs 馃檹 to fix 馃槄 )

I will release this in a week either way, so if there are any problems let's discover them and fix them quickly

Thanks!

Sorry for posting on a closed issue, but, thanks for the android support! I was following this issue for some time and I got very happy now to see that it got resolved. Thanks! :)

That reminds me, I need to release it :-), any success reports out there? failure reports?

@mikehardy I've been following this issue and finally got the time to implement it on our Android app. Happy to report it's working like a charm! Somehow the Apple logo does not show up on the button, but I'm looking into it.

@habovh check to see if you are affected by this thing that sort-of shocked me about resource include on android and how asset minimization works / interacts with standard react-native projects https://twitter.com/fastsquatch/status/1196475279688028160 (that's just me on twitter, not a total random person, although I am still just some person on the internet ;-) )

Was this page helpful?
0 / 5 - 0 ratings