How to Make a Link Open an Instagram Page in an App Installed on Android

Link on a webpage to open instagram app

You have a typo the href should be :// not //:

<div>
<a href="instagram://media?id=434784289393782000_15903882">instagram://media?id=434784289393782000_15903882</a>

How do I make a link open an Instagram page in an app installed on flutter

you can use url_launcher package and following approach

if (await canLaunch(url)) {
await launch(
'https://www.instagram.com/<INSTAGRAM_PROFILE>/',
universalLinksOnly: true,
);
}

Intent to open Instagram user profile on Android

I solved this problem using the following code.

Uri uri = Uri.parse("http://instagram.com/_u/xxx");
Intent likeIng = new Intent(Intent.ACTION_VIEW, uri);

likeIng.setPackage("com.instagram.android");

try {
startActivity(likeIng);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://instagram.com/xxx")));
}

how to make links from my website to direct to my app if installed

I found that the way to do this, was using the App Links assistant, which you can find in android studio under Tools -> App Links assistant. This is what you should see on the side once you open it:

Sample Image

Step 1

Click "Open URL Mapping Editor", then add a URL mapping (Click the "+").
In the host, put your website link e.g: https://www.example.com. For Path, in the select box, select just "path" and put nothing in the type box.

Sample Image

Step 2

The Select Activity button does not work for Kotlin, so here's the code that you manually need to put in.

    override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleIntent(intent)
}

private fun handleIntent(intent: Intent) {
val wbWebView = findViewById<View>(R.id.your_webview) as WebView
val appLinkAction = intent.action
val appLinkData = intent.data
if (Intent.ACTION_VIEW == appLinkAction && appLinkData != null) {
wbWebView.loadUrl(appLinkData.toString())
} else {
// default link that it goes to when opening app
wbWebView.loadUrl("https://www.example.com")
}
}

and in your onCreate add handleIntent(intent)

Step 3

Click the "Open Digital Asset Links File Generator". Most of the information will be already filled, so you can go on to click the "Generate Digital Asset Links File". Make a folder called ".well-known" in your website and then put a file in there called "assetlinks.json", paste the preview into there. So when you go to https://www.yourwebsite.com/.well-known/assetlinks.json you should be able to see the Digital asset links file. You can also see other websites Digital asset links file. Like for google, https://www.google.com/.well-known/assetlinks.json.

Sample Image

Then proceed to click the "Link and Verify" button, If all goes well you should see this appear beneath the button:

Sample Image

Step 4

Time to test! Go ahead and click on "Test app links" and put in a URL from your website. If all goes well, you shouldn't see a disambiguation dialogue.

I also like to do further testing by sending myself an email with the link in it.

Notes

You can only use the App Links Assistant if your website is using https instead of http.

I added android:launchMode="singleTask" into my activity tag in the manifest, this means that If you click on a link from your website in an email then it will open in a new window.

They have a doc about this here which includes a video (Keep in mind that they are using java)



Related Topics



Leave a reply



Submit