Firebase Dynamic Link 将自定义参数传递给 iOS 和 android

Firebase Dynamic Link pass custom parameters to iOS and android

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

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

我在 Medium 上写了第一篇关于此的文章(这不是一篇很好的教程),但它展示了如何做到这一点。您在 link.

末尾使用 ?yourDataHere 传递数据的方式是正确的

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

然后你可以通过调用下面的函数来处理深度 links。您几乎可以获得用于打开应用程序的 link,然后从 URL/link 字符串

中获取数据

//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');
     }
   }