【问题标题】:Firebase Dynamic Link pass custom parameters to iOS and androidFirebase 动态链接将自定义参数传递给 iOS 和 android
【发布时间】:2021-01-28 03:31:19
【问题描述】:

我在 python 中有一个自定义函数来构建动态链接:

def generate_dynamic_link(link, title=None, image=None, description=None, short=True, timeout=10):
    api_url = FIREBASE_DYNAMIC_LINK_API_URL
    domain = DYNAMIC_LINK_DOMAIN
    apn = APP_APN
    isi = APP_ISI
    ibi = APP_IBI

    payload = {
        "dynamicLinkInfo": {
            "domainUriPrefix": domain,
            "link": link,
            "androidInfo": {
                "androidPackageName": apn,
            },
            "iosInfo": {
                "iosBundleId": ibi,
                "iosAppStoreId": isi
            },
            "socialMetaTagInfo": {
                "socialTitle": title,
                "socialDescription": description,
                "socialImageLink": image
            }
        },
        "suffix": {
            "option": "SHORT" if short else "UNGUESSABLE"
        }    
    response = requests.post(api_url, json=payload, timeout=timeout)

    data = response.json()
    if not response.ok:
        raise Exception(data)
    return data['shortLink']

我想将两个参数传递给 android 和 ios 应用程序。我该怎么做?

示例: ?type=user&username=testuser

【问题讨论】:

    标签: firebase firebase-dynamic-links


    【解决方案1】:

    我写了我的第一篇关于这个的 Medium 文章(这不是一个很好的教程),但它展示了如何做到这一点。您在链接末尾使用 ?yourDataHere 传递数据的方式是正确的。

    https://augustkimo.medium.com/simple-flutter-sharing-and-deeplinking-open-apps-from-a-url-be56613bdbe6

    然后您可以通过调用下面的函数来处理深层链接。您几乎可以获取用于打开应用程序的链接,然后从该 URL/链接字符串中获取数据

    
    //ADD THIS FUNCTION TO HANDLE DEEP LINKS
       Future<Null> initUniLinks()async{
         try{
            Uri initialLink = await getInitialUri();
            print(initialLink);
            var dataFromLink = initialLink.toString().split(‘?’)[1];
            print(dataFromLink);
         } on PlatformException {
           print('platfrom exception unilink');
         }
       }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-29
      • 2020-04-16
      • 1970-01-01
      • 2016-11-12
      • 2022-01-06
      • 2022-11-25
      • 1970-01-01
      • 2020-06-19
      相关资源
      最近更新 更多