Skip to content

Commit

Permalink
Intent plugin open when app closed
Browse files Browse the repository at this point in the history
  • Loading branch information
PrimozRatej committed Feb 6, 2024
1 parent b966294 commit 7917b3a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/util/intent/intent_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:humhub/pages/web_view.dart';
import 'package:humhub/util/notifications/channel.dart';
import 'package:humhub/util/router.dart';
import 'package:humhub/util/universal_opener_controller.dart';
import 'package:loggy/loggy.dart';
Expand Down Expand Up @@ -92,6 +91,7 @@ class IntentPluginState extends ConsumerState<IntentPlugin> {
// In this example app this is an almost useless guard, but it is here to
// show we are not going to call getInitialUri multiple times, even if this
// was a widget that will be disposed of (ex. a navigation route change).

if (!_initialUriIsHandled) {
_initialUriIsHandled = true;
try {
Expand All @@ -102,10 +102,14 @@ class IntentPluginState extends ConsumerState<IntentPlugin> {
_latestUri = uri;
String? redirectUrl = uri.queryParameters['url'];
if (redirectUrl != null && navigatorKey.currentState != null) {
logInfo('MD22 IF open: $_initialUriIsHandled');
tryNavigateWithOpener(redirectUrl);
} else {
if (redirectUrl != null) {
InitFromPush.setPayload(redirectUrl);
UniversalOpenerController opener = UniversalOpenerController(url: redirectUrl);
await opener.initHumHub();
navigatorKey.currentState!.pushNamed(WebViewApp.path, arguments: opener);
return;
}
}
} on PlatformException {
Expand All @@ -120,6 +124,7 @@ class IntentPluginState extends ConsumerState<IntentPlugin> {
}

Future<bool> tryNavigateWithOpener(String redirectUrl) async {
logInfo('MD initHumHub payload: $redirectUrl');
bool isNewRouteSameAsCurrent = false;
navigatorKey.currentState!.popUntil((route) {
if (route.settings.name == WebViewApp.path) {
Expand Down

0 comments on commit 7917b3a

Please sign in to comment.