Location Access Request in iOS 11 - swift

I am requesting the user location in my app.
locationManager.requestAlwaysAuthorization()
This line of code should return this alert message:
However, I want the user to choose between "Don't Allow" and "Always Allow" only. how can I delete the "Only While Using The App" option?
Knowing that this is what I included in the info.plist, and deleting any row from these 3 rows in the info.plist is causing the app not to show this alert at all.

It is not optional anymore.
Since iOS 11 has been released, if your application requests the location to be always on (locationManager.requestAlwaysAuthorization()), the users will automatically be given all three options.
Unlike in previous iOS versions, all options have to be displayed to the user. That leads to: you have to add a key for both options.
Adapted from Apple's Article - Requesting Always Authorization:
You are required to include the NSLocationWhenInUseUsageDescription
and NSLocationAlwaysAndWhenInUseUsageDescription keys in your app's
Info.plist file. (If your app supports iOS 10 and earlier, the
NSLocationAlwaysUsageDescription key is also required.) If those keys
are not present, authorization requests fail immediately.
Reference: What's New in Location Technologies Video Session.

According to WWDC 2017 Session 713 about updates in Location technologies, you should always include When In Use description when linking against iOS 11 and later, if you want to request Always authorization. And iOS will additionally display an option to use location for When-In-Use mode.
Quote from session transcript.
So for iOS 11 we're asking all developers with Always requesting apps to additionally support the WhenInUse authorization mode. This change is both retroactive and forward-looking, so when the user updates to iOS 11, they will be able to authorize any app that requests Always authorization the WhenInUse authorization mode instead. If you link against the iOS 11 SDK, you must provide a WhenInUseUsageDescription. Otherwise, your app will be unable to request Always authorization. Furthermore, when your app requests Always authorization, we will additionally display an option to grant your app WhenInUse authorization instead. With these new three option prompts we have a new UsageDescription string as well. Your app needs to provide an AlwaysAndWhenInUse UsageDescription. Since this is a different key your app must provide it when you link against the new iOS 11 SDK. For apps linked against iOS 11 and later, Core Location will not use the old NSLocationAlways UsageDescription key.

When are not set you will catch a message in the debug console like:
The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data
Open Info.plist as Source Code
And add the following xml chunk:
<key>NSLocationAlwaysUsageDescription</key>
<string>Location always usage description</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Location always and when in usage description</string>
<key>NSLocationUsageDescription</key>
<string>Location usage desription</string>

Related

Keychain Access for API requests triggers alert

I store the token received from an API sign in process in the user's keychain. Then for all further requests to the API I get the token from the keychain to send to the API. This happens with each request made to the API. As I have understood the keychain is the right place to store sensitive information, so I'm not storing the token in the user defaults.
On iOS everything works as expected, but on macOS, there's an alert appearing that the App wants access to the keychain. The user can then select to allow it once or to allow it always. This has two major issues:
if the user chooses "once" the dialog will appear over and over again with each request the App does.
if the user chooses "always" the dialog will not appear for some time, but after a while it will reappear nevertheless.
Why is this behavior totally different between iOS and macOS? Or did I forgot to configure something?
From a security point of view, would it be okay to read the token once at the start of the app and store it in a property?
Although the Keychain on iOS and macOS share lots of similarities, there is one big difference between the two. iOS only has a single Keychain, whereas macOS can create any amount of Keychains. You can find more info on that here.
This means that we will have to tell the macOS Keychain to behave like the iOS Keychain, which we can via the kSecUseDataProtectionKeychain key, documented here. Setting this flag to true should solve your issue.

Allow access to iPhone contact for my app in iOS 5.0

In my application I am accessing phone contact of iPhone so it will ask first time to allow access,but if user will click on "Don't allow" than application will not be able to access phone contact.
I know that in iOS 6.0 there is a option of privacy in setting where I can give permission to access phone contact to my application.
But I couldn't find this kind of tab or setting in iOS 5 or lower,Please inform me where can I give permission to my application to access phone contacts.
-Thanks in advance
In fact, this permission level is introduced in ios6. This one you can't find iOS5. And in iOS6 if user gave Don't Allow at first time, you can change that settings from the Settings App in the iOS.
Privacy Settings
To find your privacy settings, just tap the Settings app to launch it and then scroll down to Privacy. Tap it.
On the privacy screen, you'll see the elements of your iPhone that contain personal information that apps can gain access to.
(like Location Services,Contacts,Calendars and Reminders,Photos). From here you can change the access level.
Hope this helps.

Open an app when clicking on a url iOS

I'm wondering if there is a way to open an app when clicking on a link in safari (or other browser) in iOS.
My app posts the name of a location, a screenshot on Twitter/Facebook which also has a link. I need to detect when the user clicks that link if he is on a pc or iOS device. If they're not on iOS device I want to continue to the linked page otherwise I want to open the app and also take take that location name as a parameter when opening it.
If the app has registered a custom URL scheme the device will open the particular app when it's asked to open a URL of a particular scheme.
This stems from the CFBundleURLSchemes key of your apps infoPlist. Apple's documentation has all the information you need to get started.
To register a URL type for your app, include the CFBundleURLTypes key
in your app’s Info.plist file. The CFBundleURLTypes key contains an
array of dictionaries, each of which defines a URL scheme the app
supports. Table 6-2 describes the keys and values to include in each
dictionary.
See more here at the iOS Programming Guide: Advanced App Tricks under 'Communicating with Other Apps' section.
Edit
In order to support the specific functionality of your question you need to go one step deeper.
Your first link needs to be a standard web URL.
The page presented from the first URL needs to detect the device and forward the user onto a second URL that will open the app on the device, with whatever parameters you want to forward to the app.
So - what you're going to have to do is build some sort of device detection into the page that your first URL points to. On that page, detect the device, then conditionally forward the user onto the second URL that will be the custom URL of your particular app.
It's possible to do this device detection, and detect if they have the app installed on their device with some of the newer HTML5 features supported by mobile browsers, but your question is themed around opening apps with URLs in iOS and the main native iOS hooks you need to support opening apps (with parameters and all) is in the documentation above.

How does iPhone app remember me feature works?

I developed an iPhone app. User need to log in to update their credentials. I'm using iOS Keychain feature to store the username and password. So, next time user launch the app user will be logged in. I would like to add remember me feature in my app. So, user will have an option to check the remember me or not.
My question is if the user don't want to remember his credentials, when I'm suppose to clear the keychain? How do I know if the app is closing/shutdown?
– applicationWillResignActive:
– applicationDidEnterBackground:
These two methods are called depending on the situation when the app enters background.(sleep button/phone call etc).
You can look it up in the docs.
https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UIApplicationDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/UIApplicationDelegate
You meed to write the login credentials to application preferences.
(Here is how to read write to iPhone app preference)
http://knol.google.com/k/iphone-sdk-application-preferences#
Also here is how to read default preferences
http://www.redcodelabs.com/2009/07/read-iphone-preferences/

Modify iPhone app store details

Once the iPhone app is in Ready for Sale status, then I want to change some details like support URL or keywords, would it change the status to In Review and again I will have to wait?
You can only change the keywords when you change the binary! We learned this the hard way after our first release.
Support URL and App Description can be changed at any time.
Changing support URL or the app description will NOT change the status of the app. In fact, nothing will unless you explicitely remove the current version from the App Store or upload a new binary (and in that case the current version will remain on sale for the time being).
You can always edit the following information:
Copyright
Description
EULA
Localization deletion
Marketing URL
Rights & Pricing
Contact Email Address
Support URL
Privacy Policy URL
Release Notes
You can only edit the following information if your app is in an editable state:
Categories
Keywords
Large Icon
Localization addition
App Name
Ratings
Review Notes
Screenshots
Version Number
Version Release Control
Editable states are:
Prepare For Upload
Waiting For Upload
Waiting For Review
Waiting For Export Compliance
Upload Received
Rejected
Metadata Rejected
Developer Rejected
Invalid Binary
Missing Screenshot (iOS only)
To make changes to your app's Rights and Pricing, In-App Purchases, Game Center, iAd Network settings, and Newsstand go to the app's App Summary page on the Manage Your Applications module. You can edit additional items on the app's Version Details page. Submitted changes should be visible on the App Store within 24 hours.