I'm using Firebase authentication in my app (email, passwordless), and trying to follow these directions .
There are several parts that are particularly confusing:
actionCodeSettings.url = URL(string: "https://www.example.com")
-- What exactly should this URL be? Why does it matter in the case of an iOS app where I want the user to tap on the link on their iPhone and for it to launch the app? the App Store ID and the Apple Developer Team ID also need to be specified
-- what if my app is not on the app store and only distributed via TestFlight? You will also need to configure your email action handler domain as an Associated Domain in your application capabilities. By default, the email action handler is hosted on a domain like the following example: APP_ID.firebaseapp.com
You will also need to configure your email action handler domain as an Associated Domain in your application capabilities. By default, the email action handler is hosted on a domain like the following example: APP_ID.firebaseapp.com
-- What is the APP_ID, is it the same as the Apple ID from the previous step? What is the email action handler domain, and how do I add one? application:openURL:options:
method as seen in the example , but it's never actually called. actionCodeSettings.url
This must be a domain that is listed in Console > Develop > Authentication > Sign-in method > Authorized domains. Otherwise you'll get an unauthorized domain error.
What this is actually doing is deciding what happens when the user taps the link on desktop. Eg you may want to take them to a 404 page, or a page that explains to open up the link on their iPhone.
If you have nothing else to use, you can always grab the foo-xxxx.firebaseapp.com or foo-xxxx.web.app urls as listed in that section, which will show a "site not found" page.
This will work! You can grab your App ID from the iTunes Connect site.
Not sure exactly what this step is. APP_ID
most likely refers to the foo-xxxx
value in the firebase console that you can find in step 1.
However, you probably don't want to use the APP_ID.firebaseapp.com
value as suggested. Instead, you want to follow the dynamic links instructions , and under your project's settings in Xcode, you'll see the Capabilities > Associated Domains tab. There you'll want to add applinks:your_dynamic_links_domain
which will likely look like applinks:foo.page.link
.
application:openURL:options:
not called Universal links (eg https://foo.page.link ) that launch your app will never call the openURL method. Instead, you need to implement the continue user activity method , as is also mentioned in the dynamic links instructions
If you implement everything correctly, it'll look like this:
application(:,continue:,restorationHandler:)
method will be called at which point you should call Auth.auth().isSignIn(withEmailLink: link)
and then eventually call Auth.auth().signIn(withEmail: email, link: link)
. Try sending yourself the email, and tap the sign in link. Go back to the email and tap it again, it should not work as each code can only be used once.
You should be able to find out who is logged in via the synchronous method Auth.auth().currentUser?.email
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.