I've got an app on iOS that requires access to the Photo Library on the initial view. It works perfectly every time, except for the VERY first time someone loads the app: when the OS asks for permission to access the user's photos, it's already loaded the view underneath that alert, but it obviously doesn't have the photos to load it properly.
It would be a simple thing to reload the view content once the user grants permission, but I'm having a surprisingly hard time finding a method that is called when that happens.
Is there a method call, or some other way, to detect the moment a user grants permission for an app to access the Photo Library? I've found a few questions that seemed promising, but nothing that actually addresses this issue...
Related
I am currently working on an app that is going to use the users iCloud information, namely first name, last name and e-mail address as a way to automatically sign-up for the app, instead of filling out a huge form.
Currently the only way I see to get to this information, is to ask the user for permission using the only CloudKit permission type available (userDiscoverability).
CKContainer.default().requestApplicationPermission(CKApplicationPermissions.userDiscoverability, completionHandler: { (status, error) in
....
})
The problem with this is, is that the definition of userDiscoverability is:
The current user is discoverable (through the user's email address) to
other users of the app
Which leads to the default dialog shown here:
The problem is, is that I want access so that i can use the information above to sign someone in automatically (and use it for when someone changes devices, loses their device, etc) so that they don't have to sign up again. Therefore the dialog shown here isn't relevant to what I need it for and the users of the app are going to be confused as to why other users of the app will see that they are using the app(and in fact there is no functionality in the app to allow this at all anyhow).
Like other privacy entries available in Xcode, is there one available somewhere for CloudKit where I can add my own custom message so that I can customize the reason I need permission?
I know that others people have offered solutions, like providing your own custom dialog before the system asks or providing a Page View Controller to explain what's going on but I would like to avoid that. Apple really needs another permission type here but for the time being, thats all we have.
Suggestions/Comments/Feedback welcome.
When the app is first run it asks for permission to access the photos!
What's the reason for that?
One way is run the code one line by one line or Another way is revert code to previous version.
And find from which version, the app become to ask permission at first launch.
Previously, when we enter select photo screen, we would write code to ask the permission.
I also try to add symbolic breakpoints like:
-[UIAlertView initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]
And even find a class dump UIAlertView header in order to add symbolic breakpoint but not work. Add UIAlertController breakpoint also does not work.
The simulator OS is 8.3. And each time I must reset contents and setting to reproduce the issue.
Any hint or good idea will be appreciated!
Finally, I find out the following code cause the iOS system to pop up the "Allow our App to access their photo gallery" dialog. Thanks for Vijay's answer.
[[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self];
Starting with iOS 6, Apple now requires apps to get explicit user permission before accessing Contacts, Calendars, Reminders, and Photos. From the "Data Privacy" section in Apple's iOS 6 Release Notes:
In addition to location data, the system now asks the user’s permission before allowing third-party apps to access certain user data, including:
Contacts
Calendars
Reminders
Photo Library
For contact, calendar, and reminder data, your app needs to be prepared to be denied access to these items and to adjust its behavior accordingly. If the user has not yet been prompted to allow access, the returned structure is valid but contains no records. If the user has denied access, the app receives a NULL value or no data. If the user grants permission to the app, the system subsequently notifies the app that it needs to reload or revert the data.
I'm trying out this code: http://github.com/akpw/AssetLibraryPhotosViewer to access photos on my iPhone.
However when I run the application, I get an alert that says the application is trying to access my photos - and then I can allow this or decline.
Can I disable this when using the AssetLibrary, or does this message always appear?
If I can't turn this off, and I press "Don't Allow", can I still make the app access my photos?
Following on from answer above. This will appear once. If you allow access then it will not show again and you will have access to the photo's. If you disallow it then you will not be allowed to access this and the alert dialog will not appear again.
This permission can be changed at any time by the user in the settings app (Under Location and Privacy, or a variation of that.) This has been around since iOS 6 I believe.
You are never able to programtically state that access has been granted, the system handles the permissions which are shown to the user.
This is a security feature of the OS that cannot be disabled. If a user does not give your app permission to access the photo library your app will not be able to access any photos. Given this ability your app should be able to handle the situation gracefully from a UI/UX perspective.
For more information take a look at this guide from Apple about iOS security guidelines (page 47 takes about accessing personal data) iOS Security
In iOS8, using Photos.framework, when you modify a photo using -[PHPhotoLibrary performChanges:], you get the following user dialog:
There doesn't seem to be any way around this dialog, and iOS seems to ask every time you save, even to a previously modified (and permitted) photo.
Is there any way to ask for blanket permission to edit photos in iOS8? Other workarounds or help here?
Additional information:
I'm usually testing this in the simulator. Any known differences here?
In response to a (possibly now deleted) answer, this assert right before the -performChanges: passes:
NSAssert([PHPhotoLibrary authorizationStatus] ==
PHAuthorizationStatusAuthorized, nil)
I found this in the apple documentation
If your app edits the contents of assets already in the Photos library—including assets your app has itself recently added—Photos prompts the user for permission to change the asset’s content. If instead your app uses the initWithPlaceholderForCreatedAsset: method to create an asset with edited content, Photos recognizes your app’s ownership of the content and therefore does not need to prompt the user for permission to edit it.
I normally use the ALAssets library to access photos and display them, but I wanted to provide the user with an alternative in case they didn't feel comfortable giving access to location data. I installed the UIImagePicker, and while it still works fine on iOS5, I noticed on iOS6, when I shut off access to the photos in my app, I get "This app does have access to your photos or videos". Does the UIImagePickerController no long allow non disputed access to the photos?
It doesn't matter which route you take to access the photos, if the user has denied access then none of the options will be permitted to access the photos. The authorisation messages may be a little misleading but the same permissions apply to both access methods.