Ganpati
How does Firebase Dynamic Links Work for Android?

How does Firebase Dynamic Links Work for Android?

09 October, 2019 by img Ajay Mehta in Mobile App Development
How does Firebase Dynamic Links Work for Android?

How does Firebase Dynamic Links Work for Android?

Dynamic links (DeepLink) using Firebase

With Dynamic Links, users get the best available experience for the platform they open the link on. If the link is opened in iOS or Android browsers, they can be taken directly to the linked content in your native app. If a user opens the same link on a desktop browser, they will be taken to the equivalent content on your website or web app.

If a user opens a Dynamic Link on iOS or Android and doesn’t have the app installed, the user can be prompted to install it; then, after installation, your Android app development services starts and can access the link shared that was shared.

How are Dynamic links different from deep links?

Dynamic links provide a way for deep links to survive the installation step and in a way that the user never loses the context.

A Dynamic Link is a deep link into your app that works whether or not your app is installed. It carries the following information:

– Project information that is available inside the Firebase Console.

-The package name for the apps that it needs to target.

-A fallback Url for redirection in those extreme cases where the app could not be installed.

-And obviously, the deep link that the app should utilize to reach the web equivalent screen.

 

 

How to Add dynamic link support for the apps?

1. Click On Tools → Firebase

2. In the left side, Firebase Assistant panel click on Dynamic link → Add Dynamic Links

Now connect your app to Firebase and add Dynamic links support. Adding a dynamic link to the app will add some google-services and firebase dependencies automatically.

Adding firebase dynamic link dependency in app’s build.gradle file.

implementation ‘com.google.firebase:firebase-dynamic-links:19.0.0’

 

Intent-filters in AndroidManifest.xml for the activity which will handle the deep links 

<activity

android:name=”.TestActivity”

android:screenOrientation=”portrait” >

<intent-filter android:autoVerify=”true”>

 <action android:name=”android.intent.action.VIEW” />

<category android:name=”android.intent.category.BROWSABLE” />

<category android:name=”android.intent.category.DEFAULT” />

<data android:host=”yourdomain.com”

 android:scheme=”http”/>

<data android:host=”yourdomain.com”

 android:scheme=”https” />

 </intent-filter>

</activity>

 

After successful completion of the above steps, we can see our project in Firebase console

 

Firebase Console → Select your project → Dynamic links (Left side panel, under Grow) →Get Started

 

 

Enter your brand name and this will be used to as the Project information segment in Dynamic links. Once verification is completed, click “Finish”.

Now click on “New Dynamic link” button in the new page which will open:

 

 

 

1. Add the deep link URL (URL for which the transition from web page to the application is needed) as per your requirement. For our example, it will be: https://testlink.com/mobile/1000

 

2.Provide app pieces of information to define link behavior for iOS and Android apps. The instructions for linking both Android and iOS apps are pretty much self-explanatory.

 

3.Click on New Dynamic Link.

 

Firebase Dynamic Links

 

This is the dynamic link created which has all the information mentioned above, for it to be able to link (https://testlink.com/mobile/1000) to our apps whether it is installed or not whenever the user hits the dynamic link on the mobile browsers.

You can choose to customize the Dynamic deep link in Setting up short URL link step.

 

How will it work if users just share the deep links (https://testlink.com/mobile/1000) and not dynamic links?

 

You create a Dynamic Link either by using the Firebase console, using a REST API, iOS or Android Builder API or by forming a URL by adding Dynamic Link parameters to a domain specific to your app.

 

Dynamic link of the format:

https://your_subdomain.page.link/?link=your_deep_link&apn=package_name[&amv=minimum_version][&afl=fallback_link]
 

More Information about the individual parameters refer below link

https://firebase.google.com/docs/dynamic-links/create-manually
 

Now every time the user opens a deep link in a mobile browser, create a dynamic link programmatically in the above format and redirect the request to it.

 

How to get deep link data from dynamic link?

Add the following in TestActivity.java:

FirebaseDynamicLinks.getInstance().getDynamicLink(getIntent())

.addOnSuccessListener(this, pendingDynamicLinkData -> {

// Get deep link from result (may be null if no link is found)

 if (pendingDynamicLinkData != null) {

try {

String link = pendingDynamicLinkData.getLink();

Toast.makeTex(YourActivity.this, link, Toast.LENGTH_SHORT).show()’

} catch (UnsupportedEncodingException e) {

e.printStackTrace();

}

}

}).addOnFailureListener(this, e -> Log.w(SplashScreen.class.getSimpleName(), “getDynamicLink:onFailure”, e));

pendingDynamicLinkData.getLink() returns the deep link

 

Now, this deep-link can be handled similarly to any other deep-links that the app supports.

 

Conclusion:

This post will give you a basic idea and information about  how to create Firebase Dynamic Links and setting Firebase Dynamic Links SDK on Android.

Rlogical Techsoft is Top-notch custom Android app development is our forte. Our hire dedicated Android App developers have innovative solutions for transforming your ideas into an intuitive app with astonishing UI/UX design and a seamless performance across multiple devices.

img

Ajay Mehta

Ajay Mehta is Sr. Android Developer at Rlogical Techsoft Pvt. Ltd. He is passionate about Android and expert in building an innovative Android mobile application.

Get in Touch

Contact Us

USA

600 E Michigan Ave, Kalamazoo, MI 49007, USA

Robert Armbrister: +1 866 277 2752

Contact Email: usa@rlogical.com
info@sparkbusinessworks.com

UK

5 Kew Road, TW9 2PR, London

Peter Klein: +44 753 859 8026

Contact Email: uk@rlogical.com

INDIA (Head Office)

701 Satkar Complex, Opp Tanishq Showroom,Behind Lal Bungalow, Chimanlal Girdharlal Rd, Ahmedabad, Gujarat 380009

Rahul Panchal: +91 982 460 1707
Contact Email: rahul@rlogical.com

Jatin Panchal: +91 997 420 2036
Contact Email: jatin@rlogical.com

JAPAN

301 1-28-21 Hayabuchi, Tsuzuki-ku, Yokohama-shi, Kanagawa 224-0025, Japan

Charles

Contact Email: japan@rlogical.com

Australia

Suit 3, Level 27, 1 Farrer Place Sydney NSW 2000

Sophie Stapleton: +61 02 8006 1544

Contact Email: australia@rlogical.com