Crash when toggling access to Camera and Photos [duplicate] - ios

This question already has answers here:
App crashed in iOS 6 when user changes Contacts access permissions
(2 answers)
Closed 7 years ago.
I have a collection view (standard flow layout) where the first cell is displaying a live camera feed, and the rest of the cells are displaying photos from the user's library using iOS 8's new Photos Framework. Everything renders and works great.
When opening for the first time, I'm prompted for access to the Camera and to the Photos library, as expected. My app behaves fine if I select yes or no for either of the prompts.
However, if I background the app, go into Settings > Privacy > Photos|Camera and toggle access, my app crashes. When connected to Xcode, I don't get any feedback for why the app is crashing.
Unfortunately, Apple's Photos Framework examples app does the same thing.
How can I prevent this from happening? I've subscribed to notifications for AVCaptureDeviceWasConnectedNotification, AVCaptureDeviceWasDisconnectedNotification, and registerChangeObserver on PHPhotoLibrary but those never seem to get called.
Again, here are the steps using Apple's Sample app and the Simulator:
In the Simulator, go to Settings > General > Reset > Reset Location & Privacy
Run the app
Allow the app access to your photos library
Background the Sample App and open Settings
Go to Privacy > Photos and toggle the setting off
Watch Xcode crash
In step 3, if you decline access to your photos, and in step 5, enable access, the app will also crash.

It's not a crash per se. The iOS system terminates every app system wide that has requested access to the Photo Library when that privacy flag is changed (including Apple System Apps).
This originates due to a privacy change made in iOS 6. Look at page 24 in the WWDC 2012 session on Privacy Support in iOS and OS X.

Related

App does not appear in iPad Settings list when iPad connected to Mac as external device

I am developing an iPhone/iPad photo processing app on a Mac using Swift in XCode 13.4. When I connect an iPhone running iOS 15.6 as an external device, the app appear in the Settings list and I can allow it to have access to Photos. When I connect to an iPad running iOS 15.5 as an external device the program runs but fails when trying to access photos using info[UIImagePickerController.InfoKey.phAsset.rawValue]. This is commonly because permission to access photos has not been given to the app. When I tried to set this I found that the app did not appear in the Settings list. The app does appear in the iPhone settings list even though it has never been installed from the App Store.
Okay, so it turns out that you mean you're running from Xcode on the device. Good! But that is irrelevant to the question, as it turns out.
The question is why it is that, on the iPad, there is no entry for your app in the Settings app, is that right? So that would be because on the iPad you've never done anything that causes the app to request permission (such as photos).
The point is, you cannot initiate the granting of permissions from Settings; the app itself must first request permission from the user (using the correct PHPhotoLibrary call). Only after that happens will the app acquire a place in Settings where the user can modify the initial permissions.
Adding a programmatic definition of photo access options as suggested by Matt in main form viewWillAppear solved the problem as per https://developer.apple.com/documentation/photokit/delivering_an_enhanced_privacy_experience_in_your_photos_app. However, iOS 14 or newer is required.

How can I get this App Store purchase window in my app?

I have implemented subscription IAP in my iOS app, but now my boss showed me several apps that provide a very nice purchase ActionSheet like window, when purchasing:
I only get simple Alerts that confirm purchase.
Is this a custom library? I see it in several apps, so it doesn't seem to be a pure custom design. Would love to use it as well.
The first image (The nice User Interface) of yours is from the latest iOS version (iOS 11). That screen gets displayed when you make a purchase in iOS 11. Previous versions will show you the second image for purchases. Get an iOS 11 device and go to App Store to download an app, and you'll get that new fancy UI.
To get that new UI, the app must be compiled with iOS 11 SDK.

App crash on iPhone 7 but not on simulator

My Objective-c app is working well so far from iPhone 5 to iPhone 6s plus. But 2 days before I got some complaints from some iPhone 7 users, the app is crashing on their phone as soon as they installed the app. And when they tap the app icon also the app is crashing. But when I run it on iPhone 7 simulator I don't get any issue. I don't even have an iPhone 7 device to check this issue. Is there any way that I can catch this issue even using an online tool? Please suggest me a solution. Thanks.
Here’s what you’ll need to do to stop the apps from crashing or hanging immediately on open: Install any waiting software update, found in Settings > General > Software Update (it is likely versioned as 10.0.1 and the iPhone 7 may ship with iOS 10.0)
Install and let the iPhone reboot as usual
Open the App Store
Download any new app at all, literally any app, whether it is free or paid does not matter
You’ll see a pop-up message saying Terms and Conditions have changed, accept the new terms by tapping on the numerous “Agree” screens
Exit the App Store
Return to the Home Screen and launch the app(s) that were crashing initially
Source : http://osxdaily.com/2016/09/16/fix-apps-crashing-immediately-new-iphone/
I had the same issue with my old app, then added the permission in Info.plist. like
For Camera:
<key>NSCameraUsageDescription</key>
<string>You can take photos to document your job.</string>
Photo Library
<key>NSPhotoLibraryUsageDescription</key>
<string>You can select photos to attach to reports.</string>
Please check you app for other permission like microphone or other. I hope this will fix your problem.
If you are not satisfied from above answer then try Instuments to check any memory issue or other issue with iPhone 7

iOS 10 App Not Showing in Settings

I recently developed an iOS app using Xcode 8 beta. I ran it on my iPhone (which is currently operating on iOS 10 beta), and it worked fine.
However, my app uses the camera, and I have been attempting to have the user go to settings, and enable the camera.
But my app does not appear in the list of apps in settings. It does not show up in the developer section either.
How can I resolve this bug? Thanks.
Starting from iOS 10, it's mandatory to add "NSCameraUsageDescription" in info.plist which is just an informatory message to the user stating the reason for accessing camera. It will be presented to the user while trying to access the camera only for the first time after installing the application.
Though this key is existing since iOS 7, it has been made mandatory in iOS 10 beta. Please refer to below Apple reference link.
https://developer.apple.com/library/prerelease/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW15
Sometimes the debug log is helpful! I ended up adding the following to my info.plist:
NSCameraUsageDescription
Then in the right side, I described how the app uses the camera.

Error "This app does not have access to your photos"

My app is working good on iPhone 5 but has a problem in iPhone 4 with the same iOS 6.0.
The problem is: When I try to open the photo gallery this issue came "This app does not have access to your photos and video"?
How can I solve this in my application programmatically?
There is nothing in the app what you could do.
The first time you attempt to access the library iOS will ask the user whether the App may access the library/photos or not. In your case the user using the iphone 4 tapped on 'no'.
At the same time an entry is created in the settings/privacy/photos/ with the display name of your app and your small settings icon (if you provided one - otherwise the standard icon will be shrinked automatically)
Go there and switch from off to on.
Do not expect this switch to take effect while the app is running. Along with the address book, not the photographed, I even observe some crashes when this setting is changed while the app is running.

Resources