Hello, everybody, in this set of articles let’s take a look at DeepLinks, consider what they are, how to configure and use them in Flutter application.
There will be 3 articles in total:
- Review and configuration of Custom links for Android and iOS (current);
- Setting up Universal links for iOS and App links for Android;
- Processing in the application using Flutter and Redux.
Here we go!
Deep links are just links, similar to the usual web links, but allowing the user to open the application on the phone, or install it. Like web links, deep links can contain additional information.
For your convenience we will use uni_links. A handy pager that allows you to configure everything in a short time.
Deep links are divided into two types — Custom links and Universal links App links.
for Android). Let’s start with Custom links and immediately consider their pros and cons.
- Very easy setup;
- No need to configure anything but the application;
- No need to have a site / server.
- Only work with the application installed;
- Many messengers do not recognize a link type such as Telegram;
- Not redirected to AppStore and Play Market if there is no application installed;
- Do not interact in any way with your web application (if any).
So, if everything suits us, let’s get to configuring and using it.
Custom links are like YOUR_SCHEME//YOUR_HOST, where
YOUR_SCHEM and YOUR_HOST are comfortable words for you. Next we will use an example for the schema and myapp.com for the host. In the end we get the example://myapp.com link. But what can we do with it?
Go to android/app/src/main/AndroidManifest.xml and add:<manifest …><! — … other tags →<application …><activity …><! — … other tags →<intent-filter><action android:name=”android.intent.action.VIEW” /><category android:name=”android.intent.category.DEFAULT” /><category android:name=”android.intent.category.BROWSABLE” />android:scheme=”example” // YOUR_SCHEMEandroid:host=”myapp.com” /> // YOUR_HOST</intent-filter></activity></application></manifest>
We go to ios/Runner/Runner.entitlements:
<?xml …><! — … other tags →<plist><dict><! — … other tags →<key>CFBundleURLTypes</key><array><dict><key>CFBundleTypeRole</key><string>Editor</string><key>CFBundleURLName</key><string>myapp.com</string> // YOUR_HOST<key>CFBundleURLSchemes</key><array><string>example</string> // YOUR_SCHEME</array></dict></array><! — … other tags →</dict></plist>
And voila, your application will open by clicking on example://myapp.com/[WHERE_USE].
We will talk about Custom Links and App links and their processing in the next parts.