I'm going to reach the contact functions using the phonegap assembly, I added the API of the required function by calling the contact box after the device is ready in index.html. but it comes as creating undefined. Please tell me where I went missing ?. really appreciate. For further reference, I gave the code for the config.xml and index.html files.
Config.xml
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.AbsenceManagement" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Add Contact</name>
<description>
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
</author>
<feature name="http://api.phonegap.com/1.0/battery"/>
<feature name="http://api.phonegap.com/1.0/contacts"/>
<feature name="http://api.phonegap.com/1.0/file"/>
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<feature name="Contacts">
<param name="android-package" value="org.apache.cordova.contacts.ContactManager" />
</feature>
<feature name="Contacts">
<param name="ios-package" value="CDVContacts" />
</feature>
<access origin="*" browserOnly="false" />
<access origin=".*"/>
<preference name="disallowOverscroll" value="true" />
<preference name="webviewbounce" value="false" />
<preference name="fullscreen" value="false" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="white" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="orientation" value="portrait" />
<preference name="phonegap-version" value="3.0.0" />
<gap:splash gap:platform="android" />
<gap:splash gap:density="ldpi" gap:platform="android" src="resources/icons/drawable-ldpi/splash_screen.png" />
<gap:splash gap:density="mdpi" gap:platform="android" src="resources/icons/drawable-mdpi/splash_screen.png" />
<gap:splash gap:density="hdpi" gap:platform="android" src="resources/icons/drawable-hdpi/splash_screen.png" />
<gap:splash gap:density="xhdpi" gap:platform="android" src="resources/icons/drawable-xhdpi/splash_screen.png" />
<icon src="resources/icons/Icon-Small@2x.png" gap:platform="ios" width="57" height="57" />
<icon src="resources/icons/hdpi/72x72.png" gap:platform="android" gap:density="hdpi" />
<icon src="resources/icons/ldpi/36x36.png" gap:platform="android" gap:density="ldpi" />
<icon src="resources/icons/mdpi/48x48.png" gap:platform="android" gap:density="mdpi" />
<icon src="resources/icons/xhdpi/96x96.png" gap:platform="android" gap:density="xhdpi" />
<icon src="resources/icons/xxhdpi/144x144.png" gap:platform="android" gap:density="xxhdpi" />
</widget>
Index.html ------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<title>Add Contact</title>
<script type="text/javascript" src="cordova.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function start(){
alert('start');
}
function onDeviceReady() {
console.log('onDeviceReady');
alert('onDeviceReady');
try{
var myContact = navigator.contacts.create({"displayName": "Test User"});
myContact.note = "This contact has a note.";
console.log("The contact, " + myContact.displayName + ", note: " + myContact.note);
alert('ContactCreated');
}
catch(e){
alert(e.message);
}
pictureSource=navigator.camera.PictureSourceType;
destinationType=navigator.camera.DestinationType;
alert('onDeviceReady After');
}
</script>
</head>
<body onload="start();init();">
<div id="outerContainer" style="position: relative;overflow-x: hidden;" >
<div id="homePage" class="screen-container" style="position: relative;min-height: 100%;" ></div>
</div>
</body>
</html>
source
share