I have a requirement to display a different camera permissions message, one for when the user starts the QR scanner, and one for taking a photo.
The user can start with either one, and product don't want to use a generic message for both.
Is there a way to set NSCameraUsageDescription programmatically, or can this only be done within Info.plist?
Thanks
You can't edit the Info.plist of your app. You don't have write access to that file. In fact an app's bundle is read-only. You can't save changes to your bundle.
You should use a generic message mentioning both cases in the permission message. This way user knows that this permission will also be utilised in other places too.
As pointed out, .plist files cannot be edited at runtime. Anyways they can be localized. It's possible to create multiple Localizable.strings files containing different values for your NSCameraUsageDescription.
Right after, you could change the localization file your app is pointing to, obtaining the correct text that will be displayed in the alert.
Besides the general message, you may present your customized alert message before request authorization somewhere, even with cooling animations.
Related
Can I change the camera access permission info.plist message dynamically in Objective-C, because I need to show some dynamic values in message from API response.
Short answer: You can't.
But I met with custom info popups before system popups.
Other solution would be to have Info.plist localized in multiple languages and then before showing system popup just force localisation based on which text you want to display.(I didn't test this)
BTW why would you wanna do that?
I've assumed that putting NSBluetoothPeripheralUsageDescription into info.plist will automatically trigger the alert view (at appropriate time) which will among the other things, show the (localized) error defined in InfoPlist.strings(current language). I assumed something like that, because of this statement from the docs:
NSBluetoothPeripheralUsageDescription (String - iOS) This key lets
you describe the reason your app uses Bluetooth. When the system
prompts the user to allow usage, the value that you provide for this
key is displayed as part of the alert.
Take a look at into this part:
When the system prompts the user to allow usage ...
IMO, this means that alert will be popped out automatically, rather than manually in the code by me.
I am using :
CoreBluetooth framework and many of its classes like:
CBPeripheral, CBCharacteristic, CBCentralManager etc. so I guess this alert should pop out. Of course, I can pop out the alert view by myself on the first use of Bluetooth, but I thought that point of these info.plist keys is, actually to warn the user automatically...
Not quite...
I would hate to have iOS automatically pop up every permission request dialog when the app first runs. Much better to allow me to show "Can I use the camera?" the first time the user gets to the section of my app where the camera is used, and "Can I use Bluetooth" when that section is used.
So, the strings are required so the users are not presented with generic "App wants to use Bluetooth" requests. Instead, you have to provide a suitably informative string (subject to the reviewer's opinion, of course).
But it won't be presented to the user until you want it to be shown.
Maybe you already answered the system popup and have an entry in the iOS settings? In this case iOS will not ask anymore.
I am new to iOS. Is it possible to show a custom view or dialog in place of the default iOS location permission dialog?
No, this dialog is presented by the operating system and you cannot modify it. It is an important part of privacy management that the dialog is presented in a consistent way for all apps and that apps cannot modify the permission process.
You can display a custom view or alert prior to requesting permissions that explains what is happening and the need to click "allow" on the alert that is about to be presented
Direct Answer is it's not possible
explanation :
Only option is set description string by using Cocoa Keys(The keys associated with the Cocoa touch environments)
Add one of these key to
NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Info.plist and set it's value to whatever which describe the purpose of getting location
ex:
MyApp picks you up from where you are. To book airport rides, choose “Allow” so the app can find your location.
Important: To protect user privacy, an iOS app linked on or after iOS 10.0, and which accesses the user’s location information, must statically declare the intent to do so. Include the NSLocationAlwaysUsageDescription key in your app’s Info.plist file and provide a purpose string for this key. If your app attempts to access the user’s location information without a corresponding purpose string, your app exits.
If you looking for localization for that message
Link
In iOS 8 you're allowed to easily delete assets from Camera Roll.
I already use this function in my App but I wan't to change the text of the alert, which is visible.
Image:
http://i.stack.imgur.com/uhSAv.png
Now I want to change the title of the alert.
Did everybody know, what I have to do that i can change the title of the alert?
I use Objective-C in Xcode.
There isn't a (sanctioned) way to modify the content of messages of this type where the iOS framework is cautioning the user about access to shared data. This is for security reasons: imagine if someone changed the meaning entirely. The user would answer a different question and the app could delete photos without the user knowing until it is too late.
I know that in iOS 6 we should request the access to contacts first like below :
But now, I wonder how to add detail message in the alert view, just between the alert-title and two buttons. I did see some-app had done that.
I use ABAddressBookCreateWithOptions and ABAddressBookRequestAccessWithCompletion, but the previous one's option is reserved as NULL while the later one only accepts a callback block.
I searched a lot, like another Q, iOS 6 Release Notes and Apple Doc, but failed to make it.
Thanks a lot for any help. :)
You can use NSContactsUsageDescription key for this purpose.
Add this key to your info.plist and add the Message you want to display as the value.
NSContactsUsageDescription
NSContactsUsageDescription (String - iOS) describes the reason that
the app accesses the user’s contacts. When the system prompts the user
to allow access, this string is displayed as part of the dialog box.
This key is supported in iOS 6.0 and later.
Please check InfoPlistKeyReference for more keys.