在Firebase电子邮件验证中使用动态/深度链接?

时间:2019-06-10 07:19:07

标签: firebase react-native react-native-android deep-linking react-native-firebase

我正在将RNfirebase与我的react-native应用程序一起使用。我可以获取电子邮件验证链接来打开我的应用程序,仅此而已。我知道我需要访问该链接并对其进行解析以获得oobCode并将其应用于用户。但是,当我使用链接打开应用程序时,使用“ react-native”中的{Linking}触发的侦听器似乎无法检测到该URL。我想将他们重定向到“感谢您验证电子邮件”页面,并使用firebase生成的oobCode验证他们的电子邮件。

我已经操纵了AndroidManifest.xml来侦听链接(myapp.page.link)

<intent-filter android:label="@string/app_name">
          <action android:name="android.intent.action.VIEW"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <category android:name="android.intent.category.BROWSABLE"/>
          <data
              android:scheme="https"
              android:host="myapp.page.link"
              />
      </intent-filter>

我已在初始应用程序页面中添加了侦听器。

useEffect(() => {
getLink()
Linking.addEventListener('url', appWokeUp)
}, [])

const getLink = async() => {
        const link = await Linking.getInitialURL()
        console.log(link)
    }

    const appWokeUp = event => {
        console.log(event.url)
    }

我从getLink()收到的所有信息都是“ null”。我从appWokeUp处理程序中什么都没收到。我希望至少收到触发该应用程序的网址。

1 个答案:

答案 0 :(得分:0)

  1. 使用firebase.links().onLink()firebase.getInitialUrl()获取链接。
  2. 然后解析查询字符串并使用参数oobCode
  3. 致电firebase.auth().applyActionCode()
相关问题