-
Couldn't load subscription status.
- Fork 941
Description
I encountered this matter yesterday and it took me a day to fix it. At first, I think it relates to Info.plist configuration, something like App Transport Security, but it is not my case. In my case, my application works well as a Flutter standard alone application but when I add it to my existing application, my WebView keeps showing loading state forever.
Try to debug it in Xcode and here is what I've found: The plugin uses rootViewController as the current visible ViewController, it only works in case the application has only one ViewController, but in case of Add2App, the application has many ViewController, our FlutterViewController is one of them. By using the wrong ViewController, the following code doesn't work:
[self.viewController.view addSubview:self.webview];
The result is that WKWebView has never been attached to the current ViewController (a FlutterViewController in this case) and the UI shows loading forever.
Here's my solution to solve this matter:
UIViewController* presentedViewController = self.viewController.presentedViewController;
UIViewController* currentViewController = presentedViewController != nil ? presentedViewController : self.viewController;
[currentViewController.view addSubview:self.webview];
Hope that it is useful.