How to make deep links work in flutter when opened with gmail?

Viewed 1794

I am trying to implement deep linking in my flutter app. I am using the uni_links flutter package.

I am sending the deeplink for my application to the user's email account. However, in gmail, you need the http protocol in the href value, Otherwise gmail will not consider that as a valid link. Hence I am forced to use the following link in the email :

<a href="https://myexample.flutter.dev">Click here</a>

as opposed to a link like,

<a href="myexample://flutter.dev">Click here</a>

Now with https://myexample.flutter.dev, when I open the link from gmail, it doesn't open my app.

But, if I change my CFBundleURLSchemes key to myexample and CFBundleURLName to flutter.dev, when I type in myexample://flutter.dev in my browser, it opens my app. However, like I mentioned before, this is not recognized as a valid link in gmail.

What is the issue here? How do I resolve this?

Here's my ios/Runner/Info.plist :

<array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>myexample.flutter.dev</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>https</string>
            </array>
        </dict>
    </array>
1 Answers

The first one is custom link you can do it by yourself

<a href="myexample://flutter.dev">Click here</a>

The second one is universal link

You need to provide file on the backend side to make it work.

Universal Links only work with https scheme and require a specified host, entitlements and a hosted file - apple-app-site-association.

<a href="https://myexample.flutter.dev">Click here</a>

UniversalLinksDocumentation

PS. I think right now as the end of the 2020 the best way to handle deeplinks is by Firebase Dynamic Links. Maybe future people will consider it it should be much more easier

Related