-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync login state across all Apple user's devices #6924
Conversation
Thanks for the contribution! To fix the CI failure, run |
All formatted |
Thanks for this contribution! Since this adds a property to the public API, this will need to go through our internal API review process. I'll go ahead and start this process now :) |
Hey @rosalyntan just checking to see if there's an update. No rush, but it would be nice to point my project at the real Firebase repo again instead of my version :) |
Hey @joehinkle11, the proposal for this pull request is still in review but at this point is only missing one or two approvers. It's been taking a while mostly because people are in and out of work due to Thanksgiving. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your patience! The API proposal has been approved, so we can move forward with this now :)
@rosalyntan thank you, I'll update the PR with the feedback shortly |
updating to latest firebase master
@rosalyntan Okay I've merge the latest master into this PR, implemented those changes, and linted the code |
Thanks @joehinkle11 this is a really important enhancement for our app. We've long had many users that upgrade to a new device and are disappointed that they are no longer logged in and have lost all their data. Most of these users were either anonymous or have forgotten which provider they linked. We then have to spend a lot of time searching for their data. Having authentication shared across devices should resolve this and allow Firebase built apps to work like other apps such as Facebook (that keep the user logged in after upgrading to a new phone). I've been watching this PR for a while, would really appreciate if this could get approved and pushed along. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes! LGTM
@Ewarrender same here, I'm going to use it for my app appmakerios.com. I want users to be able to use and pay for products without needing to sign up, and anonymous users that sync across iCloud would make that possible |
I tried this in Firebase 7.4 (release) and when signing in I get an error:
Are there any entitlements required for this feature to work? |
@xaphod I don't know if one is required, I'll try it tonight and see if what my project entitlements are. And I haven't seen it log anybody out. It would make sense that it'd log someone out if it is preferring iCloud keys over local ones. Then it would "sync" it to the logged out iCloud state. Maybe we need to make a migration path? So if it doesn't find a key on iCloud it automatically takes the local key and syncs that to iCloud? |
@joehinkle11 OK - the access group string that you use, is it arbitrary or does it represent something you created? |
@xaphod It's from this tutorial https://firebase.google.com/docs/auth/ios/single-sign-on |
It allows you to share the login state across the multiple apps on the same device |
Hi @xaphod, you can set up your Also, regarding the behavior you observed where a signed in user to become signed out, that is the behavior when switching from an unshared keychain to a shared keychain. You can find migration steps here: https://firebase.google.com/docs/auth/ios/single-sign-on#migrate_a_signed-in_user_to_a_shared_keychain
|
Here's what works for one of my sample apps:
do {
Auth.auth().shareAuthStateAcrossDevices = true
try Auth.auth().useUserAccessGroup("YG...HH4.com.yourcoolnewapp")
}
catch let error as NSError {
print("Error changing user access group: %@", error)
} Working on a blog post, should hopefully go out next week. |
Thanks everyone for the doc links - that's what I was missing. |
Hey - thank you so much - such a great implementation and beautiful addition. Worked a charm for me, and i used this to push AUTH to a Watch extension. |
Adding my thanks - this works well and is a nice way of reducing onboarding friction.
|
I used a similar approach to @xaphod for migrating as Add this string to your Info plist to avoid hardcoding the team id and keychain group id:
Then call this function on launch to enable the shared auth across devices and use the access group while keeping the user logged in:
|
This change doesn't effect the public API beyond the ability to flip the
shareLoginAcrossDevices
flag on the auth object, which will cause the keychain's credentials for the user to be synced across their iCloud, which effectively gives the user a shared login state across all their Apple devices.Works with anonymous logins too which I thought was pretty cool.
Example usage: