Esempio n. 1
0
        private void NavigateUniversalLinks(NSUrl url)
        {
            try
            {
                var urlComponents = new NSUrlComponents(url, true);
                if (urlComponents.Path?.StartsWith("/cocoa/a/") == true)
                {
                    var processingNumber = urlComponents
                                           .QueryItems?
                                           .FirstOrDefault(item => item.Name == AppConstants.LinkQueryKeyProcessingNumber)?
                                           .Value;

                    if (processingNumber != null && Validator.IsValidProcessingNumber(processingNumber))
                    {
                        var navigationParameters = NotifyOtherPage.BuildNavigationParams(processingNumber);
                        InvokeOnMainThread(async() => await AppInstance?.NavigateToSplashAsync(Destination.NotifyOtherPage, navigationParameters));
                    }
                    else
                    {
                        _loggerService.Value.Error("Failed to navigate NotifyOtherPage with invalid processingNumber");
                        InvokeOnMainThread(async() => await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters()));
                    }
                }
            }
            catch (Exception e)
            {
                _loggerService.Value.Exception("Failed to NavigateUniversalLinks", e);
            }
        }
Esempio n. 2
0
        private async Task NavigateToDestinationFromIntent(Intent intent)
        {
            _loggerService.Value.StartMethod();


            if (intent.Data != null)
            {
                _loggerService.Value.Info("Intent has data.");

                var processingNumber = intent.Data.GetQueryParameter(AppConstants.LinkQueryKeyProcessingNumber);

                if (processingNumber != null && Validator.IsValidProcessingNumber(processingNumber))
                {
                    _loggerService.Value.Info("ProcessingNumber is valid.");

                    var navigationParameters = NotifyOtherPage.BuildNavigationParams(processingNumber);
                    await AppInstance?.NavigateToSplashAsync(Destination.NotifyOtherPage, navigationParameters);
                }
                else
                {
                    _loggerService.Value.Error("Failed to navigate NotifyOtherPage with invalid processingNumber");
                    await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters());
                }
            }
            else if (intent.HasExtra(EXTRA_KEY_DESTINATION))
            {
                int ordinal     = intent.GetIntExtra(EXTRA_KEY_DESTINATION, (int)Destination.HomePage);
                var destination = (Destination)Enum.ToObject(typeof(Destination), ordinal);

                _loggerService.Value.Info($"Intent has destination: {destination}");

                var navigationParameters = new NavigationParameters();
                await AppInstance?.NavigateToSplashAsync(destination, navigationParameters);
            }
            else
            {
                await AppInstance?.NavigateToSplashAsync(Destination.HomePage, new NavigationParameters());
            }

            _loggerService.Value.EndMethod();
        }