Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,425 members, 7,819,549 topics. Date: Monday, 06 May 2024 at 05:55 PM

Phonegap Issue - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Phonegap Issue (1577 Views)

Why Do HTML5 Mobile Apps Have A Bad Reputation (cordova / Phonegap)? / If You Known About Phonegap Please Enter / Phonegap!!!! (2) (3) (4)

(1) (Reply)

Phonegap Issue by adewaleafolabi(m): 10:10am On Jan 18, 2013
Okay,
I stumbled on PhoneGap plus Adobe Build Service some months ago and it seemed as if I discovered Gold(You know that feeling), no more waitinting to compile, i can just write once coupled with jQuery mobile and simply do a cloud build, no more SDK etc.

Its a simple app that's was just supposed to load contacts from a phone and do some manipulations to the number. Simple right

Everything was going on well till this sick issue came up. For some really really weird reason, the application works well on the Blackberry simulator but not on phones sinces i tested it on a couple of phones.

I initially thought it was the jquery mobile that was causing the problem, removed it an made a totally simple version still yet this evil repeats the same thing.I upgraded my version of phoneGap (Cordova), downloaded Blackberry Works and compiled myself added signkeys, phone asks for permission after install, grants it, still contacts don't load.


So has anyone had this experience or did something like this with phoneGap and works?


//Loading methods I used
//Meth I
var x = "";
document.addEventListener("deviceready", onDeviceReady, false);

// Cordova is ready
//
function onDeviceReady() {

var options = new ContactFindOptions();
options.filter = "";
options.multiple = true;
var filter = ["displayName", "name", "phoneNumbers"];
navigator.contacts.find(filter, onSuccess, onError, options);
}


// onSuccess: Get a snapshot of the current contacts
var generatedlist = '<ul id="phonebook" data-inset="true" data-role="listview" data-filter="true" data-filter-placeholder="Search people..." data-filter-theme="d" data-theme="c" data-dividertheme="d">';
var addBook1 ="TIMBOLO";
function onSuccess(contacts) {

var emptyLI = true;//


for (var i = 0; i < contacts.length; i++) {
emptyLI = false;
var tempno = "";


for (var j = 0; j < contacts[i].phoneNumbers.length; j++) {
if (contacts[i].phoneNumbers[j].value != undefined && contacts[i].phoneNumbers[j].value != ""wink {
tempno = contacts[i].phoneNumbers[j].value;
break;
}

}
generatedlist += "<li><input type='checkbox' class='phonenos custom' id='phonenos" + i + "' data-mini='true' value='" + tempno + "'/><label for='phonenos" + i + "' >" + contacts[i].name.formatted + "</label></li>";
//alert(addBook1 += "Name:" + contacts[i].name.formatted + " | " +tempno);

}
if (emptyLI) {
generatedlist += "<li>No Phone Contacts</li>";
}
generatedlist += '</ul>';

}

// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}


//Meth II

function findContacts() {
var filterText = "";
navigator.contacts.find(
['name', 'emails', 'addresses', 'organizations'],
function(contacts) {
var msg = 'Found ' + contacts.length + ' contacts.';
navigator.notification.alert(msg, null, 'Success');
},
function(error){alert(error)},
{
multiple: true, filter: filterText
}
);
}


NB: It doesn't even alert if theres an error, also i tried this in the ripple emulator and it loads the contacts. What am i doing wrong here?

(1) (Reply)

10 Programming Languages You Should Learn In 2014 / Learning To Code In Naijarea / m

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 14
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.