Hi.
I have in my app a function that listens if the user is logged in on FB or not and if not it will authorize.
It all worked well with
Ti.Facebook etc....
But now when i have changed it to the new module it doesnt seem to work...
Here is my code that i have now:
var fb = require('facebook'); fb.appid= '3517xxxxxx23302'; fb.permissions = ['read_stream', "user_checkins", "publish_checkins", "rsvp_event"]; var ta2 = Titanium.UI.createTextArea({ value : '', height : 110, width : 260, top : 20, font : {fontSize:20}, color : '#050505', textAlign : 'left', borderColor: 'transparent', borderRadius: 6, backgroundImage : 'images/tablebg.png', scrollable : true, editable : true }); win.add(ta2); ta2.addEventListener('focus',function(e) { if (fb.loggedIn) { } else { var alertDialog = Titanium.UI.createAlertDialog({ title: Titanium.App.Properties.getString("namn")+'s Mobilapp ', message: 'Du måste logga in på Facebook för att använda den här funktionen. \nVill du göra det nu?', buttonNames: ['Ja','Nej'], cancel: 1 }); alertDialog.addEventListener('click',function(e){ if (e.index == 0) { fb.authorize(); }else{ win.close(); alertDialog.hide(); } }); alertDialog.show(); } });So what is missing and/or wrong?
I have this for my checkins:
vip_btn.addEventListener('click',function() { fb.appid = "3517xxxxxx23302"; fb.permissions = ['publish_stream', 'read_stream', 'user_checkins', 'rsvp_event', 'user_events','publish_checkins']; function doFacebookCheckin(_callback) { var getInfo = function(localCallback) { // GOTCHA - You need to stringify the coordinates or the // the API call will fail, this was a PITA to find var data = { "place" : "521xxxxxxxxx597", "coordinates" : JSON.stringify({ 'latitude' : xx.341526, 'longitude' : xx.409798, }), "access_token" : fb.accessToken }; fb.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: Titanium.App.Properties.getString("namn"), message: 'Incheckad!' }).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(!fb.loggedIn) { fb.authorize(); fb.addEventListener('login', function(e) { if(e.success) { setTimeout(function() { getInfo(); }, 2000); } else if(e.error || e.cancelled) { return; } }); } else { getInfo(); } } doFacebookCheckin(); });And that works like a charm....
This is the error i'm getting:
[ERROR] : Script Error { [ERROR] : backtrace = "#0 () at :0"; [ERROR] : line = 28; [ERROR] : message = "missing appid"; [ERROR] : sourceId = 353372576; [ERROR] : sourceURL = "file://localhost/Users/admin/Library/Application%20Support/iPhone%20Simulator/6.1/Applications/73AAA1AD-ADD0-427C-A571-2EA6235409BC/parken.app/postto.js"; [ERROR] : } [ERROR] : 2013-07-01 00:11:43.177 parken[11891:1f103] Warning: Attempt to present <TiErrorController: 0xb0cbf30> on <TiRootViewController: 0xb5a0660> whose view is not in the window hierarchy!I am building wit Ti SDK 3.1.0.GA and this is for iOS SDK 6.1
Any thoughts?