Facebook authentication in cordova / angularjs app

I am trying to use the phonegap-facebook plugin to authenticate with facebook and it works with the given examples. But now I can not figure out how to properly configure it using angular.

I tried the Ciul angular-facebook module for this purpose, and it works in the browser, but I don’t understand how to configure it in the native environment.

The angular-facebook module comes with a separate script for a telephone conversation. Does anyone here explain how the setup should be?

+4
source share
1 answer

.

index.html cordova.js cdv-plugin-fb-connect, angular -facebook angular -facebook-phonegap.js Ciul.

index.html

<script src="cordova.js"></script>
<script src="cdv-plugin-fb-connect.js"></script>
<script src="/bower_components/angular-facebook/lib/angular-facebook.js"></script>
<script src="/bower_components/angular-facebook/lib/angular-facebook-phonegap.js"></script>

bootstraping Angular.js . , angular -facebook-phonegap .

document.addEventListener('deviceready', onDeviceReady, false);

FacebookProvier angular config .

angular.config

var application_conf_mobile = {
    appId: "XXXXXXX",
    oauth: true,
    localSDK: 'facebook-js-sdk.js', //Load sdk async
    nativeInterface: CDV.FB,
    status: false,
    frictionlessRequests: true,
    useCachedDialogs: false,
    cookies:true
}
FacebookProvider.init(application_conf_mobile,false);

CDV.

api, , ( "Facebook" ):

: call api:

Facebook.getLoginStatus(function(response) {
  handleStatusChange(response)
})

, Facebook ( angular facebook ):

$rootScope.$on('Facebook:authResponseChange', function(e,data){})
$rootScope.$on('Facebook:login', function(e,data){})
...

, , !

+5

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


All Articles