Type Function Return value Event Revision Release 2024.3703 Keywords Facebook, showDialog See also facebook.login() facebook.* fbconnect
Displays an interactive Facebook UI dialog for publishing posts to a user's stream, inviting friends to your app, etc. Use facebook.request() if you need the application itself to do the posting.
The response from the dialog comes back in the form of a fbconnect event that is sent to the listener specified within facebook.init() or facebook.setFBConnectListener().
facebook.showDialog( action, params )
String. The dialog you want to show. Valid options include:
"feed"
— Opens the Share Dialog in Feed mode."link"
— Corresponds to the Share Dialog."photo"
— Corresponds to the Share Dialog."requests"
— Corresponds to the Game Requests Dialog.Table. Lua table of
Displays a native view which allows the user to send game requests to their choice of friends. For this dialog, action
should be "requests"
.
To use this, be sure that your app is categorized as a game in the Facebook Developer Portal.
On iOS, for a game request to go through to the desired recipient, you must ensure that iPhone and/or iPad Store ID fields in the Facebook Developer Portal are filled out. See the Facebook Portal Setup guide for more info.
For this dialog, the params
table can contain the following
to
— String value for the user ID of the person to send this request to.title
— String value for the title of the dialog.message
— String value for a message to be sent along with the game request.suggestions
— Table containing the user IDs of suggested friends for this game request.data
— String value for additional data to attach to the post.objectId
— String value for the Open Graph object ID of the object being sent.actionType
— String value for defining additional context about the nature of the request. By default, no action type is used. Supported actionType
values include:
"SEND"
— The user is sending an object to friends. Requires an objectId
to also be provided. Maps to the gifting and social trading scenario."ASKFOR"
— The user is asking for an object from friends. Requires an objectId
to also be provided. Maps to the asking for help scenario."TURN"
— It is the turn of the friends to play against the user in a match. An objectId
should not be provided in this case. Maps to the turn-based games scenario.filter
— String value for a filter on who can be displayed in the filter
values include:
"APP_USERS"
— Only friends who use the app will be displayed."APP_NON_USERS"
— Only friends who do not use the app will be displayed. Maps to the invites scenario.local facebook = require( "plugin.facebook.v4a" ) local function facebookListener( event ) if ( "fbinit" == event.name ) then print( "Facebook initialized" ) facebook.login() elseif ( "fbconnect" == event.name ) then if ( "session" == event.type ) then -- Handle login event if ( "login" == event.phase ) then facebook.showDialog( "requests", { message = "You should download this game!", filter = "APP_NON_USERS" }) end elseif ( "dialog" == event.type ) then -- Handle dialog event print( event.response ) end end end -- Set the "fbinit" listener to be triggered when initialization is complete facebook.init( facebookListener )