my question is quite simply, how can I popup the following view in my app?
I've seen this in quite a lot of apps, so I believe this is a system-level view controller? But what is it? How can I show it in my app?
As far as I know, that is NOT a system provided view. You'll have to detect a denial of permission by the user, and then create a view to display. Many people copy Apple's style for this view in order to make their apps 'blend in' with the platform, but its not directly provided to third party developers.
You do not have to pop this by yourself. Whenever you implement functionality that needs privacy settings, the OS asks the user if he would like to let your app to use this functionality (for example contacts or camera) automatically. If he denies to give access, then he will be presented with a view like this one whenever he tries to use that functionality again (unless of course if he has changed the settings manually in privacy settings).
Related
I've been googling on how to gracefully handle when user refuse to enable push notification service and location service that my app requires. I found out that Apple's human interface guideline prohibits developers from exiting app programatically and it should be left with users. But I don't want user to use my app without those services enabled since they are neccessary. How do accomplish that without violating any guidelines Apple laid out?
Well, I would just display a static view that explains why those services are required and how the user can enable them - best by offering a button that will redirect to the settings (Swift 3 code):
// in Button handler code:
if let appSettings = URL(string: UIApplicationOpenSettingsURLString) {
UIApplication.shared.openURL(appSettings)
}
A lot of apps implement a "pre-request" dialog, if the user accepts the request on the pre-request then display the actual permission request dialog as they're more likely to accept. If they decline your pre-request dialog, tell them again why you need the permissions or certain features won't function and try again. I haven't heard of Apple having any issues with this approach.
If they've already declined the permission request then you will need to alert them the required permissions haven't been granted and which features are now disabled, offer a dialog button to direct them to settings and display how to enable the permissions.
To open settings from your app use the below code
Swift 3
UIApplication.shared.openURL(URL(string:UIApplicationOpenSettingsURLString)!)
Swift 2.x
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
Objective-C
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]]
Update
Just realised you want to limit functionality of your app should user not have required services enabled. The best way is simply to push a view controller that displays an image and/or label stating that certain features aren't enabled and therefore the app can't function. You could detail the steps to enable required services with a button directing them to settings as per above. Again, I haven't seen Apple take issue with this as many apps implement this method should they lack for example GPS.
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
Is is possible to dynamically figure out the position of an app's icon on the home screen of an iphone/ipad?
Sorry I don't have enough credit to comment yet so I'm posting here.
To my knowledge no you cannot natively or easily do this. I know of no open source or other libraries. The reason being that your app exists in its own world, it is not in touch per say with the rest of the device. It can get permissions to read and write data but it doesn't know of itself.
Does that make sense?
When you open a website it cannot know which tab it is in the browser. Instead it knows how it was accessed and what device (physically) is using it. It knows the user-agent, the time, the browser, etc because that is information sent to it in the request. In turn the phone on launch gives data to the app in how to handle it but not for example how many other apps are running, or where it is on the screen. It's not normally considered relevant to run time. In addition it's a security feature in preventing an app from deleting or altering other apps, as well as itself. If you have an iPhone you will notice that SIRI cannot turn off google maps navigation or any other non-apple specific app. Only apps natively comparable and private party ones (ex apples) are accessible because Apple did that intentionally. They all know of their own existence and each others. However non-native in the sense of apps that do not come preinstalled and manufactured by the company creating the device are less trustworthy, in addition there are no guarantees about how they will be run by the device, where they will be, or what other apps will be there.
It is true that an app can request for another app it may be comparable with but it is up the user to handle that information.
May I ask for curiosities sake why you are trying to do this? Are there any other workarounds?
However in terms of it being physically possible, yes. I doubt that apple allows independent developers to do this however. But an example of this occurring may be gridlock where a user can move their apps around differently on the screen. The app in this case has the ability to access app position. But I believe in this case app position is about the UI and not about nested files. apps cannot to my knowledge modify information outside of their own file. Imagine if you had an app that could edit other games scores.
It is not possible to dynamically find out the position of an app's icon on the Home Screen (even for jailbreak apps). Apple wants you to respect the user's privacy settings.
Extra Info - There is popular JavaScript library that adds a promo bubble to the bottom of your mobile web application, inviting users to bookmark the app to their device's home screen.
I need your help with UIActivityViewController.
I need to present activity controller for the file where, except for default actions, the user will be able to open the file in other apps.
I know how to do this with UIDocumentController, which shows popover with all apps able to open the file.
But how can I show all these apps in UIActivityViewController?
P.S. This behavior can be seen in Apple Mail app, for example.
Look at TTOpenInAppActivity for a way to combine both a UIActivityViewController (for normal sharing), and an 'Open in' button on that which brings up a UIDocumentInteractionController. Pre-iOS 8, that is the best way to manage this.
The function and behavior is different between UIActivityViewController and UIDocumentController.
UIActivityViewController
Presents activities that are pre-defined, you can pass an array to select which ones should be excluded among the default ones that are presented, if you want to add more activities you have to use custom activities, unfortunately these will appear bellow the rest of the activities and even more, the icon will always be gray, your app never loses control since you can use delegates and other stuff to know what is going on on those apps. (Unless you manually make an activity which opens another app)
UIDocumentController
This one asks the system for all the registered applications for a certain file extension, many apps have registered their exclusive extensions which makes it so that this app will be the only one displayed. If you pass an image, you will see all the apps that can handle this file. When using this one your app will lose control since the other app will be opened.
What is your final objective?, If you describe it with more detail we could offer you a better solution.
From what i understand, you should see yourself what type of file the user is trying to open, and then yourself open it with the most suitable one.
Since you cant really emulate what apple is doing, you should handle this problem through your interface, offer the user to "share" or to "open with" for example.
The answer is very simple. There is no way to do it. You cannot add the apps except the defaults into the UIActivityViewControllers.
You are absolutley correct, you can acheive this through the UIDocumentInteractionController.
Is there a standard UIView/controller/dialog provided in iOS SDK for informing the user the app does not have access to X resource and this can be fixed from iOS privacy settings.
I have noticed a consistent view seen in many apps (snapshot below is taken from Viber). I could not find any API that would give me this dialog. I suppose I can just create one but still wanted to double check?
For the particular case I have I want to alert the user if app does not have access to user calendar/ reminders.
(I have a BOOL result in my code that tells me access granted true/false -I have to next alert the user with appropriate UI.)
The public API's UIImagePickerController displays that view if the app doesn't have access to the user's photo library. It's a _UIAccessDeniedView, which is a private class.
As far as I know, the public API doesn't provide an event picker controller, so there's no way to make the system display a similar “standard” view for calendars/reminders in your app.
If you want to set up a similar view yourself, you can extract the lock image using the iOS Artwork Extractor; it's named “UIAccessDeniedViewLock.png”. Warning: copyright infringement. Will Apple care? I have no idea.
This interface can appear for the calendar if you use EKEventEditViewController.