iOS app not show in Settings app after install
Asked Answered
I

3

6

I have an iOS app, which requests location permissions. If the user accepts, everything works fine (of course). But if the user doesn't accept and then manually triggers a localisation, he get the dialog provided by Apple to change the settings for the app in the Settings-App.

But if the user clicks on Settings, it just opens the Settings-App without jumping to the settings of my App. The app is also not listed in the Settings-App mainscreen, but can be found under Privacy -> Location Services.

But once you accept the location (or any other) permissions, the app appears in the Settings and the links work fine.

NSLocationAlwaysAndWhenInUseUsageDescription is included in the pList.

Any ideas on how to guarantee the to appear in the Settings-App mainscreen?

Iconoduly answered 21/8, 2020 at 9:2 Comment(3)
I got the same issue when I ran the app on a device that doesn't have a SIM card. I show up local network permission alert on app startup and if it is denied by the user the first time there is no way the user can change that in the settings as the app is not available there. Even the app is shown in Privacy & Security -> Local Network but not in the settings list. I tried cleaning the build folder, restarting the device etc.Reuven
do you call request authorization: locationManager.requestAlwaysAuthorization(), maybe this link helps you: hackingwithswift.com/read/22/2/…Predominance
and also you should add in your list -> "Privacy - Location Always Usage Description" key too together with "NSLocationAlwaysAndWhenInUseUsageDescription"Predominance
S
6

You need to add a Settings.bundle: Xcode > File > New > File > iOS > Settings Bundle. This way your app is always going to show up in Settings.app.

Bonus:

Q: What to use Settings.bundle for?

A: Show app version.

  1. Select "Settings.bundle" folder in Xcode, then inside select Root.plist.
  2. Select "PreferenceSpecifiers" and press (+) button, select "Title"
  3. Configure "Item 0 (Title -)":
  4. Set "Version" value to "Version".
  5. Set "Key" value to version.
  6. Add "DefaultValue" key and set value to "1.0".

It should look like this: Root.plist

Then, add a script to auto update version:

  1. Select Project in Xcode.

  2. In Targets select your app target.

  3. Select Build Phases tab.

  4. Press (+) > New Run Phase Script.

  5. Configure Script:

  6. Name Script "Settings.bundle"

  7. Unclick "Run Script: Base on dependency analysis.

  8. Paste script into form under "Shell /bin/sh":

     if [[ $TARGET_BUILD_DIR != *"maccatalyst"* ]]; then
    
     plistBuddy=/usr/libexec/PlistBuddy
     infoPlistPath="${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"
    
     settingsBundlePath="${TARGET_BUILD_DIR}/${CONTENTS_FOLDER_PATH}/Settings.bundle/Root.plist"
    
     versionNumber=$($plistBuddy -c "Print :CFBundleShortVersionString" "$infoPlistPath")
     $plistBuddy -c "Set PreferenceSpecifiers:0:DefaultValue $versionNumber" "$settingsBundlePath"
    
     fi
    
Sox answered 5/9, 2023 at 17:57 Comment(0)
B
0

try to use this, check this post How to open Location services screen from setting screen?

if let bundleId = Bundle.main.bundleIdentifier,
    let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)") 
{
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
}

or

set URL Schemes in Info.plist's URL Type Like:

UIApplication.sharedApplication().openURL(NSURL(string: "prefs:root=LOCATION_SERVICES")!)
Bonus answered 5/9, 2023 at 10:34 Comment(0)
M
-1

try to check current location permission and if it's declined show custom alert with this button action

  guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return }
                if UIApplication.shared.canOpenURL(settingsUrl) {
                    UIApplication.shared.open(settingsUrl)
                }
Mcloughlin answered 21/8, 2020 at 9:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.