I use Firebase Auth plugin for Flutter in order to sign in with Google in my app, and it works fine in both iOS and Android.
My problem starts when I try to use Firebase Auth in my iOS "Share Extension". I am new to iOS so I am not really familiar with Swift and Xcode, but as far as I understand I should enable cross-app authentication with shared iOS Keychain in order to authenticate the user in my shared extension.
I have 2 targets in my project, the "Runner" and the "Share Extension" so I have enabled the Keychain Sharing for both of them:
When the Keychain Sharing is enabled, I get the following error when I try to sign in using Firebase Auth:
Unhandled Exception: PlatformException(ERROR_KEYCHAIN_ERROR, An error occurred when accessing the keychain. The @c NSLocalizedFailureReasonErrorKey field in the @c NSError.userInfo dictionary will contain more information about the error encountered, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
<asynchronous suspension>
#2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
#3 MethodChannelFirebaseAuth.signInWithCredential (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)
#4 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:208:10)
#5 signInWithGoogle (package:matkonit/google_sign_in.dart:17:45)
<asynchronous suspension>
#6 LoginPageState.signInButton.<anonymous closure>.<anonymous clo<…>
This is what I get when I print the NSLocalizedFailureReasonErrorKey:
SecItemCopyMatching (-34018)
What can I do in order to fix this?
Edit: I have noticed that restarting the simulator makes the sign in work, but only sometimes... I couldn't figure out why.
I didn't add the Team ID prefix before my App ID, so it didn't work. You need to have an Apple Developer Account and a Team ID in order to do this, like this:
Auth.auth().useUserAccessGroup("XK********.com.matkonit.SharedItems")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With