Facebook Connect Plugin Using Phonegap Build

I saw a lot of questions about the Facebook Connect plugin using only Phonegap or Phonegap and Phonegap Build, but I still can't get it to work.

I created a facebook application (in fact, all I did was click the "Create a new application" button). I specified Display Name and Namespace and got the app ID . I updated the code https://github.com/amirudin/pgb-fbconnect (which is a simple example for the Facebook Connect plugin) with my app ID and Namespace in both index.html and config.xml. I fixed it in Phonegap Build (there is no Phonegap version in the config.xml version, so by default it is 2.9).

On Android (2.3.6 and 4.1) I always get Cordova Facebook Connect plugin fail on init! In iOS, nothing is displayed, but nothing works.

Since this warning only appears when calling FB._nativeInterface.init , I tried to use nativeInterface : false instead of nativeInterface : CDV.FB in FB.init . In this case, if I try to log in, the login page will be displayed, but after entering my name and password I get Given URL is not permitted by the application configuration.: One or more of the given URLs is not allowed by the App settings...

I am not sure how to setup facebook application:

  • I selected the Native iOS App , specified the Bundle ID (the same as the app ID I created on developer.apple.com, the same as the widget ID in Phonegap Build config.xml) and enabled Facebook Login . iPhone and iPad App Store ID remain at 0, Deep Linking disabled, and the URL scheme suffix empty.
  • I chose the Native Android App , specifying the Package Name (the same as the widget identifier in Phonegap Build config.xml), Key Hashes (one hash - I also added a key to build Phonegap - by the way, is it normal that the key is unlocked by only one hour, and for iOS - one month?), Facebook Login enabled. I do not know what I should use for the Class Name (I tried to leave it empty and then use the same as the Package Name and add ".activity" at the end). Deep Linking remains disabled. Here is what I used to generate the key and hash:

    // Create a key

    keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

    // Get hash (uses OpenSSL 0.9.8e on Win7 64)

    keytool -exportcert -alias alias_name -keystore my-release-key.keystore | openssl sha1 -binary | openssl base64

  • I tried installing App Domains on localhost , but then they told me that I also need to set the website URL or canvas URL.

  • therefore, I also selected Website with Facebook Login and specified http://localhost/ for the Site URL
  • and the selected App on Facebook , specified by http://localhost/ for the Canvas URL and https://localhost/ for the Secure Canvas URL . I left Canvas Width and Canvas Heigth to Fixed and Fluid , and Unity Integration Enabled - Disabled

The event after that, I still get the same error Given URL is not permitted by the application configuration... I know that Phonegap uses file:// , not http://localhost , but then I just don't know how to set up a facebook application.

I'm not sure if the Cordova Facebook Connect plugin fail on init! error is related Cordova Facebook Connect plugin fail on init! with the problem of App Domain or not, two problems that I will have to solve.

+6
source share
1 answer

Trying my application on another Android phone the next day, I noticed that I no longer had errors. I uninstalled and reinstalled the application on other Android phones, and the plugin also started working normally on all of them.

I'm not sure what the problem is: the problem with the hydra plugin (now I know that if something strange happens, I may have to uninstall and reinstall the application and make sure that hydration is complete), it took more time after creating the application on facebook (even if he stated that it might take minutes, not hours, to update all servers), ...

+1
source

Source: https://habr.com/ru/post/953961/


All Articles