Yes, this can happen is in your application you go straight to Vuforia (QCAR) initialization (for example doing that in the background, like the native Vuforia samples do).
The iOS Camera access dialog will popup as soon as you try to get camera access (normally this would occur at the time that you call QCAR::CameraDevice::init and /or QCAR::CameraDevice::start).
What happens is that, even if you answer Yes (i.e. you allow camera access), but you are not fast enough, Vuforia will go ahead with camera start (in background thread) before actually getting access granted by the O.S.
So, what you need to do is to proactively trigger the Camera Access dialog by adding this code at application startup time, preferably in the application:didFinishLaunchingWithOptions method (that you can find in your AppDelegate.m file):
if ([AVCaptureDevice respondsToSelector:@selector(requestAccessForMediaType:completionHandler:)]) {
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
if (YES == granted) {
NSLog(@"User granted access to camera. OK.");
}
else {
NSLog(@"User denied access to camera");
// Here you should popup a dialog
// to Tell the user that he denied camera access,
// but the app requires camera access
// for example show a UI dialog explaining the user that he
// can restore camera access for the app via
// Settings > Privacy > Camera
}
}];
}
else {
// iOS < 7, camera access always OK.
}
Note that if you run that code on iOS7, no dialog will be displayed, because the camera access is automatically granted (so, you will only see a log message saying "User granted access to camera. OK". And the app will work normally.
On iOS 8, that code (in particular the requestAccessForMediaType function) will do one of the following:
- if the user had already allowed camera access previously (for example in a previous run, or by doing that in the Settings > Privacy > Camera), then no dialog will be shown, and the access will be granted and the app will continue normally.
- if the user had not yet allowed acces (i.e. we are on the very first run), then the Camera Access dialog will be prompted and will block waiting for the user answer. This will make sure the Vuforia does not initialize in the background.
Note that you could also put that code in other places; for example, if your App has a start / splash screen / loading screen / start menu page or similar, you could also plug the code in there.
The important thing is that you make sure that the Vuforia initialization process does not start until the access has been granted. If you arenot sure where to put that code, the safest place is always in the application: didFinishLaunchingWithOptions (right at the beginning).
Hope this helps.
A Sticky notice with a summary of this (and others) iOS8 related issues will also be posted soon, but in the meantime you can follow the advice above.
Finally I found out that this behaviour is likely to be intended by Apple. Page 24 in WWDC 2012 Session Videos: Privacy Support in iOS and OS X states for iOS 6:
"If permissions changes, app is quit".
Further on in App Crashing when I Change "Calendar" Access in Privacy Settings aaron_thompson from Apple answered:
"Fortunately, your app is fine! The system actually kills your app if the user toggles your app's access to calendars in Settings. The same applies to any protected dataclass in the Settings->Privacy section"