diff --git a/app/android/app/src/main/AndroidManifest.xml b/app/android/app/src/main/AndroidManifest.xml
index 75d27286..824baacd 100644
--- a/app/android/app/src/main/AndroidManifest.xml
+++ b/app/android/app/src/main/AndroidManifest.xml
@@ -26,6 +26,16 @@
+
+
+
+
+
+
+
+
diff --git a/app/ios/Runner/Info.plist b/app/ios/Runner/Info.plist
index 0f45533f..828578ca 100644
--- a/app/ios/Runner/Info.plist
+++ b/app/ios/Runner/Info.plist
@@ -2,6 +2,19 @@
+ FlutterDeepLinkingEnabled
+
+ CFBundleURLTypes
+
+
+ CFBundleURLName
+ pipelines-run
+ CFBundleURLSchemes
+
+ pipelines
+
+
+
CADisableMinimumFrameDurationOnPhone
CFBundleDevelopmentRegion
diff --git a/app/lib/application/app_router.dart b/app/lib/application/app_router.dart
index 46af0ab0..6e9c9689 100644
--- a/app/lib/application/app_router.dart
+++ b/app/lib/application/app_router.dart
@@ -26,8 +26,16 @@ class AppRouteParser extends RouteInformationParser {
/// [AppRoute.parse] understands this form, so a browser location such as
/// `/runs/7/stage/plan?visit=1` keeps the query instead of losing it to
/// `Uri.path`. A fragment is not part of an app route.
-String routeLocation(Uri uri) =>
- uri.hasQuery ? '${uri.path}?${uri.query}' : uri.path;
+///
+/// The native notification link `pipelines://run/` (the URL the server
+/// publishes as the notification's click target, as the Android client
+/// registers it) is the run route `/runs/`.
+String routeLocation(Uri uri) {
+ final path = uri.scheme == 'pipelines' && uri.host == 'run'
+ ? '/runs${uri.path}'
+ : uri.path;
+ return uri.hasQuery ? '$path?${uri.query}' : path;
+}
/// Owns the app's current route and builds the shell for it.
///
@@ -238,13 +246,23 @@ class AppRouterDelegate extends RouterDelegate with ChangeNotifier {
}
}
-/// The location a web launch starts at, or the Pipelines list elsewhere.
+/// The location a launch starts at: the browser location on the web, the
+/// deep link a native app was opened with, or the Pipelines list.
///
/// The origin stays out of route configuration so a serialised route is always
/// app-relative, but the path and its query are both part of the route: a
/// launch at `/runs/7/stage/plan?visit=1` must open exactly that visit.
RouteInformation initialRouteInformation() {
- if (!kIsWeb) return RouteInformation(uri: Uri(path: '/pipelines'));
+ if (!kIsWeb) {
+ // A cold start from a deep link carries the full link as the platform's
+ // initial route; an ordinary launch opens the Pipelines list.
+ final launched = WidgetsBinding.instance.platformDispatcher.defaultRouteName;
+ return RouteInformation(
+ uri: launched.isEmpty || launched == '/'
+ ? Uri(path: '/pipelines')
+ : Uri.parse(launched),
+ );
+ }
return routeInformationForLocation(Uri.base);
}
diff --git a/app/test/application/app_router_test.dart b/app/test/application/app_router_test.dart
index d746433e..5f0c1f33 100644
--- a/app/test/application/app_router_test.dart
+++ b/app/test/application/app_router_test.dart
@@ -100,4 +100,18 @@ void main() {
'/',
);
});
+
+ test('the native notification link opens its run', () async {
+ const parser = AppRouteParser();
+ final run = await parser.parseRouteInformation(
+ RouteInformation(uri: Uri.parse('pipelines://run/42')),
+ );
+ expect(run, AppRoute.run(42));
+ final decide = await parser.parseRouteInformation(
+ RouteInformation(uri: Uri.parse('pipelines://run/42?action=decide')),
+ );
+ expect(decide.path, '/runs/42?action=decide');
+ // Another scheme or host is not a run link.
+ expect(routeLocation(Uri.parse('pipelines://other/42')), '/42');
+ });
}