@@ -5,6 +5,9 @@ import 'package:flutter/services.dart';
55import 'package:keevault/logging/logger.dart' ;
66import 'package:keevault/payment_service.dart' ;
77import 'package:keevault/widgets/dialog_utils.dart' ;
8+ import 'package:app_links/app_links.dart' ;
9+ import 'package:keevault/utils/deep_link_utils.dart' ;
10+ import 'package:keevault/config/routes.dart' ;
811import 'package:logger/logger.dart' ;
912import 'package:matomo_tracker/matomo_tracker.dart' hide Level;
1013import 'package:public_suffix/public_suffix.dart' ;
@@ -38,6 +41,30 @@ void main() async {
3841 DefaultSuffixRules .initFromString (suffixList);
3942 l.i ('Initialized PSL' );
4043 runApp (KeeVaultApp (navigatorKey: navigatorKey));
44+
45+ // Deep link handling
46+ final appLinks = AppLinks ();
47+ appLinks.uriLinkStream.listen ((Uri uri) {
48+ final fragment = uri.fragment;
49+ final host = uri.host;
50+ final validHosts = ['keevault.pm' , 'app-beta.kee.pm' , 'app-dev.kee.pm' ];
51+ if (validHosts.contains (host) && fragment.isNotEmpty) {
52+ final params = parseKeeVaultFragment (fragment);
53+ if (params != null ) {
54+ navigatorKey.currentState? .pushNamed (
55+ Routes .deepLinkEcho,
56+ arguments: {'params' : params, 'rawUrl' : uri.toString ()},
57+ );
58+ return ;
59+ }
60+ }
61+ // If not valid, do nothing (let browser handle)
62+ //TODO: above is bullshit? May need to relaunch a new Intent via a plugin on Android like:
63+ // Pass the URL to the default browser
64+ // Intent browserIntent = new Intent(Intent.ACTION_VIEW, uri);
65+ // startActivity(browserIntent);
66+ // Unknown how iOS will behave but probably irrelevant since we control the links we accept from the web hosted file anyway.
67+ });
4168 },
4269 (dynamic error, StackTrace stackTrace) {
4370 if (error is KeeLoginFailedMITMException ) {
0 commit comments