mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-25 05:58:42 +01:00
Add the ability to launch app from Crypto QR codes
This commit is contained in:
@@ -202,6 +202,8 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||
super.initState();
|
||||
//_handleIncomingLinks();
|
||||
//_handleInitialUri();
|
||||
|
||||
initUniLinks();
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -210,6 +212,41 @@ class AppState extends State<App> with SingleTickerProviderStateMixin {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
/// handle app links while the app is already started - be it in
|
||||
/// the foreground or in the background.
|
||||
Future<void> initUniLinks() async {
|
||||
try {
|
||||
stream = getLinksStream().listen((String link) {
|
||||
handleDeepLinking(link);
|
||||
});
|
||||
|
||||
final String initialLink = await getInitialLink();
|
||||
|
||||
handleDeepLinking(initialLink);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
}
|
||||
|
||||
void handleDeepLinking(String link) async {
|
||||
if (link == null || !mounted) return;
|
||||
|
||||
final List<String> urlComponents = link.split(":");
|
||||
|
||||
switch (urlComponents.first) {
|
||||
case "bitcoin":
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
print("Bitcoin QR Code: \n${link}");
|
||||
break;
|
||||
case "litecoin":
|
||||
case "haven":
|
||||
case "monero":
|
||||
default:
|
||||
print("@@@@@@@@@@@@@@@@@@@@@@@@@@");
|
||||
print(link);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _handleInitialUri() async {
|
||||
try {
|
||||
final uri = await getInitialUri();
|
||||
|
||||
Reference in New Issue
Block a user