text
stringlengths
1
372
set up app links for android
deep linking is a mechanism for launching an app with a URI.
this URI contains scheme, host, and path,
and opens the app to a specific screen.
a app link is a type of deep link that uses
http or https and is exclusive to android devices.
setting up app links requires one to own a web domain.
otherwise, consider using firebase hosting
or GitHub pages as a temporary solution.
<topic_end>
<topic_start>
1. customize a flutter application
write a flutter app that can handle an incoming URL.
this example uses the go_router package to handle the routing.
the flutter team maintains the go_router package.
it provides a simple API to handle complex routing scenarios.
to create a new application, type flutter create <app-name>:
to include go_router package in your app,
add a dependency for go_router to the project:
to add the go_router package as a dependency,
run flutter pub add:
to handle the routing,
create a GoRouter object in the main.dart file:
<code_start>
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
void main() => runApp(MaterialApp.router(routerConfig: router));
/// this handles '/' and '/details'.
final router = GoRouter(
routes: [
GoRoute(
path: '/',
builder: (_, __) => scaffold(
appBar: AppBar(title: const Text('Home screen')),
),
routes: [
GoRoute(
path: 'details',
builder: (_, __) => scaffold(
appBar: AppBar(title: const Text('Details screen')),
),
),
],
),
],
);
<code_end>
<topic_end>
<topic_start>
2. modify AndroidManifest.xml
add the following metadata tag and intent filter inside the
<activity> tag with .mainactivity.
replace example.com with your own web domain.
info note
the metadata tag flutter_deeplinking_enabled opts
into flutter’s default deeplink handler.
if you are using the third-party plugins,
such as uni_links, setting this metadata tag will
break these plugins. omit this metadata tag
if you prefer to use third-party plugins.
<topic_end>
<topic_start>
3. hosting assetlinks.json file
host an assetlinks.json file in using a web server
with a domain that you own. this file tells the
mobile browser which android application to open instead
of the browser. to create the file,
get the package name of the flutter app you created in
the previous step and the sha256 fingerprint of the
signing key you will be using to build the APK.
<topic_end>
<topic_start>
package name
locate the package name in AndroidManifest.xml,
the package property under <manifest> tag.
package names are usually in the format of com.example.*.
<topic_end>
<topic_start>
sha256 fingerprint
the process might differ depending on how the apk is signed.
<topic_end>
<topic_start>
using google play app signing
you can find the sha256 fingerprint directly from play
developer console. open your app in the play console,
under release> setup > app integrity> app signing tab:
<topic_end>
<topic_start>
using local keystore
if you are storing the key locally,
you can generate sha256 using the following command:
<topic_end>
<topic_start>
assetlinks.json
the hosted file should look similar to this:
set the package_name value to your android application ID.
set sha256_cert_fingerprints to the value you got
from the previous step.
host the file at a URL that resembles the following:
<webdomain>/.well-known/assetlinks.json