I'm having troubles in order to let my NativeScript app read contacts on iOS. I'm using the library nativescript-contacts in order to read all the entries of the address book and the one called nativescript-permission in order to ask the user the permission to read contacts.
Unfortunately, the latter seems to work only in Android, where everything works fine: a pop-up appears asking the user to allow the reading of contacts and, if the permission is granted, the contacts are displayed in a list.
In iOS instead, I'm not able to ask for contact permission: no dialog box pops out and when I try to use a function of nativescript-contacts (e.g. getAllContacts()), the app freezes.
I've tried searching, but the only thing I can do seems to use some native code in order to get these permissions... but I have no idea how.
May you help me with this?
Thanks!
There are two things you might need:
1st, did you add in the Info.plist file a message for the key Privacy: Contacts usage description ? This will display the message you set to the user when prompted the permission alert.
2nd. You can ask for the permission by calling requestAccess(for:completionHandler:). Check this
Related
I am currently working on an app that is going to use the users iCloud information, namely first name, last name and e-mail address as a way to automatically sign-up for the app, instead of filling out a huge form.
Currently the only way I see to get to this information, is to ask the user for permission using the only CloudKit permission type available (userDiscoverability).
CKContainer.default().requestApplicationPermission(CKApplicationPermissions.userDiscoverability, completionHandler: { (status, error) in
....
})
The problem with this is, is that the definition of userDiscoverability is:
The current user is discoverable (through the user's email address) to
other users of the app
Which leads to the default dialog shown here:
The problem is, is that I want access so that i can use the information above to sign someone in automatically (and use it for when someone changes devices, loses their device, etc) so that they don't have to sign up again. Therefore the dialog shown here isn't relevant to what I need it for and the users of the app are going to be confused as to why other users of the app will see that they are using the app(and in fact there is no functionality in the app to allow this at all anyhow).
Like other privacy entries available in Xcode, is there one available somewhere for CloudKit where I can add my own custom message so that I can customize the reason I need permission?
I know that others people have offered solutions, like providing your own custom dialog before the system asks or providing a Page View Controller to explain what's going on but I would like to avoid that. Apple really needs another permission type here but for the time being, thats all we have.
Suggestions/Comments/Feedback welcome.
My react-native app needs to create a calendar event, it doesn't need to view, edit or delete event. I tried to use few react-native libraries which handle calendar but I needed to grant permissions for a calendar in each of them.
I have no knowledge of Objective C or Swift, but I would like to know if it is even possible in either native or react-native way.
Every advice is very appreciated. Thanks!
Short answer is no.
You do need to be granted permission to create a calendar event.
The Human Interface Guidelines section about requesting permissions
Users must grant permission for an app to access personal information, including the current location, calendar, contact information, reminders, and photos. Although people appreciate the convenience of using an app that has access to this information, they also expect to have control over their private data. For example, people like being able to automatically tag photos with their physical location or find nearby friends, but they also want the option to disable such features.
In the apple docs it specifies that you need to add an entry to the info.plist. This text is used when the permission is requested.
Important: If your iOS app links on or after iOS 10.0 and you need to access Calendar data, be sure to include the NSCalendarsUsageDescription key in your Info.plist file.
Your app will crash without this key added to the info.plist.
This is the case for native apps, so the same will apply for react-native.
When the app is first run it asks for permission to access the photos!
What's the reason for that?
One way is run the code one line by one line or Another way is revert code to previous version.
And find from which version, the app become to ask permission at first launch.
Previously, when we enter select photo screen, we would write code to ask the permission.
I also try to add symbolic breakpoints like:
-[UIAlertView initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:]
And even find a class dump UIAlertView header in order to add symbolic breakpoint but not work. Add UIAlertController breakpoint also does not work.
The simulator OS is 8.3. And each time I must reset contents and setting to reproduce the issue.
Any hint or good idea will be appreciated!
Finally, I find out the following code cause the iOS system to pop up the "Allow our App to access their photo gallery" dialog. Thanks for Vijay's answer.
[[PHPhotoLibrary sharedPhotoLibrary] registerChangeObserver:self];
Starting with iOS 6, Apple now requires apps to get explicit user permission before accessing Contacts, Calendars, Reminders, and Photos. From the "Data Privacy" section in Apple's iOS 6 Release Notes:
In addition to location data, the system now asks the user’s permission before allowing third-party apps to access certain user data, including:
Contacts
Calendars
Reminders
Photo Library
For contact, calendar, and reminder data, your app needs to be prepared to be denied access to these items and to adjust its behavior accordingly. If the user has not yet been prompted to allow access, the returned structure is valid but contains no records. If the user has denied access, the app receives a NULL value or no data. If the user grants permission to the app, the system subsequently notifies the app that it needs to reload or revert the data.
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 it possible to access the phone settings of an iOS Device programmatically? I'm currently building an app and there I will provide contact possibillities, for example a direct link for calling (you just push it and then the specific contact number is called).
But I only want to show that possibility, if the user isn't calling with an unknown number.
You can access the contacts stored in the phone using the Address Book framework. If you're unfamiliar with the framework, I suggest you take a look at this quick start tutorial.
EDIT It seems you wish to read the state of the Show My Caller ID system setting, however you cannot programmatically access the system settings.
Use ABAddressBook for getting contact details in your project...
see this