Deep links are revolutionizing the landscape of mobile applications, with flutter deep linking leading the way. Imagine this scenario: a friend shares a link to a product. You click it, and presto! You’re not just inside the app but directly viewing that specific product. Sounds like magic? No, it’s the power of deep linking!
In Flutter, deep links act as direct pathways to precise app content or functionalities, crucial for apps with easily shareable content. They facilitate seamless in-app experiences when users share links, supporting everything from promotional campaigns to content shortcuts. This guide aims to explains flutter deep linking, covering everything from setting up native functionality for Android and iOS to managing navigation with GoRouter.
Deep links not only simplify navigation but also foster user retention, enhance engagement, and streamline content sharing. Whether you’re creating your initial deep link or refining existing ones, this guide serves as the ultimate roadmap to deep linking success.
A deep link redirects users to a specific destination within an app rather than a webpage.
Deep links comprise a URL, a string of characters, which includes:
Protocol: This marks the beginning of the link, commonly seen as http or https. It specifies the protocol to utilize when accessing the resource online.
Domain: This denotes the domain name of the link. For instance, codewithandrea.com represents the domain, indicating the location of the resource.
Path: This identifies the precise resource within the domain that the user wishes to access. In our instance, /careers/ serves as the path.
Additionally, there are:
Query Parameters: These are supplementary options appended after a ? mark, typically aiding in data sorting or filtering.
Port: This facilitates communication with the server’s network services. While often omitted, HTTP and HTTPS default to ports 80 and 443, respectively.
Fragment: Also known as an anchor, this optional segment follows a # symbol and focuses on a specific part of a webpage.
Here’s an annotated illustration showcasing all the aforementioned elements:
An instance of a complete URL with protocol, domain, port, path, query parameters, and fragment.
During the initial stages of your project, you might influence how the URL is constructed to ensure simplicity and ease of handling.
It’s worth noting that while some URLs are well-designed, others may pose challenges when integrated into your app. Stay tuned for the implementation section of this guide to witness how it’s executed in flutter deep linking.
Mobile apps can accommodate two types of deep links based on the utilized scheme.
Deep links encompass regular web links. Custom Schemes:
In Android, this is referred to as a deep link, while in the iOS realm, it’s termed a custom URL scheme. This approach proves advantageous if you lack a domain but seek to leverage the potential of deep links.
You have the liberty to select any Custom Scheme, provided you define it within your app. The setup process is swift since uniqueness isn’t a concern.
However, a downside is its diminished security, as any application could hijack your Custom Scheme and endeavor to open your links. Additionally, if a user lacks your app and clicks on a Custom Scheme link, they’ll encounter a dead end accompanied by an error message. While not ideal, its simplicity renders it convenient for rapid tests.
Known as App Links on Android and Universal Links on iOS, this method furnishes the most secure approach to integrating deep link support into your mobile app.
A mobile application must fulfill both domain ownership and authentication requirements. The manifest file on Android must contain the domain name and the associated domains file on iOS must contain the associated domain name.
By engaging in this synchronization, your app acknowledges the domain, and the domain authenticates your app. This bidirectional validation ensures the integrity and legitimacy of the deep links, offering a secure deep-linking experience.
Sufficient with the theory; let’s delve into platform configuration!
Let’s commence by adjusting the AndroidManifest.xml file:
Access the android/app/src/main/AndroidManifest.xml file.
Incorporate an intent filter into your activity tag. Specify your scheme and domain.
Optional: delineate supported paths.
The intent filter should resemble this:
If opting for a Custom Scheme and aiming to open links like yourScheme://yourDomain.com, utilize:
The foregoing example doesn’t specify particular paths. With this setup, your app can access all URLs from your domain. This is often undesirable, and for greater control, you must define the accepted paths by integrating relevant path tags. The most prevalent ones include path, pathPattern, and pathPrefix.
You can locate a detailed guide on utilizing various data tags in the official Android documentation.
You must ensure your domain recognizes your app as a trustworthy URL handler now that the app recognizes the types of URLs it should handle.
It’s essential to note that this step solely pertains to HTTP/HTTPS links and not custom schemes.
Step 1: Generate a new file named assetlinks.json. This file should encompass the digital asset links associating your site with your app. It should contain the following:
Swap out “com.example” with your app’s package name, and replace the sha256_cert_fingerprints value with your app’s unique SHA256 fingerprint.
Step 2: Your website must contain the assetlinks.json file. It must be accessible via https://yourdomain/.well-known/assetlinks.json. If you’re unsure how to execute this, contact your domain’s administrator.
Step 3: To validate if the assetlinks.json is correctly configured, utilize the statement list tester tool provided by Google.
SHA256 fingerprints can be generated by using this command: grandle signingReport.
Using the Developer Console, you can access your production app’s app signing under Setup > App Integrity > App Signing.
Ready to verify your deep links on Android? Simply launch an Android emulator and execute these commands via the terminal.
Heads up! ADB typically resides in the android/sdk/platform-tools directory. Ensure this directory is in your system path before executing these commands.
Encountering an “adb: more than one device/emulator” obstacle? If you’re concurrently operating multiple Android devices or emulators, peruse this thread for a resolution.
An alternative method to test is by sending the link https://yourDomain.com to yourself using any app (such as WhatsApp) and subsequently clicking on it. Initially, the aim is for the app to activate. We’ll later delve into how to navigate to the appropriate screen with flutter code.
🔸Potential concern🔸
If tapping the URL activates your app “within” the source app (such as Gmail or WhatsApp) rather than independently, append android:launchMode=”singleTask” within your <activity> tag.
The subsequent example depicts the app’s appearance after being activated with a deep link from WhatsApp:
Related read: How to Create Deeplinks for Android Using Branch.io?
The disambiguation dialogue is a prompt displayed by Android when a user possesses multiple apps capable of handling a specific link. It enables users to select their preferred application.
To circumvent this, you should make your app the default handler for the link. While this action entails user consent, it streamlines the user experience, ensuring a smoother navigation process.
Before initiating this, consider its repercussions. Once your app becomes the default handler, users must actively revoke this privilege to enable other apps to manage these links.
If you’re following the Custom Scheme approach, you don’t need to validate your server’s URLs. Instead, after appending the intent filter to AndroidManifest.xml, the integration process is complete.
Subsequently, your app can handle custom-scheme links without further ado.
Congrats! You’ve laid the foundation for deep link integration within your Android app. You’ve configured the AndroidManifest.xml file to intercept incoming links and direct users to the appropriate screens.
Next up, we’ll explore deep linking on iOS and highlight the contrasts and similarities between the two platforms.
Integration within iOS necessitates a nuanced approach due to divergent terminology and methods.
On iOS, deep links are categorized as either Universal Links (recommended) or custom URL schemes. While custom URL schemes remain prevalent, Apple advocates for Universal Links due to their enhanced security and user experience.
Universal Links closely mimic standard web URLs and operate in conjunction with the website’s domain. They proffer a seamless transition from web to app, thereby enriching the user experience.
Enhanced Security: Universal Links leverage standard HTTPS authentication mechanisms, safeguarding against potential security threats.
User Experience: Unlike custom URL schemes, Universal Links eschew abrupt app openings. Instead, they incorporate a redirection step, ensuring a seamless user experience.
Referrer Information: Universal Links preserve referrer information, affording app developers insights into traffic sources.
Before delving into Universal Link integration, ensure the following prerequisites are satisfied:
Apple Developer Account: To access capabilities, create an Apple Developer account if you haven’t already.
App ID Configuration: In the Apple Developer Center, configure your App ID to support Associated Domains. This is pivotal for Universal Link integration.
Apple App Site Association (AASA) File: Craft an AASA file and host it on your domain. This file encompasses JSON data specifying the association between your website and the app.
Domains Validation: In the Xcode project, list your domain under Associated Domains.
Implementation Overview:
To summarize, here’s an outline of the Universal Link integration process:
Let’s delve into each step in detail!
Generating the Apple App Site Association (AASA) File:
The AASA file is pivotal for Universal Link integration, establishing the association between your website and your app. It’s a JSON file comprising the following structure.
Here’s an example of an AASA file:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "TeamID.BundleID",
"paths": ["*"]
}
]
}
}
Replace “TeamID” with your Apple Developer Team ID and “BundleID” with your app’s bundle identifier.
The “paths” attribute signifies the paths within your domain that should be handled by your app. The asterisk (*) denotes all paths.
Host the AASA file at the root level of your website. It should be accessible via the URL https://yourDomain.com/apple-app-site-association.
Configuring Xcode Project Settings:
In the Xcode project, configure Associated Domains to authenticate the association between your app and your website.
Here’s an illustrative example:
In this scenario, “yourDomain.com” represents your website’s domain.
Incorporating Entitlements:
The entitlements file, entitlements.plist, is pivotal for Universal Link integration. It ensures seamless communication between your app and your website.
If your project lacks an entitlements file, create one via File > New > File > iOS > Resource > Property List.
Next, incorporate the following entitlements:
Application Associated Domain: This entitlement authorizes your app to handle Universal Links.
Paste the associated domain(s) from the previous step into this entitlement. Ensure they’re prefixed with “applinks:”.
Here’s an example of an entitlements file:
To validate your Universal Link integration, utilize the Apple App Site Association Validator:
If the validation succeeds, proceed to test the integration on an iOS device.
Testing Universal Links necessitates an iOS device running iOS 9 or later. Simulator testing isn’t viable due to inherent limitations.
Here’s a step-by-step guide to testing Universal Links:
Congratulations! You’ve successfully integrated Universal Links into your iOS app, enriching user experience and streamlining the transition from web to app.
Universal Links offer enhanced security, seamless user experience, and valuable referrer information, making them the preferred choice for deep linking on iOS.
In the subsequent section, we’ll explore navigation management within Flutter, enabling seamless traversal between screens via deep links.
GoRouter serves as a robust navigation solution for flutter apps, seamlessly integrating deep links into your application.
Declarative Routing: Define routes via a simple, declarative syntax, enhancing code readability and maintainability.
Deep Link Integration: GoRouter seamlessly integrates flutter deep linking into your flutter app, facilitating seamless traversal between screens.
Custom Transition Animation: Tailor transition animations to match your app’s design aesthetic, ensuring a cohesive user experience.
State Restoration: Preserve navigation state across app restarts, mitigating user frustration and enhancing usability.
To incorporate GoRouter into your Flutter app, follow these steps:
1. Install the GoRouter package via pubspec.yaml:
dependencies:
go_router: ^2.1.0
2. Define routes within your app using the GoRouter syntax.
3. Implement deep link handling logic within your app, parsing incoming deep links and navigating to the appropriate screens.
Here’s an illustrative example of deep link integration using GoRouter:
The foregoing example defines two routes: “/” and “/details”, corresponding to the home screen and details screen, respectively.
Upon receiving an incoming deep link, parse the link’s path and navigate to the corresponding screen using GoRouter’s navigation API.
Congratulations! You’ve successfully integrated flutter deep linking into your flutter app using GoRouter, enabling seamless navigation between screens via deep links.
GoRouter’s declarative syntax, deep link integration, custom transition animation, and state restoration capabilities make it a robust navigation solution for flutter apps.
In the subsequent section, we’ll explore deep link attribution and analytics, enabling you to track user engagement and optimize your flutter deep linking strategy.
Deep linking in Flutter enhances user experience by allowing direct navigation to specific content within an app. This guide explains how to set up and manage deep links for Android and iOS, including creating URLs, configuring necessary files, and handling different types of deep links.
Deep links streamline app navigation, improve user retention, and simplify content sharing. By following this guide, you can set up deep links, validate them, and use tools like GoRouter to manage navigation within your Flutter app. This comprehensive approach ensures a smooth and secure deep-linking experience for users.
The team at Mindbowser was highly professional, patient, and collaborative throughout our engagement. They struck the right balance between offering guidance and taking direction, which made the development process smooth. Although our project wasn’t related to healthcare, we clearly benefited...
Founder, Texas Ranch Security
Mindbowser played a crucial role in helping us bring everything together into a unified, cohesive product. Their commitment to industry-standard coding practices made an enormous difference, allowing developers to seamlessly transition in and out of the project without any confusion....
CEO, MarketsAI
I'm thrilled to be partnering with Mindbowser on our journey with TravelRite. The collaboration has been exceptional, and I’m truly grateful for the dedication and expertise the team has brought to the development process. Their commitment to our mission is...
Founder & CEO, TravelRite
The Mindbowser team's professionalism consistently impressed me. Their commitment to quality shone through in every aspect of the project. They truly went the extra mile, ensuring they understood our needs perfectly and were always willing to invest the time to...
CTO, New Day Therapeutics
I collaborated with Mindbowser for several years on a complex SaaS platform project. They took over a partially completed project and successfully transformed it into a fully functional and robust platform. Throughout the entire process, the quality of their work...
President, E.B. Carlson
Mindbowser and team are professional, talented and very responsive. They got us through a challenging situation with our IOT product successfully. They will be our go to dev team going forward.
Founder, Cascada
Amazing team to work with. Very responsive and very skilled in both front and backend engineering. Looking forward to our next project together.
Co-Founder, Emerge
The team is great to work with. Very professional, on task, and efficient.
Founder, PeriopMD
I can not express enough how pleased we are with the whole team. From the first call and meeting, they took our vision and ran with it. Communication was easy and everyone was flexible to our schedule. I’m excited to...
Founder, Seeke
We had very close go live timeline and Mindbowser team got us live a month before.
CEO, BuyNow WorldWide
If you want a team of great developers, I recommend them for the next project.
Founder, Teach Reach
Mindbowser built both iOS and Android apps for Mindworks, that have stood the test of time. 5 years later they still function quite beautifully. Their team always met their objectives and I'm very happy with the end result. Thank you!
Founder, Mindworks
Mindbowser has delivered a much better quality product than our previous tech vendors. Our product is stable and passed Well Architected Framework Review from AWS.
CEO, PurpleAnt
I am happy to share that we got USD 10k in cloud credits courtesy of our friends at Mindbowser. Thank you Pravin and Ayush, this means a lot to us.
CTO, Shortlist
Mindbowser is one of the reasons that our app is successful. These guys have been a great team.
Founder & CEO, MangoMirror
Kudos for all your hard work and diligence on the Telehealth platform project. You made it possible.
CEO, ThriveHealth
Mindbowser helped us build an awesome iOS app to bring balance to people’s lives.
CEO, SMILINGMIND
They were a very responsive team! Extremely easy to communicate and work with!
Founder & CEO, TotTech
We’ve had very little-to-no hiccups at all—it’s been a really pleasurable experience.
Co-Founder, TEAM8s
Mindbowser was very helpful with explaining the development process and started quickly on the project.
Executive Director of Product Development, Innovation Lab
The greatest benefit we got from Mindbowser is the expertise. Their team has developed apps in all different industries with all types of social proofs.
Co-Founder, Vesica
Mindbowser is professional, efficient and thorough.
Consultant, XPRIZE
Very committed, they create beautiful apps and are very benevolent. They have brilliant Ideas.
Founder, S.T.A.R.S of Wellness
Mindbowser was great; they listened to us a lot and helped us hone in on the actual idea of the app. They had put together fantastic wireframes for us.
Co-Founder, Flat Earth
Ayush was responsive and paired me with the best team member possible, to complete my complex vision and project. Could not be happier.
Founder, Child Life On Call
The team from Mindbowser stayed on task, asked the right questions, and completed the required tasks in a timely fashion! Strong work team!
CEO, SDOH2Health LLC
Mindbowser was easy to work with and hit the ground running, immediately feeling like part of our team.
CEO, Stealth Startup
Mindbowser was an excellent partner in developing my fitness app. They were patient, attentive, & understood my business needs. The end product exceeded my expectations. Thrilled to share it globally.
Owner, Phalanx
Mindbowser's expertise in tech, process & mobile development made them our choice for our app. The team was dedicated to the process & delivered high-quality features on time. They also gave valuable industry advice. Highly recommend them for app development...
Co-Founder, Fox&Fork