2

I am working on a project in appMobi, and this project has recently reached it portion that is related to facebook. However there just seems to be soo many moving parts that its virtually impossible to tell whats going on with what where and how.. more so, when everything works in the emulator but not on a device, where there is no console, no error log, nothing to work with to try and figure out the issue.

The image below is the only error I get on my device. When attempting to communicate with facebook, through appMobi specific methods. I have litteraly copied and pasted there code trying to make this work cause I know once I can see this working and how its going to work I can then start building logic around something I actually want to do. That being a mute point at the moment. Anyway, when I run this same exact code in the emulator it works exactly as expected. But running it in Test Anywhere on the device itself seems to be where this conflict is coming in.

Soo I am wondering, has anyone had this issue before out there on stack? If so what did you do to fix it? Whats the work around? Whats the means of how you debugged it and came to the conclusion as I am sure I am going to run into similar problems down the road and debugging on the device is also a bonus.

enter image description here

my javascript currently:

document.addEventListener("appMobi.facebook.login",function(e){
        if (e.success == true) 
        { console.log("Facebook Log in Successful"); } 
        else 
        { console.log("Unsuccessful Login"); }
},false); 

function fbLoginCheckz()
{
 try{
      AppMobi.facebook.login('user_birthday,user_about_me,user_status,offline_access,publish_stream,publish_actions,email,read_friendlists,publish_checkins,create_event');
   }catch(e){
      alert("Error Caught [FB 1]: "+e.message);
   }
}

document.addEventListener("appMobi.facebook.logout",function(e){
        if (e.success == true) 
        { console.log("Logged out of Facebook"); } 
        else 
        { console.log("Unsuccessful Logout"); }
},false); 


var facebookUserID = "me";  //me = the user currently logged into Facebook 
document.addEventListener("appMobi.facebook.request.response",function(e) { 
    console.log("Facebook User Friends Data Returned"); 
    if (e.success == true) { 
        var data = e.data.data; 
        var outHTML = ""; 
        for (var r=0; r< data.length; r++) { 
            outHTML += "<img src='http://graph.facebook.com/" + data[r]["id"] 
            + "/picture' info='" + data[r]["name"] + "' />";        
        } 
    $("#blah").empty().html(outHTML); 
    document.removeEventListener("appMobi.facebook.request.response"); 
 }  
},false); 

my html:

    <br><br>
    <div id="blah"></div>
    <a href="#" onclick="window.location.reload();">RELOAD</a><br>
    <a href="#" onclick="fbLoginCheckz();">LOGIN</a><br>
    <a href="#" onclick="AppMobi.facebook.logout();">LOGOUT</a><br>
    <a href="#" onclick="AppMobi.facebook.requestWithGraphAPI(facebookUserID + '/friends','GET',null);">FRIENDS</a>
chris
  • 36,115
  • 52
  • 143
  • 252
  • If your phone is plugged into your computer, you can use the iPhone configuration utility to see your console. – ahren Aug 12 '12 at 23:52
  • Its not, but It can be. Where is this utility that you speak of? – chris Aug 12 '12 at 23:55
  • mac: http://support.apple.com/kb/DL1465 / windows: http://support.apple.com/kb/DL1466 – ahren Aug 12 '12 at 23:57
  • 2
    Just a wee note though: javascript errors don't seem to get logged to the console, but you can use `try{ Your code }catch(err){ console.log(err)}` – ahren Aug 13 '12 at 00:01
  • was a nice idea, but the console kinda just nods off after launching the app. No errors app side I guess, its in the stuff thats happening inbetween somewhere thats not being seen. – chris Aug 13 '12 at 00:19
  • can you turn safari debug mode on and use the in-browser facebook instead of the app then??? – ahren Aug 13 '12 at 00:20
  • not that I am aware of, it uses the fb ap that comes with android and ios from what I gather before anything else. – chris Aug 13 '12 at 02:25
  • Another option when you are building an appMobi application is to use the integrated weinre debugger. Then you can see the JavaScript errors on computer while running the application on device. For more information look here: http://debug.appmobi.com/ – profMobi Aug 15 '12 at 13:37
  • Oh, that looks very interesting. I tried something by apple I forget what its called now, but its something to do with device profiling and the ability to watch what the device is doing in a live raw log sort of way, and that was very unuseful. This debug thing, I am definately going to give that a shot. On a different note, I finally got my app to build in the iOS format, and was able to use FB as I do in the browser finally. So I can move back into dev, I appreciate all the help you John and Ian give thanks – chris Aug 15 '12 at 14:40

1 Answers1

2

There was a problem with the build system and the test containers. If you build an adHoc version of your software it should work. However, all my "test anywhere" helper applications also still have the bug for the time being.

There should be an update to the test containers shortly that should fix the problem. I'll try to post back here once they have been updated.

profMobi
  • 779
  • 4
  • 14
  • 1
    A Facebook helper library is also now available at http://www.appmobi.com/documentation/index.php?DOC=IMPLEMENTATION_GUIDE_FACEBOOK – profMobi Sep 19 '12 at 12:09