Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent iOS apps from resetting after changing Camera permissions?

Currently, when I change the camera permissions for my app in Settings, then navigate back to my app, the app will force a refresh and I will lose my place in the app. I follow these steps exactly:

  1. Open an app that uses the camera permission.
  2. Navigate to some screen within the app (so you can visibly see the refresh later)
  3. Go to the Settings app, navigate to the app's settings, and toggle the camera permission
  4. Double click home and go back to the app. After a few seconds, it will refresh, bringing you back to the first screen

Note: I'm using an iPhone 6 running iOS 8.4

I've noticed this behavior on all apps that have the camera permission. My question is: Is there some way to prevent the app from refreshing/restarting (on resume) after changing the camera permission? It doesn't seem to happen when you toggle location services, for example, and from a usability perspective this is horrible.

User scenario: If a user navigates deep into your app, then needs to change the camera permission (because say they accidentally clicked no last time), they will be forced to navigate back to that screen when they return. This is especially harmful for an app trying to sell you something, or sign you up for a new account. They might try to introduce a new feature where you can use the camera to take a profile picture or scan your credit card. Because the user didn't know about this feature, they might have previously denied camera access, but now want to enable it. After trying to reenable, they come back to your app to find they have to spend 5+ minutes signing up / making a purchase, again! After that, even I would probably give up.

like image 488
nickjm Avatar asked Jul 29 '15 16:07

nickjm


People also ask

How do you fix camera permission on iPhone?

Step 1: Go to Settings, and scroll down to the list of apps, find out the app you want to manage. Step 2: Tap an app and you'll see the permissions it wants. You can enable or disable camera permissions for specific apps from here.

How do I give an app permission to access the camera on my iPhone?

Review or change access to the camera, microphone, and other hardware features. Go to Settings > Privacy. Tap a hardware feature, such as Camera, Bluetooth, Local Network, or Microphone.


1 Answers

I'm sure that there is no other ways to prevent restarting app. Actually you will get a SIGKILL message but no Crash log when toggling settings. See below links-

  • https://devforums.apple.com/message/715855
  • https://devforums.apple.com/message/714178

The only way to prevent this scenario is to save the previous state of you application while terminating.

  • Store app your current data into a json/plist/NSUserDefaults/archive user model at applicationWillTerminate: method and
  • restore saved data at applicationWillEnterForeground:

For example- @SignUpViewController register for UIApplicationWillTerminateNotification which will fire when the app is about to terminate. Store user information there.

- (void)viewDidLoad
{
 [super viewDidLoad];
 [[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(applicationWillTerminate:)
    name: UIApplicationWillTerminateNotification object:nil];
}

- (void)applicationWillTerminate:(NSNotification *)notification
{
 // store your data here
}

Hope this will help you:)

like image 177
Shamim Hossain Avatar answered Oct 19 '22 23:10

Shamim Hossain