Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

intel/cordova-plugin-intel-xdk-facebook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DISCONTINUATION OF PROJECT.

This project will no longer be maintained by Intel.

Intel has ceased development and contributions including, but not limited to, maintenance, bug fixes, new releases, or updates, to this project.

Intel no longer accepts patches to this project.

If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the open source software community, please create your own fork of this project. DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this project, including but not limited to, maintenance, bug fixes, new releases or updates. Patches to this project are no longer accepted by Intel. In an effort to support the developer community, Intel has made this project available under the terms of the Apache License, Version 2. If you have an ongoing need to use this project, are interested in independently developing it, or would like to maintain patches for the community, please create your own fork of the project.

intel.xdk.facebook

Integrate your application with Facebook.

This Intel XDK Cordova plugin and API has been deprecated. A suggested alternative Cordova plugin for use on Android and iOS platforms is available as a [third-party plugin](http://wizcorp.tumblr.com/post/91812168412/the-semi-official-facebook- phonegap-plugin-comes-to). Coverage for all platforms is available using [this JavaScript micro library](http://coenraets.org/blog/2014/04/facebook-phonegap-cordova-without- plugin/) (this is not a plugin). In addition, a general-purpose OAuth2 JavaScript library (no plugin required) named "HelloJS" can be used to log into Facebook (as well as a variety of other services).

Description

This object gives applications the capability to log users into Facebook in order to access their Facebook Graph as well as to post to the news feed and share request dialogs.

For more information on on how to use the Facebook JavaScript API commands in a native application, stop by this Facebook Integration article.

Methods

  • enableFrictionlessRequests — This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog
  • login — This method logs the user into Facebook
  • logout — This method logs the user out of Facebook
  • requestWithGraphAPI — This method makes calls to the new Graph Facebook API
  • requestWithRestAPI — This method makes calls to the older REST Facebook API
  • showAppRequestDialog — This method displays the Facebook application request dialog
  • showNewsFeedDialog — This method displays the Facebook news feed submission dialog

Events

Methods

enableFrictionlessRequests

This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog

intel.xdk.facebook.enableFrictionlessRequests();

Description

This command ensures that news feed requests are "frictionless" in that it enables users to send requests to specific friends without having to click on a pop-up confirmation dialog. This command option is for iOS only since Android requests are automatically set to be "frictionless".

Platforms

  • Apple iOS
  • Google Android

login

This method logs the user into Facebook

intel.xdk.facebook.login(permissions);

Description

This command is used to log the user into Facebook. When it is run, a dialog generated by Facebook should appear allowing the user to enter their credentials. Depending on the result of that interaction with Facebook, the application will receive a JavaScript event (intel.xdk.facebook.login) indicating whether the login was successful or not. This method will log the user in with a series of default permissions if no permissions parameter is specified.

Platforms

  • Apple iOS
  • Google Android

Events

  • intel.xdk.facebook.login: This event is fired upon completion of the interaction with Facebook and will indicate either successful login or failure.

Example

alert("about to log into facebook");
document.addEventListener("intel.xdk.facebook.login",function(e){
        if (e.success == true)
        { console.log("Facebook Log in Successful"); }
        else
        { console.log("Unsuccessful Login"); }
},false);
intel.xdk.facebook.login("publish_stream,publish_actions,offline_access");

logout

This method logs the user out of Facebook

intel.xdk.facebook.logout();

Platforms

  • Apple iOS
  • Google Android

Events

Example

alert("logging out of facebook");
document.addEventListener("intel.xdk.facebook.logout",function(e){
        if (e.success == true)
        { console.log("Logged out of Facebook"); }
        else
        { console.log("Unsuccessful Logout"); }
},false);
intel.xdk.facebook.logout();

requestWithGraphAPI

This method makes calls to the new Graph Facebook API

intel.xdk.facebook.requestWithGraphAPI(path, method, parameters);

Description

This method is used to make a request from the newer Facebook Graph API. For more information on this particular API, see Facebook’s documentation here.

Platforms

  • Apple iOS
  • Google Android

Parameters

  • path: The Facebook Graph PATH to execute
  • method: The request method to call the Facebook Graph API, typically GET or POST
  • parameters: Any parameters required for the request

Events

Example

var facebookUserID = "me";  //me = the user currently logged into Facebook
document.addEventListener("intel.xdk.facebook.request.response",function(e) {
    console.log("Facebook User Friends Data Returned");
    if (e.success == true) {
        var data = e.data.data;
        var outHTML = "";

        for (var r=0; r< data.length; r++) {
        outHTML += "<img src='http://graph.facebook.com/" + data[r]["id"] +
            "/picture' info='" + data[r]["name"] + "' />";

        }
        document.getElementsByTagName("body")[0].innerHTML = outHTML;
        document.removeEventListener("intel.xdk.facebook.request.response");
    }
},false);
intel.xdk.facebook.requestWithGraphAPI(facebookUserID + "/friends","GET","");

requestWithRestAPI

This method makes calls to the older REST Facebook API

intel.xdk.facebook.requestWithRestAPI(command, method, parameters);

Description

This method is used to make a request using the older Facebook REST API. This API is being deprecated by Facebook, and may not be available in the future. For more information on Facebook’s REST API see the Facebook documentation here.

Platforms

  • Apple iOS
  • Google Android

Parameters

  • command: The REST API command to have Facebook execute
  • method: The request method to call the Facebook REST API, typically GET or POST
  • parameters: Any parameters required for the request

Events

showAppRequestDialog

This method displays the Facebook application request dialog

intel.xdk.facebook.showAppRequestDialog(parameters);

Description

The Request Dialog sends a Request from one user (the sender) to one or more users (the recipients). The Request Dialog can be used to send a Request directly from one user to another or display a Multi Friend Selector Dialog, allowing the sending user to select multiple recipient users.

Platforms

  • Apple iOS
  • Google Android

Parameters

  • parameters: A JSON object holding the appropriate parameters for the request as specified in Facebook's documentation

Events

Example

document.addEventListener("intel.xdk.facebook.dialog.complete",function(e) {
        console.log("Permissions Request Returned");
        if (e.success == true) {
                console.log("News feed updated successfully");
        } else { console.log("permissions request failed"); }
},false);
var objParameters = {"to":"USER_ID_HERE","message":"My Awesome 
    Message","title":"A title for this dialog would go here"}
intel.xdk.facebook.showAppRequestDialog(objParameters);

showNewsFeedDialog

This method displays the Facebook news feed submission dialog

intel.xdk.facebook.showNewsFeedDialog(parameters);

Platforms

  • Apple iOS
  • Google Android

Events

Example

//This allows the application to post to Facebook for the logged in user
document.addEventListener("intel.xdk.facebook.dialog.complete",function(e) {
    console.log("News Feed Event Returned");
    if (e.success == true) {
        console.log("News feed updated successfully");
    }
},false);
var objParameters = {
    "picture":"http://fbrell.com/f8.jpg",
    "name":"Facebook Dialog",
    "caption":"This is my caption",
    "description":"Using Dialogs to interact with users.",
    "link":"http://xdk.intel.com"
}
intel.xdk.facebook.showNewsFeedDialog(objParameters);

Events

busy

Fired if a second Facebook request is made while a previous request is still pending

dialog.complete

This event is fired in response to a news feed or app request dialog

Description

Returns an event object with the properties success and data

dialog.fail

This event is fired if Facebook tries to log the user on during a dialog request, but the login fails

login

Fired after logging a user into Facebook

Description

Returns an event object with the properties success and data

logout

Fired after logging a user out of Facebook

Description

Returns an event object with the properties success and data

request.response

Fired in response to a Facebook API request

Description

Returns an event object with the properties success and data

session.invalidate

Fired if the Facebook session is invalidated