PDA

View Full Version : Any facebook-connect phonegap remote build sencha touch examples :) ?



sagoig
10 Oct 2013, 3:15 AM
I'm working on a project which needs to connect user to his fb account,
I got links from Kurt001 ( thank you! ) for this example:
https://github.com/bdunklau/infinite-beach-9173/tree/master/www

B (https://github.com/bdunklau/infinite-beach-9173/tree/master/www)ut I'm looking for an example of someone who implemented it on sencha touch,
Thank you in advanced :) !

mitchellsimoens
14 Oct 2013, 1:46 PM
Shouldn't be hard to see how that git repo accomplished it and port it to your app.

sagoig
15 Oct 2013, 2:33 AM
Done :) works very good

johnestar
6 Apr 2014, 5:39 PM
Can you provide some of your code as example? I don't think it is that simple!

sagoig
26 May 2014, 3:10 AM
Hey, are you stuck at some point? where you stand at? let me know and I will be happy to help after using this for a few months now..

carlo123
20 Aug 2014, 2:12 AM
Hi Sagoig, I used Sencha Architect (touch) and I need to implement the facebook login. I think to use phonegap acebook plugin but I can not understand how to use it. Can you help me please?
I know how instal it and after how to configure config.xml....but after? wich is the code to insert in sencha?

thank you
Carlo

sagoig
20 Aug 2014, 10:09 AM
Hey Carlo, have you successfully compiled using phonegap already? (I use phonegap build online, it's very nice and fast)

carlo123
20 Aug 2014, 11:49 PM
No for this plugin...but I have used yet an other plugin (camera) and function perfectly.
Now I would to use also the facebook plugin but i don't know after the code to insert in sencha....Do you have an example? Have you used a code to do a login in Facebook?

Carlo

joshmorony
21 Aug 2014, 4:30 AM
Hi Carlo, I wrote a blog post about using the Facebook Connect plugin with Sencha Touch, maybe it will help you:

http://www.joshmorony.com/posting-to-a-facebook-wall-with-phonegap-the-javascript-sdk/

My eBook also goes much more in depth into Facebook integration.

carlo123
21 Aug 2014, 1:12 PM
I Josh, Thank for your help. I Install the cordova plugin and after I insert your example code:

but I received this error:
FB is not defined

I tried to use before your code to use:


window.fbAsyncInit = function()
{
console.log('Ref: '+1);
FB.getLoginStatus(function(response) {

if (response.authResponse) {

FB.ui({
method: 'feed',
link: 'http://runtap.com',
caption: 'RunTap'
}, function(response){});

}
else {

FB.login(function(response) {
if (response.authResponse) {
FB.ui({
method: 'feed',
link: 'http://runtap.com',
caption: 'RunTap'
}, function(response){});
}
}, {scope: 'basic_info'});

}
},true);

};



the fbAsyncInit....but with this I don't see the console log and so I think that the code don't go with the fbAsyncInit...

Do you know why?
thank you

joshmorony
21 Aug 2014, 1:48 PM
You need to initialise Facebook first as well as making sure your app is set up correctly on developer.facebook.com:



window.fbAsyncInit = function() {


FB.init({
appId : '*****',
status : true,
xfbml : true
});


FB.Event.subscribe('auth.statusChange', function(response) {
console.log('status changed');
});
};


//Include SDK
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));


that's for a web based version, if you want it to use the fb connect plugin on a device:



FB.init({
appId : '*****',
status : true,
nativeInterface: CDV.FB,
useCachedDialog: false
});


FB.Event.subscribe('auth.statusChange', function(response) {
console.log('status changed');
});

coletek
2 Nov 2014, 3:33 AM
Hi Josh,

I've tried your code with the latest facebookconnect, i.e. 0.8.0, as seen in config.xml:


<gap:plugin name="com.phonegap.plugins.facebookconnect" version="0.8.0" >

but when I install the .apk on the phone that was generated by the phonegap build cloud, I get this error via looking at "adb logcat | grep -i console":


Uncaught ReferenceError: FB is not defined

And when I look in the .apk file generated, I don't see cdv-plugin-fb-connect.js or facebook-js-sdk.js, which should of been automatically added by phonegap cloud build.

However, if I change the facebook connect version to 0.4.0 in the config.xml, then cdv-plugin-fb-connect.js and facebook-js-sdk.js are automatically added to the .apk package, and I do not get the FB is not defined error - the apps works as expected.

I'm guessing there is a issue with phonegap build cloud service - any thoughts?

joshmorony
2 Nov 2014, 1:07 PM
Hi Cole,

There's no problem with the build service, just that the plugin has been updated and now requires a slightly different implementation. You now reference 'facebookConnectPlugin' instead of 'FB' and web apps must call 'browserInit'. There are some other minor changes too, check the documentation here:

https://github.com/Wizcorp/phonegap-facebook-plugin/blob/a948725/README.md

I'll be updating my eBook (https://joshmorony.com/build-a-sencha-touch-login-system/) in the next few weeks with detailed instructions on how to use the updated plugin.

quethanhvn
2 Nov 2014, 10:40 PM
I come from Vietnam, in Vietnam, the forum at sencha touch too, but luckily I found this forum. But my english level is not good. Hic.

coletek
22 Jan 2015, 9:53 PM
Hi Josh,

I ended up just using 0.4.0 to get it to work. But today I tried to upgrade to 0.8.0, and now it works with facebookConnectPlugin instead of FB. However for native version I get the following error on with this code:



facebookConnectPlugin.init({
appId : "MY_APP_ID",
status : true,
nativeInterface: CDV.FB,
useCachedDialog: false
});


The error I get is: Uncaught ReferenceError: CDV is not defined

Please advise?

joshmorony
22 Jan 2015, 10:14 PM
There's a few different things in version 0.8.0. You no longer initialise the plugin like that, instead use:



if(!(Ext.os.is.Android || Ext.os.is.iOS)){
facebookConnectPlugin.browserInit('YOUR_APP_ID');
}


That code only needs to run if it's running through the web, hence the check for the OS.

coletek
22 Jan 2015, 10:29 PM
Hi Josh,

As my previous comment says. I'm only having issues making it work natively (i.e. on Android or iOS). So are you saying I just drop the code:



facebookConnectPlugin.init({
appId : "MY_APP_ID",
status : true,
nativeInterface: CDV.FB,
useCachedDialog: false
});


If that is true, how does the facebook connect plugin know the appId?

joshmorony
23 Jan 2015, 12:21 AM
Yes, you should be able to just drop that if you're running native only.

You supply your app id and app name in the config.xml file:



<gap:plugin name="com.phonegap.plugins.facebookconnect">
<param name="APP_ID" value="[INSERT YOUR APP ID]" />
<param name="APP_NAME" value="[INSERT YOUR APP NAME]" />
</gap:plugin>

rononeal
24 Jan 2015, 10:09 PM
When executing the code, I am receiving this message:

Uncaught ReferenceError: facebookConnectPlugin is not defined

I have setup the files per the instructions, but it appears that the js file is not found. I have my FB id setup. What is the best way to test the facebookConnectPlugin command?

joshmorony
25 Jan 2015, 12:38 AM
If you're running it through the browser you need to make sure you're including the facebook connect Javascript file (make sure to reference it in your app.json file in the scripts section). Also run 'sencha app refresh' in the command line under your current project to make sure it is being included.

If you're running on a device after building with PhoneGap and you have Facebook Connect referenced in your config.xml file you should have facebookConnectPlugin available to you after you build with PhoneGap and install on a device.

coletek
28 Jan 2015, 7:50 AM
Hi Josh,Removing the .init worked. However is the following code also obsolete:



facebookConnectPlugin.Event.subscribe('auth.statusChange', function(response) { console.log('FB status changed');
});


As I get this error with it: "Uncaught TypeError: Cannot call method 'subscribe' of undefined"

When I remove it, it gets passed the error, but when I click the "Login with Facebook" button, which calls facebookConnectPlugin.getLoginStatus(), the response.status != connected, but facebookConnectPlugin.login() is not called - the code is exactly like your code.

Please remember this is when I try under Android native.

FMI: have you updated your ebook - if so, can you email me the latest version?

joshmorony
28 Jan 2015, 1:04 PM
Yes, the eBook has been updated to reflect the new version of Facebook Connect and you're correct the subscribe method is no longer used.

Can you please email me the email address you purchased with or the sales receipt and I will reset your downloads. Feel free to email me if you have any more questions in the future, I may miss it if it's posted here.