Facebook buttons force close android app

You must Login before you can answer or comment on any questions.

Hi.

I have an Android app that works.

When i added this to my code it wont even start it just force close.

What have i missed?

var check = Titanium.UI.createButton({
                title: 'Checka in',
                top : 140,
                style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN
            });
            win.add(check);
 
            // Handle the close event
            check.addEventListener('click',function() {
                Titanium.Facebook.appid = "36xxxxxxxxx636";
Titanium.Facebook.permissions = ['publish_stream', 'read_stream', "user_checkins", "publish_checkins"];
 
function doFacebookCheckin(_callback) {
 
    var getInfo = function(localCallback) {
 
        var data = {
            "place" : "121586314581979",
            "coordinates" : JSON.stringify({
                'latitude' : 61.347289,
                'longitude' : 16.393661,
            }),
            "access_token" : Ti.Facebook.accessToken
        };
        Ti.Facebook.requestWithGraphPath('me/checkins', data, 'POST', function(e2) {
 
            if(e2.success) { 
 
                Ti.API.info("Success");
                Ti.API.info(JSON.stringify(e2.result));
 
                Titanium.UI.createAlertDialog({
 title: 'Wass up?',
 message: 'Good to go!'
}).show();
 
                if(e2.result) {
                    var data = JSON.parse(e2.result);
                    return;
                }
 
            } else if(e2.cancelled) {
                Ti.API.error("User Cancelled");
                return;
            } else {
                Ti.API.error(JSON.stringify(e2));
                return;
            }
 
        });
    }
    // do that thing...
    if(!Titanium.Facebook.loggedIn) {
        Titanium.Facebook.authorize();
 
        Titanium.Facebook.addEventListener('login', function(e) {
            if(e.success) {
                setTimeout(function() {
                    getInfo();
                }, 2000); 
            } else if(e.error || e.cancelled) {
                return;
            }
        });
    } else {
       getInfo();
    }
}
 
doFacebookCheckin();
 
            });
 
 
 
Ti.Facebook.appid = '368xxxxx6636';
Ti.Facebook.permissions = ['read_stream', "user_checkins", "publish_checkins"];
 
 
 
win.add(Ti.Facebook.createLoginButton({
    top:200,
   style : Ti.Facebook.BUTTON_STYLE_NARROW
}));
Thanx

//R

— asked 12 months ago by Richard Harrysson
1 Comment
  • can you please show us your log records or Error messages.

    — commented 12 months ago by nilesh kashid

1 Answer

for starters this wont work on Android

style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN

dont know if it will stop the crash but it shouldnt be there

— answered 12 months ago by Aaron Saunders
answer permalink
1 Comment
  • Ha ha ha... Yes i saw that but i hoped that no one else would... :)

    No it still crashes and if i just have the FBlogin button it wont work either. If i have just the checkin button then it runs but it wont show...?

    If i just have this:

    win.addEventListener("focus", function(e) {
        if (Ti.Facebook.loggedIn) {
     
        } else {
            Titanium.Facebook.authorize();
        }
    });
     
    Titanium.Facebook.addEventListener('login', function(e) {
        var accTo = Titanium.Facebook.getAccessToken();
        // when you login to facebook then you can access using above line for access Token
        alert(accTo);
    });
    Then i get the login window and the app runs after that. So i guess i dont really need the FB login button if i just listen for the login and let it autocreate the login popup.

    But i dont sets the permissions for my app that way so i guess i need it anyway... :(

    But i do need the checkin button so any ideas on that one?

    — commented 12 months ago by Richard Harrysson

Your Answer

Think you can help? Login to answer this question!