The deeplinking works fine from WhatsApp, Slack and even Facebook Messenger but doesn't work from the Facebook App itself.
In the branch.io Link Settings I did enable:
✓ Always try to open app
✓ Enable App Links + SHA256 Cert Fingerprints
Changed to custom Link Domain: sharing.kptncook.com
successfully authenticated the "Facebook Install Ads"
Facebook developer settings:
Packagename, class name and hashes are correct(Facebook login also works fine)
✓ SSO is activated
✓ Deep-Link is activated
Android App Versions:
Facebook Messenger: 126.0.0.9.84
Facebook: 133.0.0.19.83
Example link: sharing.kptncook.com/pIbQ/FKktug85TE
Activity part of Manifest:
<activity android:name=".MainActivity"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:scheme="kptncook" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="sharing.kptncook.com" />
<data android:scheme="http" android:host="sharing.kptncook.com" />
</intent-filter>
</activity>
<receiver android:name="io.branch.referral.InstallListener" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
Activity:
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
#Override
public void onStart() {
super.onStart();
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchReferralInitListener(){
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
}
}, this.getIntent().getData(), this);
}
#Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
}
Additional info: In the emulator some links won't open and some does. If I send a link that doesn't work from the emulator to a real device it works on the real device.
What am I doing wrong?
Update:
New shared links work now on the Real device in both Facebook Messenger and Main App. But if I open the exact same link in the messenger on an emulator it redirects to "r31v.test-app.link..." and doesn't show anything except a toast "Can't load page". It's so frustrating. Any ideas how to debug it?
Alex from Branch.io here:
Facebook deep linking is one of the hardest things to debug — they intentionally don't want users to leave their app, wherever possible.
A few notes for debugging:
The domain r31v.test-app.link is your original link domain. You customized this to sharing.kptncook.com, but there are times when Branch needs to use both to handle certain edge cases. You need to add the following lines to your Manifest:
<data android:scheme="https" android:host="r31v.test-app.link" />
<data android:scheme="https" android:host="r31v-alternate.test-app.link" />
Other than the above, your in-app configuration implementation looks fine.
It's possible something is funky with your Dashboard configuration. Branch has separate Test and Live environments, and you're currently using the Test one. It's important to make sure you haven't split your implementation between values from both sides.
Deep linking behavior frequently doesn't work correctly in the emulators. It's always best to test with real devices, because results from emulators are usually not reliable.
Facebook sometimes caches the App Links tags, which means you may get unpredictable results when opening a URL that has just been shared, or when re-sharing a URL that has been posted before with different data.
Feel free to reach out to our Integrations team any time with questions!
Related
My MainActivity manages the deep link this way
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
intent?.let {
checkDynamicLink(intent)
}
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
checkDynamicLink(intent)
}
private fun checkDynamicLink(intent: Intent) {
FirebaseDynamicLinks.getInstance()
.getDynamicLink(intent)
.addOnSuccessListener(this) { dynamicLink ->
dynamicLink?.link?.let { deepLink ->
viewModel.postDeepLink(deepLink)
}
}
}
The viewModel is shared; once the user is logged in, the home fragment takes the deep link and the NavController handles it.
It works perfectly when debugging and also when installing the production version of the app through Android Studio (minified or not). The problem occurs when I install the production app through the play store.
When opening the dynamic link the Play Store is opened; I install the app and then click on "Continue" (the fact I see "Continue" rather than "Open" should mean it recognizes there's a dynamic link with which opening the app).
I open the app, then log in; when it arrives to the home fragment, apparently, there's no deep link to be managed. It should open a fragment, but it doesn't.
More strange: if I install the app through the dynamic link and then I open it through the launcher (rather than the "Continue" button on the play store) the dynamic link and the deep link are correctly managed.
It seems to be a Play Store bug. My question is, is there something I'm forgetting?
The following is the activity's intent-filter in the manifest:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="#string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="https" />
<data
android:host="#string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="http" />
</intent-filter>
looking at firebase dynamic links documentation, there is several ways to setupa dynamic link.
I would recommend you check that the package name on the dynamic link is set to match the package name of your production app.
The problem was related to the AndroidManifest and how the activity was declared:
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="#string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="https" />
<data
android:host="#string/firebase_dynamic_links_domain_uri_prefix"
android:scheme="http" />
</intent-filter>
<nav-graph android:value="#navigation/nav_graph" />
</activity>
The nav_graph tag caused the dynamic link to be automatically managed by the app, so when the app was launched through the play store the dynamic link's deep link was automatically managed, but the user wasn't logged in so the fragment wasn't shown (so it wasn't apparently not managed).
I am trying to open location settings from Chrome (on Android) on a button click using Android Intents. I am following the Barcode Scanner example and tried encoding the url similar way.
For location I have tried this:-
const uri = "intent://com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS#Intent;action=com.google.android.gms.location.settings.GOOGLE_LOCATION_SETTINGS;end"
I also tried opening settings using this:-
const uri = "intent://ACTION_SETTINGS#Intent;action=android.provider.Settings.ACTION_SETTINGS;end"
or this
const uri = "intent://android.provider.Settings.ACTION_SETTINGS#Intent;action=android.provider.Settings.ACTION_SETTINGS;end"
But nothing seems to work. Any help is appreciated.
I am attaching it to a button using href tag.
Seems you can't open Location Settings directly from Android Intents with Chrome because Settings Activities didn't support BROWSABLE category (for details take a look at this question of Dickeylth and answer of Rafal Malek). But You can 100% do this via custom android application and Deep Links to custom Activity with <category android:name="android.intent.category.BROWSABLE"/> support, like in that tutorial.
In that case your application SettingsActivity code should be like:
public class SettingsActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);
}
}
and AndroidManifest.xml part for SettingsActivity
<activity android:name=".SettingsActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="open.location.settings"
android:scheme="http"/>
</intent-filter>
</activity>
and, finally, "deep" link for SettingsActivity in HTML file:
Open Location Settings
Seems, if you don't want to install app on user side, you can also do this in Instant Apps. Details for links to Instant App you can find here.
I use deeplinking with branch.io in my app. App generates url and open it with custom scheme. It goes ok on native android brawser, firefox and opera-mini, but it fails on chrome-android with ERR_UNKNOWN_URL_SCHEME
code below:
manifest
<activity
android:launchMode="singleTask"
android:name=".ui.activity.ShareActivity"
android:screenOrientation="portrait">
<intent-filter>
<data android:scheme="myapp" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Code that generates url (doc: https://dev.branch.io/getting-started/creating-links-in-apps/guide/android/):
public static void generateShortUrl(#NonNull Context aContext,
#Nullable String aMediaId,
#Nullable String aCollectionId,
#NonNull CanonicalIdentifier aCanonicalIdentifier,
#NonNull String aDesktopUrl,
#NonNull Branch.BranchLinkCreateListener aListener){
BranchUniversalObject branchUniversalObject = new BranchUniversalObject()
.setCanonicalIdentifier(String.valueOf(aCanonicalIdentifier.ordinal() + 1))
.setContentIndexingMode(BranchUniversalObject.CONTENT_INDEX_MODE.PUBLIC)
.addContentMetadata(SHARE_MEDIA_ID, aMediaId);
if(BuildConfig.DEBUG){
Log.e("BranchConfigTest","share date:"+branchUniversalObject.convertToJson().toString());
}
if(!TextUtils.isEmpty(aCollectionId))
branchUniversalObject.addContentMetadata(SHARE_COLLECTION_ID,aCollectionId);
if(!TextUtils.isEmpty(aMediaId))
branchUniversalObject.addContentMetadata(SHARE_MEDIA_ID,aMediaId);
LinkProperties linkProperties = new LinkProperties()
.setFeature("sharing")
.addControlParameter("$desktop_url", aDesktopUrl);
branchUniversalObject.generateShortUrl(aContext,linkProperties,aListener);
}
Alex with Branch here: unfortunately this is a known issue with Chrome. Basically, in some release of Chrome 40, it was decided that typed and pasted URLs should prevent automated redirects like the one Branch uses to open the Play Store or launch your app. We worked on a solution with the Chromium team last summer, but it came to our attention a few weeks ago that the issue was only fixed for typed-in URLs, and not for URLs that users paste directly into Chrome's address bar.
The good news is that in the wild, this is extremely, extremely rare. It is usually only triggered by developers in the testing stages of a Branch integration — the vast majority of your users will only click links (rather than pasting URLs) and therefore will never encounter this. Obviously this is still a less than ideal solution, so if you'd like, feel free to file a radar with Chromium. We can get behind it and ask our team to provide examples as well.
I need a way to include a link in an email which either opens a mobile app or redirects the user to a website depending on whether the mobile app is installed or not. I need a solution for both Android and IOS, it is there a set practice on how to achieve this?
Thanks!
You need a combo of answers here I think.
For iOS, You can replace http:// with itms:// or itms-apps:// to avoid redirects.
How to link to apps on the app store
For Android, I think you'll want to look at the <intent-filter> element of your Mainfest file. Specifically, take a look at the documentation for the <data> sub-element.
Make a link in the Android browser start up my app?
On Android, you need to handle this via Intent Filter:
<activity
android:name="com.permutassep.IntentEvaluator"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="your/url"
android:scheme="http" />
<data
android:host="your/url"
android:scheme="https" />
</intent-filter>
</activity>
And the class you need to handle the intent data should look like this:
public class IntentEvaluator extends BaseActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = null;
if(getIntent() != null && getIntent().getData() != null){
// Do whatever you want with the Intent data.
}
}
}
Taken from an app I developed: https://raw.githubusercontent.com/lalongooo/permutas-sep/master/app/src/main/java/com/permutassep/IntentEvaluator.java
I try to use FB deep link to get referral info after App installed when I clicked in deep link which was posted at FB. But I received deep link data only if app already installed.
As follow by this doc
https://developers.facebook.com/docs/applinks/android
Application should receive data from deep link, after app has been installed.
But native FB application send to GooglePlay only :
market://details?id=my.app.package&referrer=utm_source=apps.facebook.com&utm_campaign=fb4a&utm_content=%7B%22app%22%3A0%2C%22t%22%3A1436879844%7D
There is no info from deep link
And one first launch I try use in my launch screen next methods
AppLinks.getTargetUrlFromInboundIntent
and AppLinkData.fetchDeferredAppLinkData
but they get me null.
Step by step
I have created hosted api links for android. Where include all possible data for android https://developers.facebook.com/docs/graph-api/reference/v2.0/app/app_link_hosts
Then by FB SDK post this link.
Remove my application
Click on my post with deep link in native FB application
FB ask me to install app. And I have installed app from GooglePLay
Expected :
After install receive deep link data on start app.
But if use method described at FB Docs I did not receive any info
A heads up that I helped build Branch (branch.io), a linking tool that helps with deep linking through the Play Store. We've had a ton of trouble getting Facebook's methods to work reliably as well. If you use a Branch deep link to host your Facebook App Links, it works 100% of the time through page posts, ads and invites. We have a server to server integration with Facebook, but if that fails, we fall back to our fingerprinting mechanism where we match a browser fingerprint to a device fingerprint. (More on that here)
Here's a description of how to get setup so that Branch hosts your Facebook App Links and deep links through install:
Head to start.branch.io to get your Branch key and configure your link routes
Add in the io.branch.sdk.android library from Maven Central
Setup your manifest for deep linking. You'll start with this:
<application>
<!-- Other existing entries -->
<activity
android:name="com.yourapp.SplashActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Add application subclass so that Branch can monitor for lifecycle changes to detect new deep links.
<application
android:name="io.branch.referral.BranchApp">
Add your intent filters to receive the deep link when the app is already installed
<intent-filter>
<data android:scheme="yourapp" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
Add your Branch key
<meta-data android:name="io.branch.sdk.BranchKey" android:value="your_key_here" />
The final Manifest should look like this:
<application
android:name="io.branch.referral.BranchApp">
<!-- Other existing entries -->
<activity
android:name="com.yourapp.SplashActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data android:scheme="yourapp" android:host="open" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<meta-data android:name="io.branch.sdk.BranchKey" android:value="your_key_here" />
</application>
Register to receive parameters from Branch deep link click. This is frequently put in onStart of the Activity that you want to use for deep link routing.
Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new BranchReferralInitListener(){
#Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// ... insert custom logic here ...
} else {
Log.i("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);
Lastly, to you can create Branch-hosted Facebook App Links in 100 different ways. Here's how to create them dynamically from your app:
Branch branch = Branch.getInstance();
JSONObject obj = new JSONObject(); obj.putString("foo", "bar");
branch.getShortUrl(obj, "sms", "share", new BranchLinkCreateListener() {
#Override
public void onLinkCreate(String url, BranchError error) {
Log.i("MyApp", "Ready to share my link = " + url);
}
});
Happy linking!