-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
[REQUIRED] Step 1: Describe your environment
- Xcode version: Version 12.4
- Firebase SDK version: 7.9.1
- Installation method: Swift Package Manager
- Firebase Component: Auth
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
I'm trying to use Auth.auth().useUserAccessGroups across both iPhone and WatchOS apps to share authentication. The iPhone app initiates an anonymous sign in and should be sharing the user but the watch app returns nil.
- Setup an iPhone and WatchOS app and follow the following steps for cross app authentication https://firebase.google.com/docs/auth/ios/single-sign-on?authuser=0. I set up an app group and used that in both the iphone and watch app.
- In the iphone app, on init, utilize
signInAnonymouslyafter callingAuth.auth().useUserAccessGroup - In the watch os app, on init, check the currentUser value after calling
Auth.auth().useUserAccessGroup - Run the iphone app and then the watch os app. The watch os app will return nil for user
Relevant Code:
In iPhone app:
init() {
FirebaseApp.configure()
do {
Auth.auth().shareAuthStateAcrossDevices = true
try Auth.auth().useUserAccessGroup("APP_GROUP_NAME")
} catch let error as NSError {
print("Error changing user access group: %@", error)
}
if Auth.auth().currentUser === nil {
Auth.auth().signInAnonymously()
}
print(Auth.auth().currentUser?.uid, "user")
}
In watch app:
init() {
FirebaseApp.configure()
do {
Auth.auth().shareAuthStateAcrossDevices = true
try Auth.auth().useUserAccessGroup("APP_GROUP_NAME")
print(Auth.auth().currentUser?.uid, "user")
} catch let error as NSError {
print("Error changing user access group: %@", error)
}
}