Search code examples
swiftfirebasefirebase-authenticationtoday-extension

Firebase swift Cross-app user sharing not working


I am working on adding a Today extension for my app, which will need to use FirebaseAuth, so I followed the instructions on the Firebase Documentation and set up the Keychain access group by adding it in the Signing & Capabilities tab, where I wrote it in the format: {TEAM_ID}.com.{appOrg}.{appBundle}.{groupName} and initialized it using the code below in the didFinishLaunchingWithOptions of the AppDelegate of my app, and the viewDidLoad() of my today extension, called after FirebaseApp.configure() in both instances.

Here is the code:

do {
   try Auth.auth().useUserAccessGroup("{TEAM_ID}.com.{appOrg}.{appBundle}.{groupName}")
]} catch let error as NSError {
   print("Error changing user access group: \(error.code)")        
}

Both calls give me the same error code: 0, which also translates to The operation couldn’t be completed. when I use error.localizedDescription

Any idea how to fix this? Thanks in advance!

EDIT:

Not sure if it will make any difference, but my app is a Flutter app, though the today view and code aboce is in the swift files, called upon launch of the app.


Solution

  • So, after several attempts under my thoughts that it was my setup of the keychain group, it ended up being that I was calling the code too early (right after configuring the FirebaseApp), so it just failed. Moving the code out of viewDidLoad and into a method called by a method channel right before login (for the app) and before I needed the user to populate the today extension worked for me.