Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Native Sencha Touch app with Facebook authentication

Someone ever created a Native Android/iOS app in Sencha Touch and implement Facebook authentication? If so can you please share your code/method? I already go through this link https://developers.facebook.com/docs...login/devices/ but seems Facebook yet not supporting it.

All I want to provide a simple button in app and get user's Auth token from Facebook and package this app in Native.

The above question was unanswered in sencha fourum. I have copied here for larger audience, and require your suggestions as i am trying to accomplish the same.Link to Sencha forum

regards Punith

like image 916
Punith Raj Avatar asked Nov 12 '22 00:11

Punith Raj


1 Answers

I made a Sencha Touch app built with PhoneGap and hosted on both major store (Google Play and Apple Store) with a FB share function. I've used the "FacebookConnect" plugin of PhoneGap (https://github.com/phonegap/phonegap-plugins/tree/master/Android/FacebookConnect). I've used the folowing code to share a link:

window.plugins.facebookConnect.dialog('feed',
  {
    link: mylink,
    picture: mypicture, // provide not a local url. otherwise, FB does not display nothing and rises an "FBCDN image is not allowed in stream" error
    name: myname,
    caption: mycaption,
    description: mydescription
  },
  function(response) {
    console.log("FacebookConnect.dialog:" + JSON.stringify(response));
  }
);

If not already logged in on FB (using, for example, the FB native app if installed), the plugin will show the web-based login window to the user before open the share dialog.

Before that, remember to init the FB API using something like that somewhere in your app:

window.plugins.facebookConnect.initWithAppId(FBID, function(result) {
  console.log("FacebookConnect.initWithAppId: " + JSON.stringify(result));

  // Check for cancellation/error
  if(result.cancelled || result.error) {
    console.log("FacebookConnect.initWithAppId:failedWithError: " + result.message);
    return;
  }
});

also remember to NOT call the FB API login method at the startup of the app,otherwise Apple will reject application.

I hope this is useful to your project.

like image 73
Claudio Bertozzi Avatar answered Nov 15 '22 12:11

Claudio Bertozzi