OpenUrl freezes app for over 10 seconds

前端 未结 11 879
孤街浪徒
孤街浪徒 2020-12-13 02:05

I\'m currently developing an App, that needs to open a browser to display a webpage. To do that i use the [UIApplication sharedApplication] openURL method with

11条回答
  •  囚心锁ツ
    2020-12-13 02:40

    Thanks for the advise from all the guys above, this is how I solved it in Xamarin.iOS (and Xamarin.Forms). The solution is inspired by what the guys have discussed above, and hope it helps others facing the same problem but using Xamarin.

    
    [Register("AppDelegate")]
    public class AppDelegate
    {
         ....

     public override bool OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)
     {
          // We do some logic to respond to launching app, and return to that app. 
          Task.Delay(500).ContinueWith(_ => {
                this.InvokeOnMainThread( () => {
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString(openUri));
                });
            });
     }
    

    }

提交回复
热议问题