Viewing version 3.1.0. Open the latest package page.
app_links
3.1.0Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
Readme
app_links
Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler.
This plugin allows you to:
- catch HTTPS URLs to open your app instead of the browser (App Link / Universal Link).
- catch custom schemes to open your app (Deep Link / Custom URL scheme).
Getting Started
Before using the plugin, you'll need to setup each platforms you target.
Android
- App Links: Documentation
- Deep Links: Documentation
iOs
- Universal Links: Documentation
- Custom URL schemes: Documentation
Windows
Declare this method in <PROJECT_DIR>\windows\runner\win32_window.h
// Dispatches link if any.
// This method enables our app to be with a single instance too.
// This is optional but mandatory if you want to catch further links in same app.
bool SendAppLinkToInstance(const std::wstring& title);
Add this inclusion at the top of <PROJECT_DIR>\windows\runner\win32_window.cpp
#include <app_links_windows/app_links_windows_plugin.h>
Add this method in <PROJECT_DIR>\windows\runner\win32_window.cpp
bool Win32Window::SendAppLinkToInstance(const std::wstring& title) {
// Find our exact window
HWND hwnd = ::FindWindow(kWindowClassName, title.c_str());
if (hwnd) {
// Dispatch new link to current window
SendAppLink(hwnd);
// (Optional) Restore our window to front in same state
WINDOWPLACEMENT place = { sizeof(WINDOWPLACEMENT) };
GetWindowPlacement(hwnd, &place);
switch(place.showCmd) {
case SW_SHOWMAXIMIZED:
ShowWindow(hwnd, SW_SHOWMAXIMIZED);
break;
case SW_SHOWMINIMIZED:
ShowWindow(hwnd, SW_RESTORE);
break;
default:
ShowWindow(hwnd, SW_NORMAL);
break;
}
SetWindowPos(0, HWND_TOP, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE);
SetForegroundWindow(hwnd);
// END Restore
// Window has been found, don't create another one.
return true;
}
return false;
}
Add the call to the previous method in CreateAndShow
bool Win32Window::CreateAndShow(const std::wstring& title,
const Point& origin,
const Size& size) {
if (SendAppLinkToInstance(title)) {
return false;
}
...
Great!
Now you can register your own scheme.
This package can not do it for you.
You can make it with url_protocol inside you app.
But... The most relevant is to include those registry modifications into your installer to allow the unregistration.
AppLinks usage
final _appLinks = AppLinks();
// Get the initial/first link.
// This is also useful when app was terminated (i.e. not started)
final uri = await _appLinks.getInitialAppLink();
// Do something (navigation, ...)
// Subscribe to further events when app is started.
// (Use stringLinkStream to get it as [String])
_linkSubscription = _appLinks.uriLinkStream.listen((uri) {
// Do something (navigation, ...)
});
...
// Maybe later. Get the latest link.
final uri = await _appLinks.getLatestAppLink();
Android notes:
-
Intent action is filtered by
Intent.ACTION_VIEW. -
By default, flutter Activity is set with
android:launchMode="singleTop". This is perfectly fine and expected, but this launches another instance of your app, specifically for the requested view.
If you don't want this behaviour, you can setandroid:launchMode="singleInstance"in yourAndroidManifest.xmland avoid another flutter warmup.
Tests
The following commands will help you to test links.
Android
adb shell am start
-W -a android.intent.action.VIEW
-d "<URI>" <PACKAGE>
For App Links, you can also test it from Android Studio: Documentation.
iOs
/usr/bin/xcrun simctl openurl booted "<URI>"
Changelog
3.1.0
- feat: Add Windows support.
3.0.2
- fix: iOS
applicationcallbacks do not returntrueanymore.
3.0.1
- core: Improve Android code.
3.0.0
- core: Breaking API changed to use stream instead of callback.
- fix: Consistent behaviour between iOS & Android with (deffered) stream usage (for onAppLink vs. getInitialLink "duplicated" links).
- fix: remove example splashscreen deprecation.
2.2.2
- core: Add linter.
- fix: Get rid of Android LocalBroadcastReceiver deprecation (removed dependency & import...).
2.2.1
- fix: Duplicated iOS call when app is on terminated status.
- fix: iOS
applicationcallback does not returntrueanymore. - fix: Get rid of Android LocalBroadcastReceiver deprecation.
- core: Updated dependencies.
2.2.0
- Add web support. (getInitialAppLink() only).
2.1.0
- Breaking: String uri added on
onAppLinkfor custom handling like uppercased uri. - Feat:
getInitialAppLinkStringandgetLatestAppLinkStringadded to reflect the above change.
2.0.0+1
- Minimal sample added (Thanks to @JamesCullum).
2.0.0
- Add null safety support.
1.0.0
- Same as 0.2.0.
- No known issue. Bumping to 1.0 to be prepared for null safety version.
0.2.0
- Add configurations in example.
0.1.0+2
- Update README.md.
0.1.0+1
- Add documentation.
- Format dart source code.
0.1.0
- Initial release.
- Android App Links, Deep Links, iOs Universal Links and Custom URL schemes.
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'app_links:3.1.0'pubspec.yaml
name: app_links
description: Android App Links, Deep Links, iOs Universal Links and Custom URL schemes handler for Flutter.
version: 3.1.0
homepage: https://github.com/llfbandit/app_links
environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"
dependencies:
flutter:
sdk: flutter
app_links_platform_interface: ^1.0.1
app_links_web: ^1.0.0
app_links_windows: ^1.0.0
dev_dependencies:
flutter_test:
sdk: flutter
# https://pub.dev/packages/lints
lints: ^1.0.1
# The following section is specific to Flutter.
flutter:
# This section identifies this Flutter project as a plugin project.
# The 'pluginClass' and Android 'package' identifiers should not ordinarily
# be modified. They are used by the tooling to maintain consistency when
# adding or updating assets for this project.
plugin:
platforms:
android:
package: com.llfbandit.app_links
pluginClass: AppLinksPlugin
ios:
pluginClass: AppLinksPlugin
web:
default_package: app_links_web
windows:
default_package: app_links_windows
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.1.0 | Cached · Upstream SHA-256 matched | Download | 07891d9d…8285a8 |
| 0.1.0+1 | Cached · Upstream SHA-256 matched | Download | 86542ee4…50d501 |
| 0.1.0+2 | Cached · Upstream SHA-256 matched | Download | 2ec3d04c…2af9d4 |
| 0.2.0 | Cached · Upstream SHA-256 matched | Download | becd0893…97c3d0 |
| 1.0.0 | Cached · Upstream SHA-256 matched | Download | 2c0b508b…c91682 |
| 2.0.0 | Cached · Upstream SHA-256 matched | Download | a3bc0cfb…9a8176 |
| 2.0.0+1 | Cached · Upstream SHA-256 matched | Download | cf0bb213…342014 |
| 2.1.0 | Cached · Upstream SHA-256 matched | Download | 8952ce08…a65c01 |
| 2.2.0 | Cached · Upstream SHA-256 matched | Download | 02d5b116…dd18f7 |
| 2.2.1 | Cached · Upstream SHA-256 matched | Download | 4af01185…c78234 |
| 2.2.2 | Cached · Upstream SHA-256 matched | Download | de064ea9…db2f1c |
| 3.0.0 | Cached · Upstream SHA-256 matched | Download | fcf08826…f3bb35 |
| 3.0.1 | Cached · Upstream SHA-256 matched | Download | bbe434aa…d35163 |
| 3.0.2 | Cached · Upstream SHA-256 matched | Download | 24feda5b…787688 |
| 3.1.0 | Cached · Upstream SHA-256 matched | Download | 7a28970b…8db7f2 |
| 3.2.0 | Cached · Upstream SHA-256 matched | Download | cbf1dbb4…33ecfe |
| 3.3.0 | Cached · Upstream SHA-256 matched | Download | d1b2cf9a…e36a0d |
| 3.4.0 | Cached · Upstream SHA-256 matched | Download | a669e117…da4df2 |
| 3.4.1 | Cached · Upstream SHA-256 matched | Download | 0ae67296…0d1e8e |
| 3.4.2 | Cached · Upstream SHA-256 matched | Download | d572dcdf…c1b5e8 |
| 3.4.3 | Cached · Upstream SHA-256 matched | Download | 16725e71…6a4cb6 |
| 3.4.4 | Cached · Upstream SHA-256 matched | Download | f41abc50…80abd5 |
| 3.4.5 | Cached · Upstream SHA-256 matched | Download | eb83c2b1…ef0dae |
| 3.5.0-beta.1 | Cached · Upstream SHA-256 matched | Download | b577f5af…703122 |
| 3.5.0-beta.2 | Cached · Upstream SHA-256 matched | Download | 6604788c…0ac535 |
| 3.5.0-beta.3 | Cached · Upstream SHA-256 matched | Download | 1e1e917e…e5cef8 |
| 3.5.0 | Cached · Upstream SHA-256 matched | Download | 4e392b5e…74a3bb |
| 3.5.1 | Cached · Upstream SHA-256 matched | Download | 3ced568a…0cada4 |
| 4.0.0 | Cached · Upstream SHA-256 matched | Download | fd7fc156…88bb5f |
| 4.0.1 | Cached · Upstream SHA-256 matched | Download | 42dc15ae…08c815 |
| 5.0.0 | Cached · Upstream SHA-256 matched | Download | 0fd41f05…eeb121 |
| 6.0.0 | Cached · Upstream SHA-256 matched | Download | f57cf388…ca3a9f |
| 6.0.1 | Cached · Upstream SHA-256 matched | Download | 1c2b9e9c…53d001 |
| 6.0.2 | Cached · Upstream SHA-256 matched | Download | 8c6ef5ba…e736c9 |
| 6.1.0 | Cached · Upstream SHA-256 matched | Download | c7b2c446…9a0cc1 |
| 6.1.1 | Cached · Upstream SHA-256 matched | Download | 96e67781…5eb3db |
| 6.1.2 | Cached · Upstream SHA-256 matched | Download | 49117eef…9e7a14 |
| 6.1.3 | Cached · Upstream SHA-256 matched | Download | a9905d6a…c4f06b |
| 6.1.4 | Cached · Upstream SHA-256 matched | Download | ae5f9a1b…70c4af |
| 6.2.0 | Cached · Upstream SHA-256 matched | Download | 4acba851…ceb0c7 |
| 6.2.1 | Cached · Upstream SHA-256 matched | Download | f04c3ca9…305e21 |
| 6.3.0 | Cached · Upstream SHA-256 matched | Download | 50437e59…e1c5ea |
| 6.3.1 | Cached · Upstream SHA-256 matched | Download | 7e058edb…93a491 |
| 6.3.2 | Cached · Upstream SHA-256 matched | Download | ad1a6d59…84dd99 |
| 6.3.3 | Cached · Upstream SHA-256 matched | Download | 433df2e6…be7950 |
| 6.4.0 | Cached · Upstream SHA-256 matched | Download | 85ed8fc1…bb54ba |
| 6.4.1 | Cached · Upstream SHA-256 matched | Download | 5f884475…cee3e8 |
| 7.0.0 | Cached · Upstream SHA-256 matched | Download | 3462d9de…8a7abc |
| 7.1.0 | Cached · Upstream SHA-256 matched | Download | a408901c…7a4e4f |
| 7.1.1 | Cached · Upstream SHA-256 matched | Download | a350a5b3…483c18 |
| 7.1.2 | Cached · Upstream SHA-256 matched | Download | 4ec328cd…7f1315 |
| 7.2.0 | Cached · Upstream SHA-256 matched | Download | 9d3c82f6…780dbe |
| 7.2.1 | Cached · Upstream SHA-256 matched | Download | f8db46d2…1188ea |
| 7.2.2 | Cached · Upstream SHA-256 matched | Download | 08ba88bf…bc69c3 |
Dependencies
app_links_platform_interface "^1.0.1"
app_links_web "^1.0.0"
app_links_windows "^1.0.0"
flutter {
"sdk": "flutter"
}