iPhone Biometric (FaceID) do not work in several apps which used same code base. Some notes for Apple Sign-in Flutter.
Recently, Apple Sign-in is implemented at almost apps for some reasons: client requirements, iPhone users' target, enriching sign-in methods, etc. And certainly to us-Flutter developers, Apple Sign-in implementation is the topic we are interested as well.
Many of us are familiar with this awesome dependency. I believe its document is already perfect to be applied and understandable, so there is no any other words for bringing up this problem ( actually I am not going to reduplicate how to use this lib to make my post seems longer 😆).
Some notes for Apple Sign-in
And let’s move on some things you should keep in mind when dealing with Apple Sign-in.
You just have only one opportunity to retrieve user’s apple email.
It was already clearly noted in dependency but I thought there are still some developers (like me 🙄) have skipped this. So I highly raise up this issue such a way to let other one does not silly ask why credential.email after execute SignInWithApple.getAppleIDCredential is always null
. ( I thought it would have no one else except me 😵).
For security issue, Apple will only provide email
on the first authorization, Up further times, userIdentifier
will be the only data you got when sign-in again, so you should store this data securely and carefully on your server.
Face ID will not work in multiple installed apps if those are built from one code base
In some cases, we need to build a lot of different apps by using one code base. So you will face an issue like: App A, B, and C used 1 code base and installed in device, but just App C works with device Face ID, the others will keep staying at the grey icon below with no detection.
… so for this case, let's create a new XCode Target for it !
Revise how to create XCode Target
Guess you all know about how to duplicate current target.
And remember to use the correct Info.plist
file for corresponding target.
Update Pod File after that
When you run Flutter project, it will re-run pod install
, so if you didn’t change your Pod file to your new Target, its framework will be lost and caused crash after then.
Update
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
To
def shared_pods
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
target 'Runner' do
shared_pods
end
target 'Runner-Copy' do
shared_pods
end
Create shared_pods
to make sure Pod will apply only one config to all targets you have.
These are some experience in me when playing around Apple Sign-in in Flutter, if you think there is something more interesting, let’s bring up here.
Happy coding!