Modules.Facebook
> Modules.Facebook

Add-on Facebook module.

The Facebook module is used for connecting your application with Facebook. This module supports the following features:

  • Logging in to Facebook and authorizing your application with either the Login button or programatically.

  • Making requests through the Facebook Graph API using the requestWithGraphPath() method.

  • Sharing content using Facebook dialogs or the Like button.

Using Ti.Facebook with iOS 10 and Xcode 8

The paragraph about custom capabilities was only necessary between Titanium SDK 5.5.0 and 6.0.0. Since 6.0.1.GA, we add the required capabilities automatically, so you don't need to curate your own entitlements file anymore, which will avoid possible issues with concurring values. Please ensure to use both SDK and CLI 6.0.1 (or later).

Note: As of April 30th, 2015, Facebook no longer supports version 1.0 of their API, which includes the FQL and REST APIs. Only the Graph APIs will be supported.

Migration from the Facebook module v4.x to v5.x

  • dialog() method -- presentWebShareDialog() is deprecated and removed. The module will auto determine if you have a native Facebook App installed. canPresentShareDialog() is also deprecated and removed. For more details, see 'Share Dialogs' and 'Request Dialogs' below.

  • presentShareDialog() method -- 'name' parameter is deprecated and replaced with 'title'. 'caption' parameter is deprecated and removed.

  • presentSendRequestDialog() method -- 'to' parameter is deprecated and replaced with 'recipients'. There are a few new parameters as well, for more details, see presentSendRequestDialog()

The following APIs were removed due to changes in the native Facebook SDKs and removal of the Facebook v1.0 REST APIs:

  • appid property -- The Facebook application ID can no longer be set programmatically in the application. Set the Facebook application ID in the tiapp.xml file. For more details, see 'Getting Started' below for more details. Migration from the Facebook module v3.x to v4.x

The following APIs were removed due to changes in the native Facebook SDKs and removal of the Facebook v1.0 REST APIs:

  • appid property -- The Facebook application ID can no longer be set programmatically in the application. Set the Facebook application ID in the tiapp.xml file. For more details, see 'Getting Started' below for more details.

  • dialog() method -- Use either presentSendRequestDialog(), presentInviteDialog(), presentMessengerDialog(), presentShareDialog() or presentWebShareDialog(). For more details, see 'Share Dialogs' and 'Request Dialogs' below.

  • forceDialogAuth property -- On Android, you can force dialog authorization with the LoginButton.sessionLoginBehavior property.

  • publishInstall() method -- The underlying Facebook API has been deprecated and is now handled automatically by the module.

  • request() method -- Due to the removal of the Facebook v1.0 APIs, all applications should call the Graph APIs instead. If you make any REST API calls with the request() method, transition to the Graph APIs and use the requestWithGraphPath() method.

  • reauthorize() method -- To request additional Facebook permissions once the user authorizes the application, use either the requestNewReadPermissions() or requestNewPublishPermissions(). For more details, see "Manage Read and Write Permissions" below.

  • LoginButton style property -- Facebook redesigned its Login button and the style can no longer be changed.

  • Places API -- Fetch nearby places using the current location or a specified search-tearm.

Getting Started

To use the Facebook module, you need a Facebook application. To create a Facebook App, go to the Facebook Developer App: developers.facebook.com/apps.

  • Edit the modules section of your tiapp.xml file to include this module:

    <modules>
        <!-- Add the appropriate line(s) to your modules section -->
        <module platform="android">facebook</module>
        <module platform="iphone">facebook</module>
    </modules>
    
  • Instantiate the module with the require('facebook') method, then make subsequent API calls with the new Facebook object.

     var fb = require('facebook');
     fb.permissions = [FACEBOOK_APP_PERMISSIONS]; // e.g. ['email']
     fb.initialize();
     fb.authorize();
    

Additional iOS Setup Steps

For the iOS platform, in the ios plist dict section of your tiapp.xml file, add the following keys:

  • FacebookAppID key with your Facebook App ID as the string value
  • FacebookDisplayName key with your Facebook App name (the one from developer.facebook.com) as the string value
  • CFBundleURLTypes key with a single-element array containing a dict as the value, where the dict contains:
    • CFBundleURLName key with the application app ID (same value as the id in the tiapp.xml file) as the string value
    • CFBundleURLSchemes key with a single-element array containing the Facebook App ID prefixed with fb as a string value

For example:

    <ti:app>
        <ios>
            <plist>
                <dict>
                    <key>CFBundleURLTypes</key>
                    <array>
                        <dict>
                            <key>CFBundleURLName</key>
                            <!-- Application ID same as the id value in the tiapp.xml file -->
                            <string>APP_ID</string>
                            <key>CFBundleURLSchemes</key>
                            <array>
                                <!-- Prefix the Facebook App ID with 'fb' -->
                                <string>fbFACEBOOK_APP_ID</string>
                            </array>
                        </dict>
                    </array>
                    <key>FacebookAppID</key>
                    <!-- Facebook App ID -->
                    <string>FACEBOOK_APP_ID</string>
                    <key>FacebookDisplayName</key>
                    <!-- Facebook App Name from developer.facebook.com -->
                    <string>FACEBOOK_APP_NAME</string>
                </dict>
            </plist>
        </ios>
    </ti:app>

To enable the use of Facebook dialogs (e.g., Login, Share), you also need to include the following key and values in tiapp.xml to handle the switching in and out of your app:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
</array>

If you are using the older Ti.Facebook Module 4.0.5 and wish to support iOS9, you will instead need to include the following key and values in tiapp.xml to handle the switching in and out of your app:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

For iOS9 and titanium 5.0.0.GA and above, App Transport Security is disabled by default. If you choose to enable it, you have to set the following keys and values in tiapp.xml section for facebook module:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
        <dict>
            <key>facebook.com</key>
                <dict>
                    <key>NSIncludesSubdomains</key> 
                    <true/>
                    <key>NSExceptionRequiresForwardSecrecy</key> 
                    <false/>
                </dict>
            <key>fbcdn.net</key>
                <dict>
                    <key>NSIncludesSubdomains</key> 
                    <true/>
                    <key>NSExceptionRequiresForwardSecrecy</key>  
                    <false/>
                </dict>
            <key>akamaihd.net</key>
                <dict>
                    <key>NSIncludesSubdomains</key> 
                    <true/>
                    <key>NSExceptionRequiresForwardSecrecy</key> 
                    <false/>
                </dict>
        </dict>
</dict>

Additional Android Setup Steps

Since Facebook module v4.0.0, for the Android platform, you need to:

  • Add the Facebook Login activity to the Android manifest
  • Add the Facebook App ID to the Android resources string.xml file
  • Create a Facebook proxy and associate it with the current active activity

Modify the Android Manifest

Add the Facebook Login activity to the android manifest section of your tiapp.xml file. You may need to add the manifest and application elements.

<ti:app>
    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest>
            <application>
                <activity android:name="com.facebook.FacebookActivity" 
                          android:theme="@android:style/Theme.Translucent.NoTitleBar" 
                          android:label="YourAppName" 
                          android:configChanges="keyboard|keyboardHidden|screenLayout|screenSize|orientation" />
                <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="@string/facebook_app_id"/>
            </application>
        </manifest>
    </android>
<ti:app>

Add the Facebook App ID to Android Resources

Add a string element to the /platform/android/res/values/strings.xml file with the name attribute set to facebook_app_id and the node text set to your Facebook App ID. Create the file if it does not exist.

<resources>
    <string name="facebook_app_id">FACEBOOK_APP_ID</string>
</resources>

Create a Facebook Proxy

Use the createActivityWorker() method to create a Facebook proxy. Pass the method a dictionary with the lifecycleContainer property set to the current active instance of a standalone Window (window not contained in a tab group) or TabGroup. Create the proxy before calling the open() method on either the window or tab group.

The Facebook module needs to hook into the lifecycle events of the current active activity in order to synchronize its state between various activities in the application, for example, to update the label of the Login button when the user logs in or out of Facebook.

Attach the proxy to the Window or TabGroup object, so it does not get garbage collected.

win.fbProxy = fb.createActivityWorker({lifecycleContainer: win});

Module API Usage

Facebook Login and Authorization

To use Facebook, a user must logged into Facebook and explicitly authorize the application to perform certain actions, such as accessing profile information or posting status messages.

There are two ways to initiate the login process:

  • Call authorize to prompt the user to login and authorize the application. Before calling this method, set the permissions property if additional permissions are needed.

  • Create a Facebook LoginButton to allow the user to log in if desired. You can add either read permissions or write permissions, otherwise the default is to request for the public_profile permission. Note that Facebook does not support setting both readPermissions and publishPermissions properties at the same time when using the LoginButton.

Which approach you take depends on your UI and how central Facebook is to your application.

Manage Read and Write Permissions

In order to read or write content to a user's Facebook page, you need to request permission from the user. You can either request permissions when the user authorizes your application or request permissions on the fly.

Before the user logs in and authorizes the application, you can request permissions for the application to use by either:

  • Setting the permissions property if you are using authorize() method to have the user login and authorize the application.
  • Setting either the readPermissions or publishPermissions on an instance of a LoginButton. Do not set both properties or the application will throw an error.

For a complete list of permissions, see the official Facebook Permissions Reference

Refresh Application Permissions

Since the user can selectively turn application permissions on and off from their Facebook page, the application may need to refresh its granted permissions.

To refresh the application's permissions, call the refreshPermissionsFromServer() method, then listen for the tokenUpdated event to be notified when permissions are updated.

fb.addEventListener('tokenUpdated', function(e) {
    Ti.API.info('Updated permissions: ' + JSON.stringify(fb.permissions));
});
fb.refreshPermissionsFromServer();

Request Additional Read Permissions

To request additional read permissions once the user authorizes your application, use the requestNewReadPermissions() method.

Check the permissions property to make sure the user accepted the request for additional permissions.

var fb = require('facebook');
fb.requestNewReadPermissions(['read_stream','user_hometown', etc...], function(e) {
    if (e.success) {
        fb.requestWithGraphPath(...);
    } else if (e.cancelled) {
        ....
    } else {
        Ti.API.debug('Failed authorization due to: ' + e.error);
    }
});

Request Additional Write Permissions

To request additional write permissions once the user authorizes your application, use the requestNewPublishPermissions() method. Note that in addition to passing the permissions to request, you need to also pass an AUDIENCE_* constant to indicate the default audience when positing content.

Check the permissions property to make sure the user accepted the request for additional permissions.

var fb = require('facebook');
fb.requestNewPublishPermissions(['read_stream','user_hometown', etc...], fb.AUDIENCE_FRIENDS, function(e) {
    if (e.success) {
        fb.requestWithGraphPath(...);
    } else if (e.cancelled) {
    ....
    } else {
        Ti.API.debug('Failed authorization due to: ' + e.error);
    }
});

Share Dialogs

The Share dialog prompts a person to publish an individual story or an Open Graph story to their timeline. This does not require the user to authorize your app or any extended permissions, so it is the easiest way to enable sharing.

The Share dialog uses the Facebook apps interface, so the Facebook app needs to be installed. If the Facebook app is not installed, the application can use the Feed dialog that presents the dialog in a web-based view as a back up if the Share dialog is not available.

To present a Share dialog to a user, use the canPresentShareDialog property to check if the application can use the Share dialog. If the application supports the Share dialog, call the presentShareDialog() to present it, else call the presentWebShareDialog() method to present the Feed dialog.

Pass either method parameters you want to add to the post, such as a link or hashtag, or to share the user's status, do not pass any parameters to the methods.

To monitor if the share request succeeded or not, listen to the shareCompleted event. It uses the same arguments as presentMessengerDialog.

    fb.addEventListener('shareCompleted', function (e) {
        if (e.success) {
            Ti.API.info('Share request succeeded.');
        } else {
            Ti.API.warn('Failed to share.');
        }
    });

    fb.presentShareDialog({
        link: 'https://appcelerator.com/',
        hashtag: 'codestrong'
    });

For details on the Share dialog, see the official Facebook Share Dialogs documentation.

Requests Dialog

A request dialog allows a user to invite another user to use your application. Facebook will send a private message to the recipient. The typical use case is to invite another user to play a game. If you want to invite people to your application which is not a game, use the presentInviteDialog() method instead.

To send a request to a user, call the presentSendRequestDialog() method and pass the method a dictionary with the message property set the message you want to send the invited user. Optional: You can set the title property with a title string. You can also set the data property with a dictionary of custom parameters. If you want to preselect users to send invite to, you can set the to property with string of values that are facebook ids seperated by comma.

To monitor if the request succeeded or not, listen to the requestDialogCompleted event.

    fb.addEventListener('requestDialogCompleted', function (e) {
        if (e.success) {
            Ti.API.info('request succeeded.');
        } else {
            Ti.API.warn('Failed to share.');
        }
    });

    fb.presentSendRequestDialog({
        message: 'Go to https://appcelerator.com/',
        title: 'Invitation to Appcelerator',
        recipients: ['123456789', '123456788'],
        data: {
            badge_of_awesomeness: '1',
            social_karma: '5'
        }
    });

For details on request dialogs see the official Facebook Request Dialogs documentation.

Messenger Dialog

A messenger dialog allows a user to send content to the Facebook Messenger using your application.

To send a message to a user, call the presentMessengerDialog() method and pass the method a dictionary with the optional values "hashtag", "link", "to", "placeID" and "referal". It uses the same arguments as presentShareDialog.

    fb.presentMessengerDialog({
        link: "https://appcelerator.com", // The link you want to share
        referal: "ti_app", // The referal to be added as a suffix to your link
        placeID: "my_id", // The ID for a place to tag with this content
        to: [] // List of IDs for taggable people to tag with this content
    });

For details on dialog see the official Facebook Messenger Dialogs documentation.

Messenger Button

The Messenger button provides a quick mechanism for users to share content to the Facebook Messenger. A click on the button can share the content to multiple users.

To create a Messenger button, call the createMessengerButton() method and pass the "mode" and "style" properties:

var messengerButton = fb.createMessengerButton({
    mode: fb.MESSENGER_BUTTON_MODE_RECTANGULAR
    style: fb.MESSENGER_BUTTON_STYLE_BLUE
});
win.add(messengerButton);

For more information, see the MessengerButton API reference.

Like Button

The Like button provides a quick mechanism for users to share content. A click on the button will share the content on the user's Facebook page.

To create a Like button, call the createLikeButton() method and pass it a dictionary with the objectID assigned to either a URL or Open Graph object ID you want to share. Add the button instance to a view to display it.

var likeButton = fb.createLikeButton({
    objectID: "https://www.facebook.com/appcelerator"
});
win.add(likeButton);

For more information, see the LikeButton API reference.

Fetch Places

The Facebook SDK supports fetching places since Graph API v2.9. You are able to use the official FBSDKPlacesKit API in Titanium SDK 6.2.0 and later to fetch places by the current user location or a specified search tearm. Example of using the current location:

fb.fetchNearbyPlacesForCurrentLocation({
    confidenceLevel: fb.PLACE_LOCATION_CONFIDENCE_NOT_APPLICABLE, // optional
    fields: [], // optional, see https://developers.facebook.com/docs/places/fields
    success: function(e) {
        alert('Successfully fetched places!');
        Ti.API.info(e);
    },
    error: function(e) {
        alert('Error fetching places!');
        Ti.API.error(e);
    }
}); 

Check out the full example in examples/facebook_places.js.

Examples

Alloy Example

Displays the Facebook Login and Like buttons in a window.

app/alloy.js:

// Make API calls to Alloy.Globals.Facebook
Alloy.Globals.Facebook = require('facebook');

app/views/index.xml:

<Alloy>
    <Window backgroundColor="white">
        <LoginButton id="fbLogin" module="facebook" top="25" />
        <LikeButton id="fbLike" module="facebook" top="100" />
    </Window>
</Alloy>

app/controllers/index.js:

$.fbLike.objectID = "http://www.facebook.com/appcelerator";
if (OS_ANDROID) {
    $.index.fbProxy = Alloy.Globals.Facebook.createActivityWorker({lifecycleContainer: $.index});
}
$.index.open();

Authorize

Shows official Facebook dialog for logging in the user and prompting the user to approve your requested permissions. Listen for the module's login event to determine whether the request succeeded.

var fb = require('facebook');
fb.initialize();
fb.addEventListener('login', function(e) {
    if (e.success) {
        alert('login from uid: '+e.uid+', name: '+ JSON.parse(e.data).name);
        label.text = 'Logged In = ' + fb.loggedIn;
    }
    else if (e.cancelled) {
        // user cancelled
        alert('cancelled');
    }
    else {
        alert(e.error);
    }
});
fb.authorize();

Logout

Logout the user and forget the authorization token. The logout event is fired after the user is logged out.

fb.addEventListener('logout', function(e) {
    alert('Logged out');
});
fb.logout();

Authorize/Logout Using the Facebook LoginButton

You can use the the native Facebook LoginButton to allow the user to log in as required. The button updates its state automatically depending on whether the user is logged in or not. When the user is logged in, then the button will show "Logout", and vice-versa.

Note that you don't need to set a click listener or anything else on the button. To be notified when the user logs in or out, add event listeners for the login and logout events provided by the Facebook module, as in the example below.

// Don't forget to set your requested permissions, else the login button won't be effective.
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var fb = require('facebook');

fb.addEventListener('login', function(e) {
    if (e.success) {
        alert('Logged in');
    }
});
fb.addEventListener('logout', function(e) {
    alert('Logged out');
});

if (Ti.Platform.name === 'android') {
    win.fbProxy = fb.createActivityWorker({lifecycleContainer: win});
}

// Add the button.  Note that it doesn't need a click event listener.
win.add(fb.createLoginButton({
        readPermissions: ['read_stream','email'],
        top: 50
}));

win.open()

Simple Graph API Call

This example makes a call to the "me" graph path, which represents the current user. The JSON results are simply displayed in an alert. This example assumes the user is already logged in. You can check this with loggedIn.

fb.requestWithGraphPath('me', {}, 'GET', function(e) {
    if (e.success) {
        alert(e.result);
    } else if (e.error) {
        alert(e.error);
    } else {
        alert('Unknown response');
    }
});

Post a Photo Using the Graph API from the Gallery.

This example posts a photo to the user's account using the Graph API. This requires the "publish_actions" permission.

var B1_TITLE = 'Upload Photo from Gallery with Graph API';
var b1 = Ti.UI.createButton({
    title:B1_TITLE,
    left: 10, right: 10, top: 0, height: 80
});

b1.addEventListener('click', function() {
    Titanium.Media.openPhotoGallery({
        success:function(event)
        {
            b1.title = 'Uploading Photo...';
            var data = {picture: event.media};
            // If publish_actions permission is not granted, request it
            if (fb.permissions.indexOf('publish_actions') < 0) {
                fb.requestNewPublishPermissions(['publish_actions'], fb.AUDIENCE_FRIENDS, function(e) {
                    if (e.success) {
                        Ti.API.info('Permissions:'+fb.permissions);
                        fb.requestWithGraphPath('me/photos', data, "POST", showRequestResult);
                    }
                    if (e.error) {
                        Ti.API.info('Publish permission error');
                    }
                    if (e.cancelled) {
                        Ti.API.info('Publish permission cancelled');
                    }
                });
            } else {
                fb.requestWithGraphPath('me/photos', data, "POST", showRequestResult);
            }
        },
        cancel:function()
        {
        },
        error:function(error)
        {
        },
        allowEditing:true
    });
});

For more information on posting photos, see:

Post a Photo Using the Graph API with an image in resources directory

This example posts a photo to the user's account using the Graph API. This requires the "publish_actions" permission.

var b2 = Ti.UI.createButton({
    title: 'Upload Photo from file with Graph API',
    left: 10, 
    right: 10, 
    top: 90, 
    height: 80
});

b2.addEventListener('click', function() {
    b2.title = 'Uploading Photo...';
    var f = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'images', 'flower.jpg');
    var blob = f.read();
    var data = {
        caption: 'behold, a flower',
        picture: blob
    };
    // If publish_actions permission is not granted, request it
    if (fb.permissions.indexOf('publish_actions') < 0) {
        fb.requestNewPublishPermissions(['publish_actions'], fb.AUDIENCE_FRIENDS, function(e) {
            if (e.success) {
                Ti.API.info('Permissions:'+fb.permissions);
                fb.requestWithGraphPath('me/photos', data, "POST", showRequestResult);
            }
            if (e.error) {
                Ti.API.info('Publish permission error');
            }
            if (e.cancelled) {
                Ti.API.info('Publish permission cancelled');
            }
        });
    } else {
        fb.requestWithGraphPath('me/photos', data, "POST", showRequestResult);
    }
});

For more information on posting photos, see:

Show the Share Dialog

This example shows how to use the Share Dialog.

var wallDialog = Ti.UI.createButton({
    title: 'Share URL with Share Dialog',
    top: 135, 
    left: 10, 
    right: 10, 
    height: 40
});

wallDialog.addEventListener('click', function() {
    if (fb.getCanPresentShareDialog()) {
        fb.presentShareDialog({
            link: 'https://appcelerator.com/',
            name: 'great product',
            description: 'Titanium is a great product',
            caption: 'it rocks too',
            picture: 'http://www.appcelerator.com/wp-content/uploads/scale_triangle1.png'
        });
    } else {
        fb.presentWebShareDialog({
            link: 'https://appcelerator.com/',
            name: 'great product',
            description: 'Titanium is a great product',
            caption: 'it rocks too',
            picture: 'http://www.appcelerator.com/wp-content/uploads/scale_triangle1.png'
        });
    }
});

For more information on Facebook Dialogs, see:

Show the Invite Dialog

This example shows how to use the Invite Dialog.

var wallDialog = Ti.UI.createButton({
    title: 'Invite friends!',
    top: 135, 
    left: 10, 
    right: 10, 
    height: 40
});

wallDialog.addEventListener('click', function() {
    FB.presentInviteDialog({
        appLink: "https://fb.me/xxxxxxxx",
        appPreviewImageLink: "https://www.mydomain.com/my_invite_image.jpg"
    });
});

For more information on Invite Dialogs, see: Facebook Invite Dialog Reference

Share content to the Facebook Messenger

This example shows how to share images, GIF's and videos to the Facebook messenger.

var btn = Ti.UI.createButton({
    title: "Share media to messenger"
});
btn.addEventListener("click", function(e) {
    var media = [
        Ti.UI.createView({height: 30,width:30,backgroundColor: "#ff0"}).toImage(), // Image blob
        Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "test.gif").read(), // GIF Blob
        Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, "movie.mp4").read() // Video Blob
    ];

    var options = Ti.UI.createOptionDialog({
        options: ["Photo", "GIF", "Video", "Cancel"],
        cancel: 3
    });
    options.addEventListener("click", function(e) {
        if (e.index == 3) {
            return;
        }
        FB.shareMediaToMessenger({
            media: media[e.index],
            metadata: "Ti rocks!",
            link: "https://appcelerator.com",
            //renderAsSticker: true // Only for photos e.g. selfies
        });
    });
    options.show();
});

For more information on sharing media to the Facebook Messenger, see:

Requesting additional permissions

This example shows how to use the requestNewPublishPermissions method to request additional permissions to publish a post to the user's wall.

fb.requestNewPublishPermissions(['publish_actions'], fb.AUDIENCE_FRIENDS, function(e) {
    if (e.success) {
        fb.requestWithGraphPath('me/feed', null, "POST", showRequestResult);
    } else {
        Ti.API.debug('Failed authorization due to: ' + e.error);
    }
});
  • 3.1.0
  • 3.1.0
  • 3.1.0
Defined By

Properties

Modules.Facebook
ACTION_TYPE_ASK_FOR : Numberreadonly

The user is asking for an object from friends.

The user is asking for an object from friends.

Use to set the actionType with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
ACTION_TYPE_NONE : Numberreadonly

No action type.

No action type.

Use to set the actionType with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
ACTION_TYPE_SEND : Numberreadonly

The user is sending an object to the friends.

The user is sending an object to the friends.

Use to set the actionType with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
ACTION_TYPE_TURN : Numberreadonly

It is the turn of the friends to play against the user in a match.

It is the turn of the friends to play against the user in a match.

Use to set the actionType with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
AUDIENCE_EVERYONE : Numberreadonly

Published content is visible to all Facebook users.

Published content is visible to all Facebook users.

Use to set the default audience with either LoginButton.audience or requestNewPublishPermissions.

  • 4.0.0
  • 4.0.0
  • 4.0.0
Modules.Facebook
AUDIENCE_FRIENDS : Numberreadonly

Published content is only visible to the user and user's friends.

Published content is only visible to the user and user's friends.

Use to set the default audience with either LoginButton.audience or requestNewPublishPermissions.

  • 4.0.0
  • 4.0.0
  • 4.0.0
Modules.Facebook
AUDIENCE_ONLY_ME : Numberreadonly

Published content is only visible to the user.

Published content is only visible to the user.

Use to set the default audience with either LoginButton.audience or requestNewPublishPermissions.

  • 4.0.0
  • 4.0.0
  • 4.0.0
Modules.Facebook
BUTTON_STYLE_NORMAL : Numberreadonlyremoved

Use with LoginButton.style to specify the default login button reading "Connect" or "Login".

Use with LoginButton.style to specify the default login button reading "Connect" or "Login".

This property has been removed since 4.0.0

Modules.Facebook
BUTTON_STYLE_WIDE : Numberreadonlyremoved

Use with LoginButton.style to specify a wide login button reading "Connect with Facebook" or "Login with Facebook".

Use with LoginButton.style to specify a wide login button reading "Connect with Facebook" or "Login with Facebook".

This property has been removed since 4.0.0

Modules.Facebook
FILTER_APP_NON_USERS : Numberreadonly

Friends not using the app can be displayed.

Friends not using the app can be displayed.

Use to set the filter with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
FILTER_APP_USERS : Numberreadonly

Friends using the app can be displayed.

Friends using the app can be displayed.

Use to set the filter with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
FILTER_NONE : Numberreadonly

No filter all friends can be displayed.

No filter all friends can be displayed.

Use to set the filter with presentSendRequestDialog()

  • 5.0.0
  • 5.0.0
  • 5.0.0
Modules.Facebook
LOGIN_BEHAVIOR_BROWSER : Numberreadonly

Opens login window in the default Web Browser (Safari/Firefox etc...)

Opens login window in the default Web Browser (Safari/Firefox etc...)

  • 5.4.0
  • 5.4.0
  • 5.4.0
Modules.Facebook
LOGIN_BEHAVIOR_DEVICE_AUTH : Numberreadonly

Expose Facebook Login for devices such as Android TV and Fire TV.

Expose Facebook Login for devices such as Android TV and Fire TV.

  • 5.4.0
Modules.Facebook
: Numberreadonly
Opens login window with the native Facebook app. ...

Opens login window with the native Facebook app. On iOS it will attempt to fallback to if the Facebook app is not installed or Facebook chooses it internally. For Android use to get this behavior.

Note: As of today (Facebook SDK 4.11.0), Facebook seems to not allow logging in using the Facebook app to login, so this constant won't work proper on iOS. This issue is discussed here.

  • 5.4.0
  • 5.4.0
  • 5.4.0
Modules.Facebook
: Numberreadonly
Opens login window with the native Facebook app. ...

Opens login window with the native Facebook app. On Android it will attempt to fallback to if the Facebook app is not installed. For iOS use to get this behavior.

  • 5.4.0
Modules.Facebook
LOGIN_BEHAVIOR_SYSTEM_ACCOUNT : Numberreadonly

Attempts to login with through the Facebook account currently signed in through Settings.

Attempts to login with through the Facebook account currently signed in through Settings.

  • 5.4.0
  • 5.4.0
Modules.Facebook
LOGIN_BEHAVIOR_WEB : Numberreadonly

Opens login window through a modal browser window.

Opens login window through a modal browser window.

  • 5.4.0
  • 5.4.0
Modules.Facebook
: Numberreadonly
The default behavior. ...

The default behavior. The tooltip will only be displayed if the app is eligible (determined by possible server round trip).

  • 6.1.0
  • 6.1.0
  • 6.1.0
Modules.Facebook
: Numberreadonly
Force disable. ...

Force disable. In this case you can still exert more refined control by manually constructing a new login button.

  • 6.1.0
  • 6.1.0
  • 6.1.0
Modules.Facebook
LOGIN_BUTTON_TOOLTIP_BEHAVIOR_FORCE_DISPLAY : Numberreadonly

Force display of the tooltip (typically for UI testing).

Force display of the tooltip (typically for UI testing).

  • 6.1.0
  • 6.1.0
  • 6.1.0
Modules.Facebook
LOGIN_BUTTON_TOOLTIP_STYLE_FRIENDLY_BLUE : Numberreadonly

Light blue background, white text, faded blue close button.

Light blue background, white text, faded blue close button.

  • 6.1.0
  • 6.1.0
  • 6.1.0
Modules.Facebook
LOGIN_BUTTON_TOOLTIP_STYLE_NEUTRAL_GRAY : Numberreadonly

Dark gray background, white text, light gray close button.

Dark gray background, white text, light gray close button.

  • 6.1.0
  • 6.1.0
  • 6.1.0
Modules.Facebook
MESSENGER_BUTTON_MODE_CIRCULAR : Numberreadonly

Use with MessengerButton.mode to specify the default send button reading "Send".

Use with MessengerButton.mode to specify the default send button reading "Send".

You can localize the button by localizing "Send" in your strings.xml. Learn more about that topic here.

  • 5.4.0
  • 5.4.0
Modules.Facebook
MESSENGER_BUTTON_MODE_RECTANGULAR : Numberreadonly

Use with MessengerButton.mode to specify the default send button reading "Send".

Use with MessengerButton.mode to specify the default send button reading "Send".

You can localize the button by localizing "Send" in your strings.xml. Learn more about that topic here.

  • 5.4.0
  • 5.4.0
Modules.Facebook
MESSENGER_BUTTON_STYLE_BLUE : Numberreadonly

Use with MessengerButton.style to specify the default send button style.

Use with MessengerButton.style to specify the default send button style.

  • 5.4.0
  • 5.4.0
Modules.Facebook
MESSENGER_BUTTON_STYLE_WHITE : Numberreadonly

Use with MessengerButton.style to specify the default send button style.

Use with MessengerButton.style to specify the default send button style.

  • 5.4.0
  • 5.4.0
Modules.Facebook
MESSENGER_BUTTON_STYLE_WHITE_BORDERED : Numberreadonly

Use with MessengerButton.style to specify the default send button style.

Use with MessengerButton.style to specify the default send button style.

  • 5.4.0
  • 5.4.0
Modules.Facebook
PLACE_LOCATION_CONFIDENCE_HIGH : Numberreadonly

High confidence level.

High confidence level.

  • 6.2.0
  • 6.2.0
Modules.Facebook
PLACE_LOCATION_CONFIDENCE_LOW : Numberreadonly

Low confidence level.

Low confidence level.

  • 6.2.0
  • 6.2.0
Modules.Facebook
PLACE_LOCATION_CONFIDENCE_MEDIUM : Numberreadonly

Medium confidence level.

Medium confidence level.

  • 6.2.0
  • 6.2.0
Modules.Facebook
PLACE_LOCATION_CONFIDENCE_NOT_APPLICABLE : Numberreadonly

Used to indicate that any level is acceptable as a minimum threshold.

Used to indicate that any level is acceptable as a minimum threshold.

  • 6.2.0
  • 6.2.0
Modules.Facebook
SHARE_DIALOG_MODE_AUTOMATIC : Numberreadonly

Acts with the most appropriate mode that is available.

Acts with the most appropriate mode that is available.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_BROWSER : Numberreadonly

Displays the dialog in Safari.

Displays the dialog in Safari.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_FEED_BROWSER : Numberreadonly

Displays the feed dialog in Safari.

Displays the feed dialog in Safari.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_FEED_WEB : Numberreadonly

Displays the feed dialog in a webview within the app.

Displays the feed dialog in a webview within the app.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_NATIVE : Numberreadonly

Displays the dialog in the main native Facebook app.

Displays the dialog in the main native Facebook app.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_SHARE_SHEET : Numberreadonly

Displays the dialog in the iOS integrated share sheet.

Displays the dialog in the iOS integrated share sheet.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
Modules.Facebook
SHARE_DIALOG_MODE_WEB : Numberreadonly

Displays the dialog in a web view within the app.

Displays the dialog in a web view within the app.

Use with presentShareDialog().

  • 6.0.0
  • 6.0.0
  • 6.0.0
Modules.Facebook
SSO_ONLY : Numberreadonly

Only attempt single sign-on.

Only attempt single sign-on.

Use with the LoginButton.sessionLoginBehavior property.

  • 4.0.0
Modules.Facebook
SSO_WITH_FALLBACK : Numberreadonly

Attempt single sign-on, then fallback to dialog authorization.

Attempt single sign-on, then fallback to dialog authorization.

Use with the LoginButton.sessionLoginBehavior property.

  • 4.0.0
Modules.Facebook
SUPPRESS_SSO : Numberreadonly

Do not attempt single sign-on and only use dialog authorization.

Do not attempt single sign-on and only use dialog authorization.

Use with the LoginButton.sessionLoginBehavior property.

  • 4.0.0
Modules.Facebook
accessToken : Stringreadonly

OAuth token set after a successful authorize.

OAuth token set after a successful authorize.

apiName : Stringreadonly

The name of the API that this proxy corresponds to.

The name of the API that this proxy corresponds to.

The value of this property is the fully qualified name of the API. For example, Button returns Ti.UI.Button.

  • 3.2.0
  • 3.2.0
  • 3.2.0
Modules.Facebook
: String
If not explicitly set, the default will be read from the application's plist (FacebookAppID) which is the recommende...

If not explicitly set, the default will be read from the application's plist (FacebookAppID) which is the recommended way.

Since Titanium SDK 6.2.0, this property also has a getter to return the currently set appID.

Indicates if the proxy will bubble an event to its parent. ...

Indicates if the proxy will bubble an event to its parent.

Some proxies (most commonly views) have a relationship to other proxies, often established by the add() method. For example, for a button added to a window, a click event on the button would bubble up to the window. Other common parents are table sections to their rows, table views to their sections, and scrollable views to their views. Set this property to false to disable the bubbling to the proxy's parent.

Default: true

  • 3.0.0
  • 3.0.0
  • 3.0.0
Modules.Facebook
canPresentOpenGraphActionDialog : Booleanreadonly

Checks if the device can support the use of the Facebook Open Graph action dialog from the Facebook App.

Checks if the device can support the use of the Facebook Open Graph action dialog from the Facebook App.

  • 4.0.0
Modules.Facebook
canPresentShareDialog : Booleanreadonlyremoved

Checks if the device can support the use of the Facebook Share dialog from the Facebook App.

Checks if the device can support the use of the Facebook Share dialog from the Facebook App.

This property has been removed since 5.0.0

  • 4.0.0
  • 4.0.0
  • 4.0.0
Modules.Facebook
expirationDate : Datereadonly

Time at which the accessToken expires.

Time at which the accessToken expires.

Modules.Facebook
: Booleanremoved
Indicates whether the login should use the traditional dialog-based authentication. ...

Indicates whether the login should use the traditional dialog-based authentication.

This property has been removed since 4.0.0

Set to false to enable Single-Sign-On (SSO) in cases where the official Facebook app is on the device. Default is true, meaning the traditional, dialog-based authentication is used rather than SSO. See the Facebook Mobile Guide for details of their Single-Sign-On scheme.

To use the built-in iOS 6 login, set this property to false. This property is read-only on Mobile Web.

Default: true

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

The Window or TabGroup whose Activity lifecycle should be triggered on the proxy.

If this property is set to a Window or TabGroup, then the corresponding Activity lifecycle event callbacks will also be called on the proxy. Proxies that require the activity lifecycle will need this property set to the appropriate containing Window or TabGroup.

  • 3.6.0
Modules.Facebook
loggedIn : Booleanreadonly

Indicates if the user is logged in.

Indicates if the user is logged in.

Modules.Facebook
: NumberCreation-Only
Defines the behavior that the module will attempt to use for authorize(). ...

Defines the behavior that the module will attempt to use for authorize().

Be sure to set this before calling authorize if this is needed. It is recommended to follow Facebook's guidelines for ideal login behavior

This API can be assigned the following constants:

Default: Defaults to on Android and on iOS (which uses the native Safari Dialog internally).

  • 5.4.0
  • 5.4.0
  • 5.4.0
Modules.Facebook
permissions : String[]

Array of permissions to request for your app.

Array of permissions to request for your app.

Be sure the permissions you want are set before calling authorize.

For a complete list of permissions, see the official Facebook Permissions Reference

iOS Platform Notes

On iOS, do not request any write permissions before calling the authorize() method. Use the requestNewPublishPermissions() to request write permissions once the user authorizes the application.

Prior to Release 4.0.0

To use the build-in iOS 6 login, this property cannot contain any of the following: offline_access, publish_actions, publish_stream, publish_checkins, ads_management, create_event, rsvp_event, manage_friendlists, manage_notifications, or manage_pages.

Modules.Facebook
uid : Stringreadonly

Unique user ID returned from Facebook.

Unique user ID returned from Facebook.

Defined By

Methods

Adds the specified callback as an event listener for the named event. ...

Adds the specified callback as an event listener for the named event.

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to invoke when the event is fired.

Returns

  • void
Applies the properties to the proxy. ...

Applies the properties to the proxy.

Properties are supplied as a dictionary. Each key-value pair in the object is applied to the proxy such that myproxy[key] = value.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • props : Dictionary

    A dictionary of properties to apply.

Returns

  • void
Modules.Facebook
( )
Prompts the user to log in (if not already logged in) and authorize your application. ...

Prompts the user to log in (if not already logged in) and authorize your application. You can also use LoginButton to log in.

Be sure to set your required permissions before calling authorize.

A login event is generated to indicate a successful or unsuccessful login attempt.

iOS Platform Notes

On iOS, do not request any write permissions before calling this method. Use the requestNewPublishPermissions() to request write permissions once the user authorizes the application.

Prior to Release 4.0.0

Set the appid property as well as the permissions property before calling authorize().

Returns

  • void
Modules.Facebook
( parameters ) : Titanium.Proxy
Creates a Facebook proxy to hook into the activity of either a standalone Titanium.UI.Window (not inside a TabGroup) ...

Creates a Facebook proxy to hook into the activity of either a standalone Titanium.UI.Window (not inside a TabGroup) or Titanium.UI.TabGroup.

Set the lifecycleContainer property in the dictionary passed to the method to either the current active instance of a Titanium.UI.Window or Titanium.UI.TabGroup in order to monitor the activity's lifecycle events, required by Facebook to synchronize its state between various activities in the application.

The proxy object must be created before calling the open() method on the associated Window or TabGroup.

  • 4.0.0

Parameters

  • parameters : Dictionary<Titanium.Proxy>

    Properties to set on a new object, including any defined by Titanium.Proxy except those marked not-creation or read-only.

    Note: You must set the lifecycleContainer property.

Returns

Modules.Facebook
( [parameters] ) : Modules.Facebook.LikeButton
Creates and returns an instance of Modules.Facebook.LikeButton. ...

Creates and returns an instance of Modules.Facebook.LikeButton.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

Returns

Modules.Facebook
( [parameters] ) : Modules.Facebook.LoginButton
Creates and returns an instance of Modules.Facebook.LoginButton. ...

Creates and returns an instance of Modules.Facebook.LoginButton.

Parameters

Returns

Creates and returns an instance of Modules.Facebook.MessengerButton. ...

Creates and returns an instance of Modules.Facebook.MessengerButton.

  • 5.4.0
  • 5.4.0

Parameters

Returns

Modules.Facebook
( [confidenceLevel], [fields], success, error )
Query for places the device is likely located in. ...

Query for places the device is likely located in.

This is an asynchronous call, due to the need to fetch the current location from the device. Note that the results of the graph request are improved if the user has both Wi-Fi and Bluetooth enabled.

Note: Remember to request the location permssions with Titanium.Geolocation and include either the NSLocationWhenInUseUsageDescription or the NSLocationAlwaysUsageDescription key in your plist before using this method. The Facebook graph also requires the FacebookClientToken to be present in the plist, so check the Facebook Developer Portal > Apps > Your App > Settings > Advanced for your OAuth client-token.

  • 6.2.0
  • 6.2.0

Parameters

Returns

  • void
Modules.Facebook
( searchTearm, [categories], [fields], [distance], [cursor], success, error )
Query for nearby places using the device's current location and search-term. ...

Query for nearby places using the device's current location and search-term.

This is an asynchronous call, due to the need to fetch the current location from the device.

Note: Remember to request the location permssions with Titanium.Geolocation and include either the NSLocationWhenInUseUsageDescription or the NSLocationAlwaysUsageDescription key in your plist before using this method. The Facebook graph also requires the FacebookClientToken to be present in the plist, so check the Facebook Developer Portal > Apps > Your App > Settings > Advanced for your OAuth client-token.

  • 6.2.0
  • 6.2.0

Parameters

  • searchTearm : String

    The term to search for in the Places Graph.

  • categories : Array<String> (optional)

    The categories for the place. Each string in this array must be a category recognized by the SDK. See the Facebook Docs for all possible values.

  • fields : Array<String> (optional)

    A list of fields that you might want the request to return. See the Facebook docs for all possible values.

  • distance : Number (optional)

    The search radius. For an unlimited radius, use 0.

  • cursor : String (optional)

    A pagination cursor.

  • success : Callback

    The callback triggered when places are successfully fetched.

  • error : Callback

    The callback triggered when places could not be fetched.

Returns

  • void
Fires a synthesized event to any registered listeners. ...

Fires a synthesized event to any registered listeners.

Parameters

  • name : String

    Name of the event.

  • event : Dictionary

    A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Returns

  • void
Modules.Facebook
( ) : String
Gets the value of the accessToken property. ...

Gets the value of the accessToken property.

Returns

  • String
Gets the value of the apiName property. ...

Gets the value of the apiName property.

  • 3.2.0
  • 3.2.0
  • 3.2.0

Returns

  • String
Modules.Facebook
( ) : String
Gets the value of the appID property. ...

Gets the value of the appID property.

Returns

  • String
Gets the value of the bubbleParent property. ...

Gets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Returns

  • Boolean
Modules.Facebook
( ) : Boolean
Gets the value of the canPresentOpenGraphActionDialog property. ...

Gets the value of the canPresentOpenGraphActionDialog property.

  • 4.0.0

Returns

  • Boolean
Modules.Facebook
( ) : Booleanremoved
Gets the value of the canPresentShareDialog property. ...

Gets the value of the canPresentShareDialog property.

This method has been removed since 5.0.0

  • 4.0.0
  • 4.0.0
  • 4.0.0

Returns

  • Boolean
Modules.Facebook
( ) : Date
Gets the value of the expirationDate property. ...

Gets the value of the expirationDate property.

Returns

  • Date
Modules.Facebook
( ) : Booleanremoved
Gets the value of the forceDialogAuth property. ...

Gets the value of the forceDialogAuth property.

This method has been removed since 4.0.0

Returns

  • Boolean
Gets the value of the lifecycleContainer property. ...

Gets the value of the lifecycleContainer property.

  • 3.6.0

Returns

Modules.Facebook
( ) : Boolean
Gets the value of the loggedIn property. ...

Gets the value of the loggedIn property.

Returns

  • Boolean
Modules.Facebook
( ) : Number
Gets the value of the loginBehavior property. ...

Gets the value of the loginBehavior property.

  • 5.4.0
  • 5.4.0
  • 5.4.0

Returns

  • Number
Modules.Facebook
( ) : String[]
Gets the value of the permissions property. ...

Gets the value of the permissions property.

Returns

  • String[]
Modules.Facebook
( ) : String
Gets the value of the uid property. ...

Gets the value of the uid property.

Returns

  • String
Modules.Facebook
( )
Loads a cached Facebook session if available, then fires the login event. ...

Loads a cached Facebook session if available, then fires the login event.

Be sure to set your login and logout event listeners before calling initialize.

**Note: This method needs to be called before calling authorize in order to be handle the auth-flow correctly. Otherwise, you might see a white screen without any response.

The timeout parameter was deprecated in version 5.0.0 of Ti.Facebook and is not used anymore.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Returns

  • void
Modules.Facebook
( event, [valueToSum], [params] )
Logs a custom event to Facebook. ...

Logs a custom event to Facebook.

From the Facebook API Reference:

Events are not sent immediately when logged. They're cached and flushed out to the Facebook servers in a number of situations:

  • when an event count threshold is passed (currently 100 logged events).
  • when a time threshold is passed (currently 15 seconds).
  • when an app has gone to background and is then brought back to the foreground.

Some things to note when logging events:

  • There is a limit on the number of unique event names an app can use, on the order of 300.
  • Event names must be between 2 and 40 characters and must consist of alphanumeric characters, _, - or spaces.
  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

  • event : String

    Arbitrary string to log as an event.

  • valueToSum : Number (optional)

    An arbitrary number that can represent any value (e.g., a price or a quantity). When reported, all of the valueToSum properties will be summed together in Facebook Analytics for Apps (since 5.4.0).

  • params : Object (optional)

    A dictionary object containing optional parameters (since 5.4.0).

Returns

  • void
Modules.Facebook
( amount, currency )
Log a purchase of the specified amount, in the specified currency. ...

Log a purchase of the specified amount, in the specified currency.

  • 5.2.0
  • 5.2.0
  • 5.2.0

Parameters

  • amount : Number

    Purchase amount to be logged, as expressed in the specified currency. This value will be rounded to the thousandths place (e.g., 12.34567 becomes 12.346).

  • currency : String

    Currency, is denoted as, e.g. "USD", "EUR", "GBP". See ISO-4217 for specific values.

Returns

  • void
Modules.Facebook
( payload, [action] )
Log an app event that tracks that the application was open via Push Notification. ...

Log an app event that tracks that the application was open via Push Notification.

  • 6.1.0
  • 6.1.0
  • 6.1.0

Parameters

  • payload : Dictionary

    Notification payload received via in the push-notification callback.

  • action : String (optional)

    Name of the action that was taken.

Returns

  • void
Modules.Facebook
( )
Clears the OAuth accessToken and logs out the user. ...

Clears the OAuth accessToken and logs out the user.

Returns

  • void
Modules.Facebook
( params )
Opens a supported Facebook Invite dialog from the Facebook App. ...

Opens a supported Facebook Invite dialog from the Facebook App.

To monitor if the share request succeeded or not, listen to the shareCompleted event.

  • 5.4.0
  • 5.4.0
  • 5.4.0

Parameters

  • params : InviteDialogParams

    A dictionary object containing required and optional parameters.

Returns

  • void
Modules.Facebook
( params )
Opens a supported Messenger dialog from the Facebook Messenger App. ...

Opens a supported Messenger dialog from the Facebook Messenger App.

Be sure to check if the device can support this method by calling canOpenURL with "fb-messenger-api://" before using this method. If true, you can use this method. If false, the Facebook Messenger application is probably not installed in the device.

Listen for the shareCompleted to be notified if the attempt was successful or not.

  • 5.4.0
  • 5.4.0

Parameters

Returns

  • void
Modules.Facebook
( params )
Opens an App Request dialog. ...

Opens an App Request dialog.

A requestDialogCompleted event is generated to indicate if the request attempt was successful or unsuccessful, and the resultURL.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

Returns

  • void
Modules.Facebook
( params )
Opens a supported Facebook Share dialog from the Facebook App. ...

Opens a supported Facebook Share dialog from the Facebook App.

Be sure to check if the device can support this method by calling getCanPresentShareDialog before using this method. If true, you can use this method. If false, the Facebook application is probably not installed in the device. In this case, use presentWebShareDialog instead.

Listen for the shareCompleted to be notified if the attempt was successful or not.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

Returns

  • void
Modules.Facebook
( )
Makes a request to Facebook to get the latest permissions granted. ...

Makes a request to Facebook to get the latest permissions granted.

Facebook now grants total control over granted permissions, and if the user modified the permissions outside of your app your cached token may not be updated.

Listen for the tokenUpdated event to be notified if the attempt was successful.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Returns

  • void
Removes the specified callback as an event listener for the named event. ...

Removes the specified callback as an event listener for the named event.

Multiple listeners can be registered for the same event, so the callback parameter is used to determine which listener to remove.

When adding a listener, you must save a reference to the callback function in order to remove the listener later:

var listener = function() { Ti.API.info("Event listener called."); }
window.addEventListener('click', listener);

To remove the listener, pass in a reference to the callback function:

window.removeEventListener('click', listener);

Parameters

  • name : String

    Name of the event.

  • callback : Callback<Object>

    Callback function to remove. Must be the same function passed to addEventListener.

Returns

  • void
Modules.Facebook
( permissions, audience, callback )
Makes a request to Facebook for additional write permissions. ...

Makes a request to Facebook for additional write permissions.

Note that it is not an error for the user to 'Skip' your requested permissions, so you should check the module's permissions property following the call.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

Returns

  • void
Modules.Facebook
( permissions, callback )
Makes a request to Facebook for additional read permissions. ...

Makes a request to Facebook for additional read permissions.

Note that it is not an error for the user to 'Skip' your requested permissions, so you should check the module's permissions property following the call.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Parameters

Returns

  • void
Modules.Facebook
( path, params, httpMethod, callback )
Makes a Facebook Graph API request. ...

Makes a Facebook Graph API request.

If the request requires user authorization, the user must be logged in, and your app must be authorized to make the request. You can check the loggedIn property to determine if the user is logged in.

Every Facebook object has an associated path. For example, "me" requests information about the current user.

For a complete list of Graph API methods, parameters and return types, see the official Facebook Graph API documentation.

Parameters

  • path : String

    Graph API path to request.

  • params : Dictionary

    A dictionary object for setting parameters required by the call, if any.

  • httpMethod : String

    The HTTP method (GET/POST/DELETE) to use for the call.

  • callback : Callback<FacebookGraphResponse>

    Callback to invoke when the request completes.

Returns

  • void
Modules.Facebook
( appID )
Sets the value of the appID property. ...

Sets the value of the appID property.

Parameters

  • appID : String

    New value for the property.

Returns

  • void
Sets the value of the bubbleParent property. ...

Sets the value of the bubbleParent property.

  • 3.0.0
  • 3.0.0
  • 3.0.0

Parameters

  • bubbleParent : Boolean

    New value for the property.

Returns

  • void
Modules.Facebook
( params )
Set a new access token for using Facebook services. ...

Set a new access token for using Facebook services.

  • 6.2.0
  • 6.2.0

Parameters

  • params : CurrentAccessTokenParams

    A dictionary object containing required and optional parameters.

    Note: There is an open issue in the native Facebook SDK causing the appID from not being updated although specified in the parameters. You can use the appID setter to change the appID inside your app.

Returns

  • void
Modules.Facebook
( forceDialogAuth )removed
Sets the value of the forceDialogAuth property. ...

Sets the value of the forceDialogAuth property.

This method has been removed since 4.0.0

Parameters

  • forceDialogAuth : Boolean

    New value for the property.

Returns

  • void
Sets the value of the lifecycleContainer property. ...

Sets the value of the lifecycleContainer property.

  • 3.6.0

Parameters

Returns

  • void
Modules.Facebook
( loginBehavior )
Sets the value of the loginBehavior property. ...

Sets the value of the loginBehavior property.

  • 5.4.0
  • 5.4.0
  • 5.4.0

Parameters

  • loginBehavior : Number

    New value for the property.

Returns

  • void
Modules.Facebook
( permissions )
Sets the value of the permissions property. ...

Sets the value of the permissions property.

Parameters

  • permissions : Array<String>

    New value for the property.

Returns

  • void
Modules.Facebook
( deviceToken )
Sets a device token to register the current application installation for push notifications. ...

Sets a device token to register the current application installation for push notifications.

  • 6.1.0
  • 6.1.0
  • 6.1.0

Parameters

  • deviceToken : String

    Device-token received when registering for push-notifications.

Returns

  • void
Modules.Facebook
( params )
Call this method to open Messenger and share an image, animated GIF or video. ...

Call this method to open Messenger and share an image, animated GIF or video.

  • 5.4.0
  • 5.4.0

Parameters

Returns

  • void
Defined By

Events

Modules.Facebook
Fired when the Invite dialog is closed. ...

Fired when the Invite dialog is closed.

  • 5.4.0
  • 5.4.0
  • 5.4.0

Properties

  • success : Boolean

    Returns true if request succeeded, false otherwise.

  • cancelled : Number

    Indicates if the user canceled the request by closing the dialog.

  • error : String

    Error message, if any returned. Will be undefined if success is true.

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Modules.Facebook
Fired at session login. ...

Fired at session login.

Properties

  • success : Boolean

    Indicates if the user was logged in successfully. Returns true if request succeeded, false otherwise.

  • cancelled : Number

    Indicates if the user canceled the login request by closing the dialog.

  • error : String

    Error message, if any returned. Will be undefined if success is true.

  • code : Number

    Error code. Error code will be 0 if success is true, nonzero otherwise. If the error was generated by the operating system, that system's error value is used. Otherwise, this value will be -1.

  • uid : String

    User ID returned by Facebook if the login was successful.

  • data : String

    Data returned by Facebook when we query for the UID (using graph path "me") after a successful login. Data is in JSON format, and includes information such as user name, locale and gender.

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Modules.Facebook
Fired at session logout. ...

Fired at session logout.

Properties

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Modules.Facebook
Fired when the Send Request dialog is closed. ...

Fired when the Send Request dialog is closed.

  • 4.0.2
  • 4.0.2
  • 4.0.2

Properties

  • success : Boolean

    Returns true if request succeeded, false otherwise.

  • cancelled : Number

    Indicates if the user canceled the request by closing the dialog.

  • error : String

    Error message, if any returned. Will be undefined if success is true.

  • data : Dictionary

    data returned by Facebook. See Facebook reference for details.

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Modules.Facebook
Fired when the Share dialog or Web Share dialog is closed. ...

Fired when the Share dialog or Web Share dialog is closed.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Properties

  • success : Boolean

    Returns true if request succeeded, false otherwise.

  • cancelled : Number

    Indicates if the user canceled the request by closing the dialog.

  • error : String

    Error message, if any returned. Will be undefined if success is true.

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •  
Modules.Facebook
Fired when refreshPermissionsFromServer is completed. ...

Fired when refreshPermissionsFromServer is completed.

  • 4.0.0
  • 4.0.0
  • 4.0.0

Properties

  • source : Object

    Source object that fired the event.

    •  
    •  
    •  
  • type : String

    Name of the event fired.

    •  
    •  
    •  
  • bubbles : Boolean

    True if the event will try to bubble up if possible.

    •  
    •  
    •  
  • cancelBubble : Boolean

    Set to true to stop the event from bubbling.

    •  
    •  
    •