/// <summary> /// Handle protocol activations. /// </summary> /// <param name="e">Details about the activate request and process.</param> protected override async void OnActivated(IActivatedEventArgs e) { if (e.Kind == ActivationKind.Protocol) { // Handle URI activation ProtocolActivatedEventArgs eventArgs = e as ProtocolActivatedEventArgs; // Initialize the links information LinkInformationService.Reset(); bool validUri = true; Exception exception = null; try { validUri = eventArgs.Uri.IsWellFormedOriginalString(); if (validUri) { // Use OriginalString to keep uppercase and lowercase letters LinkInformationService.ActiveLink = UriService.ReformatUri(eventArgs.Uri.OriginalString); } } catch (UriFormatException ex) { validUri = false; exception = ex; } finally { if (!validUri) { LogService.Log(MLogLevel.LOG_LEVEL_ERROR, "Invalid URI detected during app activation", exception); await DialogService.ShowAlertAsync(ResourceService.AppMessages.GetString("AM_InvalidUri_Title"), ResourceService.AppMessages.GetString("AM_InvalidUri")); } } Frame rootFrame = CreateRootFrame(); if (eventArgs.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // When the navigation stack isn't restored navigate to the first page, configuring // the new page by passing required information as a navigation parameter if (rootFrame.Content == null) { rootFrame.Navigate(typeof(MainPage), eventArgs); } // Ensure the current window is active Window.Current.Activate(); // Check session and special navigation await AppService.CheckActiveAndOnlineSessionAsync(); // Validate product subscription license on background thread Task.Run(() => LicenseService.ValidateLicensesAsync()); } }
/// <summary> /// Process the verify email link /// </summary> public async void ProcessVerifyEmailLink() { if (string.IsNullOrWhiteSpace(LinkInformationService.ActiveLink) || !LinkInformationService.ActiveLink.Contains("#verify")) { return; } this.VerifyEmailLink = LinkInformationService.ActiveLink; LinkInformationService.Reset(); var verifyEmail = new QueryChangeEmailLinkRequestListenerAsync(); var result = await verifyEmail.ExecuteAsync(() => this.MegaSdk.queryChangeEmailLink(this.VerifyEmailLink, verifyEmail)); switch (result) { case QueryChangeEmailLinkResult.Success: this.Email = verifyEmail.Email; return; case QueryChangeEmailLinkResult.InvalidLink: await DialogService.ShowAlertAsync(ResourceService.UiResources.GetString("UI_ChangeEmail"), ResourceService.AppMessages.GetString("AM_ChangeEmailInvalidLink")); break; case QueryChangeEmailLinkResult.UserNotLoggedIn: await DialogService.ShowAlertAsync(ResourceService.UiResources.GetString("UI_ChangeEmail"), ResourceService.AppMessages.GetString("AM_UserNotOnline")); break; case QueryChangeEmailLinkResult.Unknown: default: await DialogService.ShowAlertAsync(ResourceService.UiResources.GetString("UI_ChangeEmail"), ResourceService.AppMessages.GetString("AM_ChangeEmailGenericError")); break; } OnUiThread(() => { NavigateService.Instance.Navigate(typeof(MainPage), true, NavigationObject.Create(typeof(ConfirmChangeEmailViewModel), NavigationActionType.Default)); }); }
private void InitializeApplication() { if (ApplicationInitialized) { return; } // Clear settings values we do no longer use AppService.ClearObsoleteSettings(); // Initialize the application information if (AppInformation == null) { AppInformation = new AppInformation(); } // Initialize the links information LinkInformationService.Reset(); // Initialize SDK parameters SdkService.InitializeSdkParams(); // Add a global notifications listener GlobalListener = new GlobalListener(); SdkService.MegaSdk.addGlobalListener(GlobalListener); // Add a global request listener to process all. SdkService.MegaSdk.addRequestListener(this); // Add a global transfer listener to process all transfers. SdkService.MegaSdk.addTransferListener(TransferService.GlobalTransferListener); // Initialize Folders AppService.InitializeAppFolders(); // Initialize the DB AppService.InitializeDatabase(); // Save the app information for future use (like deleting settings) AppService.SaveAppInformation(); // Ensure we don't initialize again ApplicationInitialized = true; }