简体   繁体   中英

Firebase dynamic link not working as expected with custom domain

I have example.com custom domain and i want to let invite members to groups inside the app with dynamic links.

I want to use app.example.com/ as prefix.

All libraries installed, team id on firebase for ios is defined and imported with new google services plist.

So my url i prepared to my desire is this (building this as shortlink app.example.com/SOMERANDOMTHING)

https://app.example.com/?link=https://example.com/joingroup?groupid=SOMEGROUPID&apn=com.myorganization.myapp&amv=4&ibi=com.myorganization.myapp&isi=TEAMID&imv=4&ius=myapp

on iOS:

added to info.plist:

<key>FirebaseDynamicLinksCustomDomains</key>
<array>
    <string>https://app.example.com</string>
</array>

Also added applinks:app.example.com to associated domains And to URL Schemes, added com.myorganization.myapp

And my code on component did mount:

    componentDidMount() {

     var that = this

    dynamicLinks().onLink((link) => {

        
        that.handleDynamicLink(link)


    })


    if(Platform.OS == 'android') {


    dynamicLinks().getInitialLink().then((link2) => {

        if(link2) {

            

            that.handleDynamicLink(link2)

        }

Problems

on Android

  1. When click link re-opening app from start and it calls getInitialLink, onLink not working (Thats why i selected platform for getinitiallink because on ios both functions working).

  2. Also when click link; no option like 'Open with MyApp' so link is not associated with MyApp, after clicking browser decides link to be opened with MyApp. (OK, it works but not cool)

  3. If I add this to AndroidManifest:

     <data android:host="app.example.com" android:scheme="http"/> <data android:host="app.example.com" android:scheme="https"/>

    this time link opening with my app and android recognizes link belongs to MyApp but neither getInitialLink nor onLink works.

on iOS

onLink works, but its not transferring result to the app; its just transferring all link

https://app.example.com/?link=https://example.com/joingroup?groupid=SOMEGROUPID&apn=com.myorganization.myapp&amv=4&ibi=com.myorganization.myapp&isi=TEAMID&imv=4&ius=myapp

instead of

https://example.com/joingroup?groupid=SOMEGROUPID

So im stuck on these problems, thanks for your assist

This is possible if you use a link as a parameter of another link. I suggest replacing this with the following

https://app.example.com/?link=https%3A%2F%2Fexample.com%2Fjoingroup%3Fgroupid%3DSOMEGROUPID&apn=com.myorganization.myapp&amv=4&ibi=com.myorganization.myapp&isi=TEAMID&imv=4&ius=myapp

If you use JavaScript to create a link manually, you can use encodeURIComponent

const link = encodeURIComponent('https://example.com/joingroup?groupid=SOMEGROUPID');
const url = `https://app.example.com/?link=${link}&apn=com.myorganization.myapp&amv=4&ibi=com.myorganization.myapp&isi=TEAMID&imv=4&ius=myapp`;
console.log(url)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM