UIWebview unable to access camera or photos - uiwebview

I have an app with a Storyboard scene. In the storyboard scene I have a UIWebView. In the storyboard scene I have a UIWebView. My code is as follows:
#IBOutlet weak var webView: UIWebView!
override func viewDidLoad() {
super.viewDidLoad()
let url = URL(string: “http://www.somepage.com”)
let urlRquest = URLRequest(url: url!)
webView.loadRequest(urlRquest)
}
The user is able to navigate and click on links in the UIWebView. I run into an issue when that web view requests access to the camera or stored photos.
iOS presents a standard control at the bottom of the view with the following options:
Take Photo or Video
Photo Library
Browse
Cancel
Once the user selects ANY of the options the webview disappears and I get the following error:
<UIImagePickerController: 0x1071ae400> on <MyApp.WebViewVC: 0x10e924ae0> whose view is not in the window hierarchy!
I am not able to use WKWebView in this particular app.
I have verified that the proper permissions are requested in the plist file and I am able to access photo album and camera within the app and have requested permissions before calling the web view.
I did not implement any of the UIImagePickerControllerDelegate functions as this is a UIWebView requesting access.

Related

.NET MAUI Dynamic Tab page

I am having issue to implement dynamic tab page in .NET MAUI project. Can we add tabs into Navigation page at runtime to open Webpage. I am trying to implement functionality model like Chrome or Edge to open web URLs in separate tab.
Can we add tabs into Navigation page at runtime to open Webpage
What does the webpage mean? At first, if you want to add a new tab into the TabbedPage when the user operates in the child page, you can use the the following code in the child page:
var tabbedpage = this.Parent as TabbedPage;
tabbedpage.Children.Add(new ChildPage());
And then if the ChildPage just have a webview in it and you want to add a new tab when the webview navigates to a new url. You can add a Navigating event to the webview and pass the url to the child page.
Update
You can create a construction method which has a parameter for the ChildPage, such as:
public ChildPage(string url)
{
//use the url here
}

Navigating to a specific view from appdelegate using xamarin.ios and mvvmcross

I am working on a cross platform app using xamarin and MVVMcross.
I want to navigate to Login page when the app is in background for a specific amount of time.
I was successfull in implementing the same in android but wasn't able to find a proper solution in ios for this where MVVMCross is used.
Below is my Android code which is working
Intent intent = new Intent(this, typeof(LoginView));
var viewModelRequest = new MvxViewModelRequest(typeof(Core.ViewModels.LoginViewModel));
var serializer = new MvvmCross.Core.Parse.StringDictionary.MvxViewModelRequestCustomTextSerializer();
intent.PutExtra("MvxLaunchData", serializer.SerializeObject(viewModelRequest));
StartActivity(intent);
I need to implement the same in ios. I know I need to write a similar code like in android in WillEnterForeground method of Appdelegate but wasn't able to find a proper solution for it anywhere.
Is WillEnterForeground the right place to do this ?
Can someone please help
I was able to go one step ahead
var view = (IMvxIosView)UIStoryboard.FromName("Tasks", null).InstantiateViewController("LoginView");
var viewController = view.CreateViewControllerFor(viewModelRequest) as UIViewController;
Window.RootViewController = new UINavigationController(viewController);
Window.MakeKeyAndVisible();
Now I am able to get to the login screen when the app comes in foreground again.
But when I click the Login button nothing happens.
Just for more information i am using Storyboards and have overridden CreateIosViewsContainer method of MvxIosSetup in my Setup class.
Any help please as I am relatively very new to ios development?

Xamarin Forms, best way to navigate from AppDelegate to a screen in forms?

When I receive a push notification with Custom Data, based on the data available in it, I need to make a call to navigate the user to a certain screen in Xamarin Forms.
public void DidReceiveNotificationResponse(UNUserNotificationCenter center, UNNotificationResponse response, Action completionHandler)
{
// This is where I need to navigate the user to a form based screen
}
Any suggestions are welcome.
Thanks
ST

Xamarin.iOS 8.0 - PresentViewController Issue

I have created a RootViewController class. In this class, i have events listening for user logging success and then present view controller to login page. It works fine when the application starts because i put RootViewController class to windows.RootViewController property, The issue is - i have a logout button as a bar item on the next page after successfully login. When i click on logout button, i dismiss the current view controller and then try to present the RootViewController again so that RootViewController class can present the login screen back again to the user. But, when i touch the logout button then just white blank screen shows up instead of login page. On the console, it outputs the below warning messages. I just want to add that it was working fine in iOS 7.0 but after updating Xamarin to iOS 8.0 then i start having this issue.
Warning: Attempt to present on whose view is not in the window hierarchy!
I solved this issue. My code for redirecting to login page in the RootViewController has to be in the ViewWillAppear Method. Earlier, I only had this in the ViewDidLoad method. Then, I figured out that ViewDidLoad execute only once in the app load but ViewWillAppear work on evey

JavaFX 2.2 WebView

I am using Javafx and FXML . I have created my form . in one of my pages I have a Tree in the left pane (Split Pane) , and the right pain is a Webview inside the right Anchor pane.
when I select a node on the tree (treeItem) the webview will change accordingly to the respective site that was selected in the tree view.
This works (like a charm)when I run it as an application.
HOWEVER , when viewing this in the browser (i.e. chrome , firefox and safari(mac)) i dont see the web view , it stays blank. i.e. the UI will load and the tree will be there , but the right jand pain never shows the embedded views.
When I run as a webstart I see the right views. The web pages that are embedded into the web views have a login, when i try login the web page flicker , like ther refresh and the login form is blanked, I have to enter the credential again.
not sure what is wrong or how to debug the browser / webstart side.
when viewing this in the browser (i.e. chrome , firefox and safari(mac)) i dont see the web view , it stays blank. i.e. the UI will load and the tree will be there , but the right jand pain never shows the embedded views.
If you not done so already, you will need to sign your application to allow it to run outside of the browser embedded Java application sandbox so that the webview's network layer has permission to access the external locations.
Also monitor the webview loadworker's exception property to see if an exception or FAILED state was encountered:
Worker worker = webview.getEngine().getLoadWorker();
worker.stateProperty().addListener(new ChangeListener<Worker.State>() {
#Override public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State oldState, Worker.State newState) {
System.out.println("Browser state change: " + newState);
}
});
worker.exceptionProperty().addListener(new ChangeListener<Throwable>() {
#Override public void changed(ObservableValue<? extends Throwable> observableValue, Throwable oldThrowable, Throwable newThrowable) {
System.out.println("Browser encountered a load exception: " + newThrowable);
}
});
not sure what is wrong or how to debug the browser / webstart side.
There is an excellent Oracle article on debugging steps for webstart / browser embedded applications. The article provides numerous pointers such as how to set debug and trace levels, etc.

Resources