Discussions
Categories
- 196.7K All Categories
- 2.2K Data
- 235 Big Data Appliance
- 1.9K Data Science
- 449.8K Databases
- 221.5K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 549 MySQL Community Space
- 477 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 532 SQLcl
- 4K SQL Developer Data Modeler
- 186.8K SQL & PL/SQL
- 21.3K SQL Developer
- 295.4K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.1K Development Tools
- 104 DevOps
- 3.1K QA/Testing
- 645.9K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 153 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 17 Java Essentials
- 158 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 203 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 394 LiveLabs
- 37 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.6K Other Languages
- 2.3K Chinese
- 170 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 230 Portuguese
ADF Mobile: creating contact on device only after user selects ALLOW button

My app allows users to quickly and easily add contacts on their IOS phone. I need help capturing the "DON'T ALLOW" button click.
Background:
When adding a contact on the users device phoneGap prompts the user "Allow theApp to Access Contacts?". After this alert is shown the user must select either "Allow" or "Don't Allow". Of course if the user selects "Allow" my code runs perfectly.
However, if the user selects "Don't Allow" I am not able to capture that selection and process accordingly.
Here's the line of code that processes the newContact for that app user.
Contact newContact = device.createContact(contact);
where "contact" has been preset with user data;
Would you offer your expert opinion on how to proceed please?
Many Thanks!
Tree Strepek
Best Answer
-
The permissions for iOS are set in config.xml.
<plugin name="Contacts" value="CDVContacts" />
https://github.com/apache/cordova-plugin-contacts/blob/master/src/ios/CDVContacts.h
Answers
-
If one of the two has to be selected, use the ! (complement) of the value returned with Allow to process for Don't Allow.
For example, if Allow returns a value boolean true, if the value is not true implies Don't Allow has been selected.
if (allow!=true)
Implies Don't Allow is selected.
-
Thank you for that insight Mystery Man "dvohra21". LOL.
I have a detailed implementation question=> what is the syntax to capture the value(whether allow or !allow) I am trying to find how to capture the user's selection. Phonegap takes control for a brief second. It is outside the control of my app for a moment. In this period of time the User is prompted if they agree to "allow access".
How do I access the result returned by phonegap? Is the Contact newContact = device.createContact(contact); call automatically populating a callback method? Or setting a variable somewhere I can access. If so can you offer some direction on where to look for the details?
Contact newContact = device.createContact(contact); <- the command that calls Phonegap to interact with the device's OS.
Thank You for all your help!
Tree Strepek
-
Refer
Oracle ADF Mobile Decoded: ADF Mobile: Capture User Response to Alert Popup
which makes use of AdfmfContainerUtilities.invokeContainerJavaScriptFunction to capture user response.
-
Hey dvohra21:
I love it that you're referencing my blog entry on this subject. I created that blog as I was trying to decode how to use JavaScript call back methods in AdfmfContainerUtilities. A technique I tried and dismissed as a solution. (I am still working to clarify the syntax on Javascript call back methods).
But my question here specifically refers to capturing the result of the Phonegap UI alert "Allow App to Access Contacts?". 2 buttons are displayed. "Allow", "Don't Allow". If the user always selects "Allow" my code works as designed. However, I am coding for the other scenario=> the user selects "Don't Allow".
My Essential Question: How do I access the users selection to the Phonegap alert? This seems to happen outside ADF Mobile's control(as a blocking call to Phonegap)
Is there a return value I can access? Is it like the Javascript scenario(in AdfmfContainerUtilities), in which, there is a callBack method I can query for the results?
It seems if the user selects "Don't Allow" the contact should not get added to their device's contact list. && I need to reset the phone gap parameter, so that same user gets prompted next time they want to add a contact. (right now the user's selection is final)
I appreciate you sharing your knowledge with me!
Tree Strepek
-
Is there a return value I can access? Is it like the Javascript scenario(in AdfmfContainerUtilities), in which, there is a callBack method I can query for the results?
All notifications provide a callback function.
notification.confirm
confirmCallback: Callback to invoke with index of button pressed (1, 2, or 3) or when the dialog is dismissed without a button press (0).
notification.alert
alertCallback: Callback to invoke when alert dialog is dismissed. (Function)
notification.prompt
promptCallback: Callback to invoke when a button is pressed. (Function)
http://docs.phonegap.com/en/3.0.0/cordova_notification_notification.md.html
-
I believe the correct issue is here that if the user disallows access to contacts then how do we detect that? The prompt in question regarding access to Contacts is displayed by iOS and it's response cannot be captured similar to an alert response.
IS there a call or way we can hook into PhoneGap to discover if the user has disallowed access to contacts before performing contact related operations? This way we can diplay a message asking user to first enale access to contacts rather than attempt the operation and fail.
-
The permissions for iOS are set in config.xml.
<plugin name="Contacts" value="CDVContacts" />
https://github.com/apache/cordova-plugin-contacts/blob/master/src/ios/CDVContacts.h
-
That's right. Thank you for that clarification.
-
Phonegap interaction (including user response) has been brought into MAF.