Granting permission for the calendar without showing ios builtIn alertView - ios

I am using this method to ask user for the calendar permission requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) but what i want is that when user clicks on Button named as GrantPermission, then the permission should be granted without showing the alertView which is of IOS builtin, is there any way to do this?
I want to do this because when user clicks on Dont Allow then i show a alertView which says that user have to manually turn on permission from settings and when user manually turns on this permission then the app crashes.

There is no way to grant permission without displaying the native alert view, as it provides an added level of security (without it developers would just be programatically granting permission to everything).
If you want to mitigate against getting into the situation where the user needs to manually grant permission from the Settings app you could display a "pre-permission" alert where you offer the user some information as to why they might want to allow it, followed by actually asking the system for permission which will in turn display the built in alert.
FWIW This isn't my idea, nor is it that new. This TechCrunch article goes into a lot more detail about the UX of asking for permissions on iOS.
Note that you could still end up in the situation where the user needs to manually grant permission - if they "accept" your alert but deny the actual system alert. In this case you will need to figure out why your app is crashing, maybe post another question regarding that.

Related

iOS Location Services Alert - What is the delay between showing it?

Just a quick question here.
I am displaying the the alert for the user to allow the app to access location data, and I have this triggered from a switch.
When the user turns the switch on, the alert will be displayed.
If the user clicks disallow, is there a time restriction that Apple has before you can show that alert again?
Thanks in advance!
Once the user chooses not to give your app permission to access their location data, the user will not be able to grant your app that permission from within your app. Instead, the user must enter the Settings app and grant the permission from there. This is to prevent the app from bombarding the user with requests to use location data.

Access photos with AssetLibraryPhotosViewer

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

Custom Ui for iOS permission

I need to create a custom ui for mic permission, is there a way to do it.
below is code code how permission block works.. it seems difficult with this call? App Shazam is doing it.
[[AVAudioSession sharedInstance] requestRecordPermission:^(BOOL granted){
if (granted) {
NSLog(#"granted");
} else {
NSLog(#"denied");
}}];
I am not aware of any way that you can circumvent the UIAlertViews presented by Apple that ask the user for permissions. What you can do however is this:
Present a view explaining in greater detail why you need the specific permission. With two buttons as Shazam does. And tell the user the user that tapping OK will present an alert to confirm.
If user taps ok, trigger some action (e.g. location) that requires the user's permission or use the system provided way of asking for permission (e.g. mic).
If the user taps "don't allow" you can still in the future present the interface again. With more explanation.
This approach is better than to always use the system's permission dialogue right away, as this can usually only be denied once from within the app. Using a custom view before the alert view allows you to ask more often.
We have also published a framework to help you with that: https://github.com/iosphere/ISHPermissionKit
For iOS >= 7.0
in you app.plist add this key: NSMicrophoneUsageDescription and your desired customized prompt. More details here: https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1

How to rerequest permission once denied by user

Users can post messages on Facebook using my application. iOS presents the users with the permission dialogue the first time they try to post ("foo app would like to post privately on your behalf" - Don't Allow / OK). Now it seems that this decision is a persisting one. Once this dialogue is completed either way, the user will never be asked again.
Now, as this might have happened out of mistake I don't think this is good enough for the user. Is there a way to initiate this permission dialogue from code somehow?
No. You can create your own dialog telling the user that they must go to the Settings app to change the privacy settings.

iOS photo permissions to ask for second time

I am currently using alasset which asks for permission for first time. If want to pop permission second time or every time when user has blocked it, how it is possible.
there is no way to show the permission prompt the second time.
The best way to handle the permission prompt is that you should explain to the user before triggering the permission prompt (read: call method in the AssetsLibrary framework). If the user still click on "Don't Allow", then you should tell the user how can he/she grant the permission via the Settings app as you cannot invoke the prompt for the second time.
That dialog isn't controlled by the app, so no API for that.
You can reset things as a user in the settings app (IIRC) but no programmatic way.
To get the current authorization status:
[ALAssetsLibrary authorizationStatus];
(+ (ALAuthorizationStatus)authorizationStatus)
Also, methods to get assets taking access error blocks, e.g.:
- (void)assetForURL:(NSURL *)assetURL
resultBlock:(ALAssetsLibraryAssetForURLResultBlock)resultBlock
failureBlock:(ALAssetsLibraryAccessFailureBlock)failureBlock

Resources