public override void ViewWillAppear (bool animated)
{
base.ViewWillAppear (animated);
sessionQueue.DispatchAsync (() => {
switch (setupResult) {
// Only setup observers and start the session running if setup succeeded
case SetupResult.Success:
AddObservers ();
Session.StartRunning ();
sessionRunning = Session.Running;
break;
case SetupResult.CameraNotAuthorized:
DispatchQueue.MainQueue.DispatchAsync (() => {
string message = "AVCamManual doesn't have permission to use the camera, please change privacy settings";
UIAlertController alertController = UIAlertController.Create ("AVCamManual", message, UIAlertControllerStyle.Alert);
UIAlertAction cancelAction = UIAlertAction.Create ("OK", UIAlertActionStyle.Cancel, null);
alertController.AddAction (cancelAction);
// Provide quick access to Settings
UIAlertAction settingsAction = UIAlertAction.Create ("Settings", UIAlertActionStyle.Default, action => {
UIApplication.SharedApplication.OpenUrl (NSUrl.FromString (UIApplication.OpenSettingsUrlString), new UIApplicationOpenUrlOptions (), null);
});
alertController.AddAction (settingsAction);
PresentViewController (alertController, true, null);
});
break;
case SetupResult.SessionConfigurationFailed:
DispatchQueue.MainQueue.DispatchAsync (() => {
string message = "Unable to capture media";
UIAlertController alertController = UIAlertController.Create ("AVCamManual", message, UIAlertControllerStyle.Alert);
UIAlertAction cancelAction = UIAlertAction.Create ("OK", UIAlertActionStyle.Cancel, null);
alertController.AddAction (cancelAction);
PresentViewController (alertController, true, null);
});
break;
}
});
}