0

I can't this simplest use of AppMobi.contacts.chooseContact() example to work. It works in the XDK but then not on app-lab for iPhone 4s and I tried on my old Kindle Fire, where it crashes the app-lab app after picking a contact or two. It handled when you cancel the choosing of contact properly, but if you choose one the event listener appears to never be called.

I also ran it in a native app compiled for iPhone and same problem. Here's the code I used to minimally reproduce the problem, which I've run on the XDK on Windows, and the iPhone and Kindle Fire using Test Anywhere on app-lab and it exhibits the same problems described below. The code is included below. I know I'm probably doing something really dumb and just don't see it, but I cannot figure it out. Thank you.

<!DOCTYPE html><!--HTML5 doctype-->
<html>
<head>
<title>Your New Application</title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> 
<style type="text/css">
    /* Prevent copy paste for all elements except text fields */
    *  { -webkit-user-select:none; -webkit-tap-highlight-color:rgba(255, 255, 255, 0); }
    input, textarea  { -webkit-user-select:text; }

    /* Set up the page with a default background image */
    body {
        background-color:#fff;
        color:#000;
        font-family:Arial;
        font-size:48pt;
        margin:0px;padding:0px;
        background-image:url('images/background.jpg');
    }
</style>
<script type="text/javascript" charset="utf-8" src="_appMobi/appmobi_local_bootstrap.js"></script> 
<script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/xhr.js"></script> 
<script type="text/javascript">
/* This function runs once the page is loaded, but appMobi is not yet active */
var init = function(){

};
window.addEventListener("load",init,false);  

/* This code prevents users from dragging the page */
var preventDefaultScroll = function(event) {
    event.preventDefault();
    window.scroll(0,0);
    return false;
};
document.addEventListener('touchmove', preventDefaultScroll, false);

/* This code is used to run as soon as appMobi activates */
var onDeviceReady=function(){
    //Size the display to 768px by 1024px
    AppMobi.display.useViewport(768,1024);

    //hide splash screen
    AppMobi.device.hideSplashScreen();  


    document.addEventListener('appMobi.contacts.choose', onChooseContact);
    document.addEventListener('appMobi.contacts.busy', onChooseContactBusy);
    // runs right away more or less.
    AppMobi.contacts.chooseContact();

};
document.addEventListener("appMobi.device.ready",onDeviceReady,false);



function onChooseContact(evt)
{
    if (evt.success == true)
    {
        alert("Choose Contact Success");
        //AppMobi.contacts.editContact(evt.contactid);
    }
    else if (evt.cancelled == true)
    {
        alert("Choose Contact Cancelled");
    } else {
        alert("Huh, how did it get here?");
    }
}

function onChooseContactBusy()
{
    alert('got in OnChooseContactBusy');
}


</script>

</head>
<body>

    <a class="button"
        onclick="AppMobi.contacts.chooseContact();" >Click Here to Choose Contact</a>
    <br />


</body>
</html>
JustTrying
  • 764
  • 6
  • 11
  • FWIW here's the documentation link:http://www.appmobi.com/documentation/jsAPI/contacts/chooseContact/index.html – JustTrying Jan 28 '13 at 19:44
  • I've gotten your code to work great using appLab on an iPod Touch. Give me a chance to try it on the devices you found the problem on. – profMobi Jan 29 '13 at 18:26
  • On a Samsung Galaxy S, an appLab is crashing just as you described. I'm submitting a bug report to appMobi support. Thanks for the sample code! – profMobi Jan 29 '13 at 18:44
  • Thanks. Sorry I posted the same question on the appMobi forums this morning, I didn't realize there were comments. I pulled out an old iTouch myself just now with no contacts on it, and added one and it was able to select it. It's unning iOS 4.3.3 (8J2). I'm going to try all contacts functions on it, and if they all continue to work upgrade it to the latest iOS and see if it still all works. My iPhone is also getting contacts from the clould and facebook, so I'll have to figure out the combo of factors when it fails. May be based on the number of contacts too, who knows. – JustTrying Jan 30 '13 at 18:26
  • Fails on my iPad2, currently running iOS 6.0.1. Updating it to 6.1 that came out today. – JustTrying Jan 30 '13 at 18:30
  • Failed on iOS 6.1 on iPad2. – JustTrying Jan 30 '13 at 18:57
  • I've narrowed it down to one of my 350 contacts on my me.com account. Now to delete them one at a time and see which is exposing a defect. – JustTrying Jan 31 '13 at 02:01
  • It springs back to life once I pare it down to around 50-53 contacts, but I haven't been able to figure out if there's something about particular contacts that mess it up. If it starts working, then I add a bunch more simple contacts it doesn't stop working again, so it seems like it must be something about some individual contacts. – JustTrying Jan 31 '13 at 15:55
  • It has proven to be very time consuming to narrow it down, so I was going to write code to pseudo-randomly create contacts and grab them until it breaks to find the pattern, but alas I see I cannot add contact details with addContact but rather just invoke the iPhone native 'add contact' capability. Thus I guess I will give up and hope that the company will instrument the function to give some debug information on why the event isn't being fired. I suggest using someone's iOS device with hundreds of contacts. I think it is likely they too will experience this failure. Thanks. – JustTrying Jan 31 '13 at 18:29
  • Yes, I agree that adding contacts through code would help test this. That could easily be why it works smoothly for me since I only have 12 contacts. I'll give the iOS device another try to see if the same problem appears there. – profMobi Feb 01 '13 at 15:17
  • Thank you for looking into this. As you probably already know there is now a ticket with ticket ID #FR00001205 on the appMobi support site related to this. – JustTrying Feb 01 '13 at 16:40
  • They say they see the issue and have put it in their tracking system to fix it. I will post here when I find out it has been fixed. – JustTrying Feb 18 '13 at 20:13

0 Answers0