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