IBM Worklight - config app facebook to run in real device

依然范特西╮ 提交于 2019-12-23 06:16:32

问题


I have a Worklight-based app that uses Facebook Login. When I preview it everything is ok (I can click the login button and the Facebook Login dialog box is displayed), but when I run it on the Android Emulator or device I get the following error in LogCat:

05-28 09:17:35.391: I / Web Console (751): URL has not been configured
> to allow application.: One or more of the provided URL is not set app
> permissions. URL must match the URL of the web page or the page URL or
> domain is a subdomain of the domain of application. at
> https://www.facebook.com/connect/ping?client_id=321009794697186&response_type=token%2Csigned_request%2Ccode&domain=&origin=2&redirect_uri=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D24%23cb%3Df1eae8b44c%26origin%3Dfile%253A%252F%252F%252Ff3688c0c94%26domain%3D%26relation%3Dparent&sdk=joey:1

This is my Facebook configuration in the app:

window.fbAsyncInit = function() {   FB.init({
    appId      : 'xxxxx', // App ID   //  channelUrl : 'http://stormy-sands-2143.herokuapp.com/channel.html', // Channel File
    status     : true, // check login status
    cookie     : true, // enable cookies to allow the server to access the session
    xfbml      : true,  // parse XFBML
    oauth: true   });


  };

  // Load the SDK asynchronously    (function(d){
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); js.id = id; js.async = true;
     js.src = "http://connect.facebook.net/en_US/all.js";
     d.getElementsByTagName('head')[0].appendChild(js);    }(document));

This is my Facebook configuration in the facebook.com app:

What do I need to configure for this to run in a device?


回答1:


I believe this error happens to you because you are using the Facebook JavaScript SDK.
This SDK is meant for when the web resources are on a server:

  • web sites or
  • mobile web apps

The Facebook App requires an App Domain/Site URL that a site or mobile web app would have, but an Android app doesn't have a domain...

A Worklight Hybrid app with the Android environment, while using web resources, is not a "mobile web app", it's an app.

Thus, you should either use a Cordova plug-in that implements Facebook login across platforms (whichever is available by the plug-in), or use the Facebook SDK for Android.



来源:https://stackoverflow.com/questions/17546357/ibm-worklight-config-app-facebook-to-run-in-real-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!