How to open Ana left in MAUI - iOS application

Vaibhav Methuku 60 Reputation points
2024-04-22T13:15:48.8866667+00:00

Hello Team,   

I want the user to force update the application.  So, Based on the below logic, I'm opening an alert with an update option in it. When I click on the update. It is navigating to the Appstore. But when I click on the backbutton on the top left corner the app is being crashed.

     MainThread.BeginInvokeOnMainThread(() =>
			{
				string msg = "A new version of this application is available. " +
					"Please update to the new version now.";
				UIAlertController dlg = UIAlertController.Create("Update Available", msg
					, UIAlertControllerStyle.Alert);
				// this was a remote Notification
				dlg.AddAction(UIAlertAction.Create("Update", UIAlertActionStyle.Default, x =>
				{
					UIApplication.SharedApplication.OpenUrl(new NSUrl(appSpecificStoreLink),
						new NSDictionary() { },
						null);
					Thread.Sleep(100);
                    Thread.CurrentThread.Interrupt();
                }));
				UIWindow window = UIApplication.SharedApplication.KeyWindow;
				window.RootViewController.PresentViewController(dlg, true, null);
			});

 User's image

If I had removed

        Thread.CurrentThread.Interrupt();

user will come back to the application from the appstore and no crashing is happing but user can able to access the application. as per my requirement. I want to restrict the user in the landing page itself.

Thanks  

Vaibhav Methuku.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,897 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,446 Reputation points Microsoft Vendor
    2024-04-23T06:38:11.72+00:00

    Hello,

    After clicking the alert, it will dismiss. It's the default behavior on iOS platform. If it is possible, you could try to display another alert when the page returns back.

    Best Regards,

    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments