Firebase PendingDynamicLinkData is sometimes null - android

I'm trying to implement Firebase dynamic links in my app.
I'm using custom domain of mine (instead of the one provided by firebase).
It works most of the time.
However, on a specific device (Samsung A7), the dynamic link is sometimes null
Here's the standard code for pulling the dynamic link:
FirebaseDynamicLinks.getInstance().getDynamicLink(intent).addOnSuccessListener { dynamicData ->
val link = dynamicData?.link
if (link != null)
{
Log.i(TAG, "pullDynamicLinkAsync", "dynamic link found")
}
}.addOnFailureListener {
Log.i(TAG, "pullDynamicLinkAsync", "dynamic link not found")
}
The steps of my test:
Click on the shared dynamic link -> Play store page of my app (previous version) gets opened
Make a fresh install of the app from Android Studio
Call the above code directly from onCreate method
As I said, most of the time it works and I get the link.
Could it be an issue related to the specific device? Maybe Play services issue? Or limitation?
EDIT (03/12/2020):
It seems like this issue is somehow related to Chrome browser.
When I press the dynamic link and the browser (in this case - chrome), opens, The following line gets printed in the log most of the time:
**I/ActivityManager: START u0 {act=com.google.firebase.dynamiclinks.VIEW_DYNAMIC_LINK ...**
If the line appears in the log, I always received the dynamic link in my app
If the lines doesn't appear in the log, I never receive the dynamic link in my app
The issue happens only with chrome browser.
If I open the link with other browser (Firefox, build in browser..) it always works.

Related

Can't switch between two mobile drivers for Chrome and other react native app

Good afternoon,
I am trying to automate the following scenario on Android using Kotlin:
Start Appium driver and open React native app (driver1)
Perform some actions on React native app
Create driver2 with chrome options to open chrome and paste deep link there
Deeplink leads to the app automatically (but I suppose the current session uses driver2, not driver1 here)
I need to continue using the app further with driver1 however it is not working and not finding the element which is on the next screen where my deep link leaded me
I am using Appium v1,21,0
Language - Kotlin
App - React-native
I tried the following solutions:
getContext - does not work as this is not a hybrid app but two different mobile apps
startActivity - it actually launching the app from scratch, not continuing (i need to be on a particular screen after deep-link navigation, can't navigate anywhere else flow won't work)
startActivityCommand - this one did not work for me at all (it ignores the command but maybe anyone can give an example of its usage as I might use it wrong)
driver.switchTo().window("0") - did not work
assign to driver2(web) new capabilities - does not work as it is already defined so we cant change it
sessionId - I am not sure how it works exactly yet, but I tried to find a way to assign a driver to the particular session-id and was not successful (looks like AppiumDriver methods do not support it)
Would appreciate any ideas, links, or sources that can help archive the above
Good Day!
Solution that helped:
#AndroidFindBy(xpath = "//android.widget.EditText[#resource-id=\"com.android.chrome:id/search_box_text\"]")
#iOSXCUITFindBy(id = "")
lateinit var chromeURL: MobileElement
var deeplink = <your deeplink>
driver.activateApp("com.android.chrome")
chromeURL.sendKeys(deepLink)
var clickOnDeepLink = driver.findElements(MobileBy.AndroidUIAutomator("new UiSelector().text(\"$deepLink\")"))
clickOnDeepLink[0].click() //here we could not use Keys.ENTER so we just click on the element first in the list - default android google chrome behaviour
So there is no need for several drivers - same driver instance is fine

Android Firebase Dynamic Links, A way to simulate Play Store install via deeplink

We have couple of Firebase Dynamic links defined in our native Android application. For the first time users coming from a dynamic link and install the application, we would like to understand which dynamic link they're coming from.
My question is in order to do that, is there any way to fake the Play Store install from the dynamic link ? Because for the testing purposes I need to check which data is coming.
Example :
User clicks dynamic link https://myapp.page.link/qr/?id=123456
Redirected to Play Store
Installs the app and clicks Open from Play Store
Is it possible to know which URI does that Open button passes the app ?
In iOS it's easier to test. When user clicks a dynamic link and goes to App Store, you can run the codebase and install the app. And when app opens it still behaves like it's installed from App Store. But from Android side it doesn't work like that.
Hope it was explanative enough. Looking forward for suggestions.
For those who might be struggling about the same problem, here how I solved it.
First of all even though in the Firebase Dynamic Links Documentation it says that links will survive the Play Store installation process, it is not completely true. Like in my case
User clicks dynamic link https://myapp.page.link/qr/?id=123456
Redirected to Play Store
Installs the app and clicks Open from Play
Store
After the steps above when user opens the app, Firebase dynamic links listener will only get the base landing page which you set from Firebase console. So if you have a link link like this https://myapp.page.link/qr/?id=123456 your query params will get lost !
However it's still possible to understand which deeplink path did user click and install the application. Long story short it's the utmParameters. That variable is a Bundle comes with couple of extras and one of them is utm_campaign key. Which includes your deeplink name. See the code below :
Firebase.dynamicLinks
.getDynamicLink(intent)
.addOnSuccessListener(activity) { pendingDynamicLinkData ->
Log.v(
TAG, "pendingDynamicLinkData link : ${pendingDynamicLinkData?.link}" +
"pendingDynamicLinkData utmParameters : ${pendingDynamicLinkData?.utmParameters}"
)
pendingDynamicLinkData?.let {
// Check if it has your desired utm name
if(it.utmParameters.get("utm_campaign") == "Your Dynamic Link Name") {
//Do the job
}
}
}
.addOnFailureListener(this) { e -> Log.v(TAG, "getDynamicLink:onFailure $e") }
After the implementation, you can create an internal release for yourself and test the download flow from the Play Store.

How to test Deferred Deep Linking with AppsFlyer?

I'm integrating AppsFlyer with Android Native Application. And I want to use Deferred Deep Linking, when user click landing page ads and download the app and upon first app open the user lands directly on the activity I want.
Link docs: https://support.appsflyer.com/hc/en-us/articles/207032096-Deferred-Deep-Linking-Getting-the-Conversion-Data
But I have not found a way to check that my code is running correctly.
Please help me with this problem
What was working for me is:
Add physical device as a test device in AppsFlyer (here's how to do it)
Enable Debug Mode in AppDelegate.swift in didFinishLaunchingWithOptions
AppsFlyerTracker.shared().isDebug = true
Add AppsFlyer methods in your AppDelegate.swift (as per article)
Remove app (or test build) from physical device
Open Deep Link from physical device, you will be redirected to App Store. Don't install app from the App Store!!! (just close it)
Install app via XCode
After it, on a first install it will call onConversionDataReceived method and the rest staff.
You're going to have to implement the onInstallConversionDataLoaded listener:
public interface AppsFlyerConversionListener {
void onInstallConversionDataLoaded(Map<String,String> conversionData);
void onInstallConversionFailure(String errorMessage);
}
This will return a map of all the parameters on the link that you clicked.
The parameter you need to pay attention to is the af_dp parameter.
This parameter should contain the URI scheme of the activity you want to route your users to. Make sure that you have set up this URI scheme properly in the manifest.
To create a tracking link you can use Link Management. It doesn't matter if it's a single platform link or a OneLink, as long as you have the af_dp parameter on the link, that parameter (along with all other parameters on the link) will be part of the response.
If you're still facing issues, feel free to reach out to support#appsflyer.com.

branch.io deep-linked URL not passing data in App from Facebook Ads

We are using branch.io to pass custom data to App. For that we are following this steps in branch dashboard.
1) Ads -> Partner Management -> Facebook -> Create Facebook Link
2) Set data in Key/Value under "Deep Linking" Section (data which we need in our app)
3) We set Play/App Store URL in Android/iOs respectively Or set Default Redirects under "Redirects" section
That's it!!!
Now Go to Facebook Ads Manager and select App Install Campaign.
1) Select Play/App Store under App Section.
2) Set above generated URL under "deffered deep link"
You can read more here : https://docs.branch.io/pages/deep-linked-ads/facebook-app-install-ads/
Now Our Problem is :
When user clicked on any branch link with deep link params it able to receive data in both case when user fresh install the application and if user has already app installed.
When we clicked on Facebook ads with same url we are unable to get branch data if user has not installed application (Mostly in case when user redirect from App Store/play store) . But user has installed the app we can able to receive all branch data from same url.
So Question is:
1) Do we need any permission from Facebook or missing any configuration on Branch or Facebook?
2) The same thing will work with both (e.g. Android and iOs) devices?
Thanks
Unfortunately the branch.io documentation for setting this is up is pretty incomplete - we just spent about a week testing and debugging the SDK to figure out how to get it to work. The necessary changes itself are actually quite simple.
On Android:
Integrate the Facebook SDK if you haven't done so already
Ensure that the facebook_app_id string resource you added as part of (1) is not prefixed with "fb"
If you are using ProGuard, add rules to keep the relevant parts of the Facebook SDK
Call enableFacebookAppLinkCheck() on your Branch instance right after initializing it
On iOS:
Integrate the Facebook SDK if you haven't done so already
Call registerFacebookDeepLinkingClass(FBSDKAppLinkUtility.self) on your Branch instance right after initializing it
I had this exact same problem, but in a React Native project, so I'm using react-native-branch. #henning-dodenhof 's answer helped me a lot (thanks for figuring this out!), but I needed a couple of further adaptations, so I add this answer in case it's useful for someone else since this post was the main thing I found regarding this issue:
For iOS:
The FB SDK registration needs to happen before initializing Branch, not after as the above answer suggests. So, before this line that you add as part of the normal library setup:
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
You need get the Branch instance from RNBranch and then register this FB SDK class:
[[RNBranch branch] registerFacebookDeepLinkingClass:[FBSDKAppLinkUtility class]];
Adding this new line before the initialization is critical, doesn't work if it's done after.
For Android:
Here the setup code already gets an instance with Branch.getAutoInstance(this), so we can just chain the registration:
Branch.getAutoInstance(this).enableFacebookAppLinkCheck();
It looks like the getAutoInstance above doesn't actually fully initializes the instance, so you can call enableFacebookAppLinkCheck right after, and the instance gets fully initialized after the first use.

Handle deep linking in cordova app built on meteorjs (myapp://)

I'm building a meteorjs app and deploying it as a native (cordova) app for Android and iOS.
I need to deep link to my app, so I can launch it by following a link on a website.
I've implemented URL Scheme using the cordova plugin by Eddy Verbruggen (https://github.com/EddyVerbruggen/Custom-URL-scheme) and I managed to get my app launched by following a link of the "myapp://" format.
The problem is that, even though the app is getting successfully launched, the handleOpenUrl hook is not getting triggered.
Meteor.startup(function() {
handleOpenURL = function handleOpenURL(url) {
console.log("received url: " + url);
// parse url and proceed accordingly
}
});
Nothing gets logged. So I have no way of passing any parameters to my app, or even detect that the app was launched via a link that follows the 'myapp://' URL scheme.
Also, I noticed that even though my app is already open, if I switch to the browser and click on a special "myapp://" link, instead of switching to my (already open) app, a new instance of the app is getting launched.
[edit] Turned out the two problems were related. Once I prevented a new instance of the app from being initialized, the handleOpenUrl function was triggered successfully.
I'm using the Android emulator for all my tests. I haven't had the chance to test on iOS yet.
[edit] iOS didn't give this problem at all. It was only an Android problem.
If anyone out there has any experience on implementing custom URL scheme in meteorjs, your feedback is much appreciated!
I managed to fix the issue I was facing. Here is the solution, for anybody else who is facing similar problems.
First of all, it was only occurring on Android. iOS had no problem whatsoever to launch the app and trigger the handleOpenUrl function.
The two issues that I was facing on Android turned out that there were related to each other. The fact that a new instance of the app was triggered every time, prevented the handleOpenUrl function from being triggered.
Both problems were fixed by adding a single line of code on the mobile-config.js file:
App.setPreference("AndroidLaunchMode", "singleTask");

Categories

Resources