【问题标题】:Implement Firebase Dynamic Links in Ionic / React.js application with Capacitor使用 Capacitor 在 Ionic / React.js 应用程序中实现 Firebase 动态链接
【发布时间】:2021-11-11 10:28:23
【问题描述】:

我已经开发了一个以 Firebase 作为后端的 React.js 应用程序,我们还使用 Ionic 将应用程序部署到 android 和 IOS 版本。我们目前正在使用 Capacitor 添加一些本机功能,但在实现动态链接时遇到了问题。

那里有几个包,经过大量搜索后,我发现了这个包:https://github.com/Turnoutt/capacitor-firebase-dynamic-links

这个包不适用于 Capacitor 3.0 的问题,有人很友好地提交了 pull request,但 repo 所有者尚未合并到修复中。有些人分叉了 repo 来实施修复,我遇到了下面的 repo。

一切都很顺利,但我不确定将听众放在哪里?我应该把它放在应用程序级别吗?如果是这样,该代码 sn-p 分别放在 Android / IOS 的什么位置?

方法

// addListener('deepLinkOpen', (data: { url: string })
// Add this method when the app starts to listen for the dynamic link.

CapacitorFirebaseDynamicLinks.addListener('deepLinkOpen', (data: { url: string }) => {
      Implement your navigation handler
    })

CapacitorFirebaseDynamicLinks.addListener('deepLinkOpen', (data: { url: string }) => { 实现您的导航处理程序 })

【问题讨论】:

    标签: reactjs firebase ionic-framework capacitor firebase-dynamic-links


    【解决方案1】:

    我在 Capacitor v2.4.2,Angular 上实现了动态链接。我使用了 Turnoutt 的第一个插件。 这与您的 Capacitor 版本不同,但我的输入可能会有所帮助。

    CapacitorFirebaseDynamicLinks.addListener 侦听器将放置在您的 React 代码中,应用程序启动的位置和平台准备就绪后。我受到反应知识的限制,但this is 如何在离子反应中添加听众。实现上会类似

    对于 iOS 原生,必须遵循参考 this link 的单独步骤

    具体来说,在AppDelegate.swift,这些是我所做的更改。

    import Firebase
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()
        return true
      }
    
    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        // Called when the app was launched with a url. Feel free to add additional processing here,
        // but if you want the App API to support tracking app url opens, make sure to keep this call
        return CAPBridge.handleOpenUrl(url, options)
      }
    

    【讨论】:

    • 史诗,非常感谢你。我想这会让我越界。
    猜你喜欢
    • 2020-11-23
    • 1970-01-01
    • 2021-11-15
    • 2020-03-21
    • 2021-06-16
    • 1970-01-01
    • 1970-01-01
    • 2021-08-07
    • 2019-09-17
    相关资源
    最近更新 更多