从iOS 8设置启用相机访问时,应用程序崩溃 [英] App crashes on enabling Camera Access from Settings iOS 8

查看:161
本文介绍了从iOS 8设置启用相机访问时,应用程序崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款适用于iPhone的应用程序,它使用相机扫描条形码和拍照。当我们没有Camera访问权限并且用户启用了Camera Access时,应用程序崩溃并重新打开。

I am developing an app for iPhone, it is using camera for scanning barcodes and taking pictures. When we don't have Camera access and the user enables Camera Access, the app crashes and the re-opens.

你能帮助我解决这个问题吗?

Can you folks help me to fix this?

提前致谢。

推荐答案

第一次访问相机时操作系统将自动显示权限提示。无论用户是允许还是拒绝提示,您的应用都将继续运行。如果用户在某个时刻更改了地址簿,日历,提醒,相机或照片权限,则iOS将 SIGKILL 该应用。它采取此操作以确保应用程序不再拥有其拥有的任何先前授权的数据。当用户从设置应用程序移回第三方应用程序时,它将从头开始启动,现在具有拒绝授权状态。由于这种行为,我有两个建议:

The first time you access the Camera the OS will automatically show the permission prompt. Whether the user allows or denies the prompt, your app will continue running. If the user at some point changes the Address Book, Calendars, Reminders, Camera, or Photos permissions, iOS will SIGKILL the app. It takes this action to ensure that the app no longer has any previously authorized data in its possession. When the user moves from the Settings app back to the third-party app, it launches from scratch and now has the Denied authorization status. As a result of this behavior, I have two recommendations:


  1. 检测权限何时被拒绝并提供一些解释该权限的UI用户需要切换设置应用程序权限。在iOS 8中,您可以使用 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]] 将它们直接带到您应用的条目。

  1. Detect when the permission is denied and present some UI that explaining that the user needs to toggle the Settings app permission. In iOS 8 you can take them directly to your app's entry with [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]].

实施某种状态恢复,以便当应用程序终止并重新启动时,它会将用户返回到先前可见的视图/功能。

Implement some sort of state restoration so that when the app is terminated and relaunched it will return the user to the view/feature that was previously visible.

来源(需要开发者帐户)

这篇关于从iOS 8设置启用相机访问时,应用程序崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆