Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

contacts.js 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. *
  20. */
  21. var exec = require('cordova/exec');
  22. /**
  23. * Provides iOS enhanced contacts API.
  24. */
  25. module.exports = {
  26. newContactUI : function(successCallback) {
  27. /*
  28. * Create a contact using the iOS Contact Picker UI
  29. * NOT part of W3C spec so no official documentation
  30. *
  31. * returns: the id of the created contact as param to successCallback
  32. */
  33. exec(successCallback, null, "Contacts","newContact", []);
  34. },
  35. chooseContact : function(successCallback, options) {
  36. /*
  37. * Select a contact using the iOS Contact Picker UI
  38. * NOT part of W3C spec so no official documentation
  39. *
  40. * @param errorCB error callback
  41. * @param options object
  42. * allowsEditing: boolean AS STRING
  43. * "true" to allow editing the contact
  44. * "false" (default) display contact
  45. * fields: array of fields to return in contact object (see ContactOptions.fields)
  46. *
  47. * @returns
  48. * id of contact selected
  49. * ContactObject
  50. * if no fields provided contact contains just id information
  51. * if fields provided contact object contains information for the specified fields
  52. *
  53. */
  54. var win = function(result) {
  55. var fullContact = require('./contacts').create(result);
  56. successCallback(fullContact.id, fullContact);
  57. };
  58. exec(win, null, "Contacts","chooseContact", [options]);
  59. }
  60. };