Yea i`m doing that on organize and stuffs…
here is my code of building
settings = { -- enable the admob plugin plugins = { ["CoronaProvider.ads.admob"] = { -- required publisherId = "com.coronalabs", }, -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, ["facebook"] = { publisherId = "com.coronalabs", supportedPlatforms = { iphone = true }, }, }, orientation = { default = "landscapeRight", supported = { "landscapeRight", "landscapeLeft" }, }, iphone = { plist = { CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small.png", "Icon-Small@2x.png", "Icon-40.png", "Icon-40@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", }, UIApplicationExitsOnSuspend = false, FacebookAppID = "1389442937944862", --replace XXXXXXXXXX with your Facebook App ID CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1389442937944862", } --replace XXXXXXXXXX with your Facebook App ID } } } }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.VIBRATE", }, }, }
and my code to logIn and try some request:
------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() ------------------------------------------- local ragdogLib = require "ragdogLib"; local json = require( "json" ); local facebook = require( "facebook" ); local fbAppID = "1389442937944862" ------------------------------------------- -- Variaveis local bg local timerT local centerX = \_G.centerX local centerY = \_G.centerY local totalWidth = \_G.totalWidth local totalHeight = \_G.totalHeight local leftSide = \_G.leftSide local rightSide = \_G.rightSide local topSide = \_G.topSide local bottomSide = \_G.bottomSide ------------------------------------------- -- Funções local mudaCena = function() local options = { effect = "fade", time = 500, params = { var1 = "testeFacebook", var2 = "mainMenu", } } storyboard.gotoScene( "destroiCenaAnterior", options ); end -- Compartilhar local postaSocial = function( nome ) local isAvailable = native.canShowPopup( 'social', nome ); -- If it is possible to show the popup if isAvailable then local listener = {} function listener:popup( event ) --print( "name(" .. event.name .. ") type(" .. event.type .. ") action(" .. tostring(event.action) .. ") limitReached(" .. tostring(event.limitReached) .. ")" ) if tostring(event.action) == 'sent' then print( 'ENVIOU ENVIOU ENVIOU' ) end end -- Show the popup native.showPopup( 'social', { service = nome, -- The service key is ignored on Android. message = "Test", listener = listener, --[[image = { { filename = "fotoSS.png", baseDir = system.DocumentsDirectory }, }, url ={ "https://play.google.com/store/search?q=bee%20flappy&c=apps&hl=pt\_BR" }]]-- }); else native.showAlert( "Cannot send " .. nome .. " message.", "Please setup your " .. nome .. " account or check your network connection", { "OK" } ) end end -- Facebook Requests local comecaFb = function() ----------------------------------------------------------------- local function FBlistener( event ) print( "event.name", event.name ) --"fbconnect" print( "event.type:", event.type ) --type is either "session", "request", or "dialog" print( "isError: " .. tostring( event.isError ) ) print( "didComplete: " .. tostring( event.didComplete ) ) --"session" events cover various login/logout events --"request" events handle calls to various Graph API calls --"dialog" events are standard popup boxes that can be displayed if ( "session" == event.type ) then --options are: "login", "loginFailed", "loginCancelled", or "logout" if ( "login" == event.phase ) then local access\_token = event.token --code for tasks following a successful login end elseif ( "request" == event.type ) then print("facebook request") if ( not event.isError ) then local response = json.decode( event.response ) --process response data here print( response ) end elseif ( "dialog" == event.type ) then print( "dialog", event.response ) --handle dialog results here end end ----------------------------------------------------------------- facebook.login( fbAppID, FBlistener, { "publish\_actions, users\_like" } ) ----------------------------------------------------------------- local fbBtnShare2 = ragdogLib.newSimpleButton( grupoShare, "IMG/shareIMG/fbIcone.png", 45, 45); fbBtnShare2.x, fbBtnShare2.y = centerX - 150, centerY - 15; function fbBtnShare2:touchBegan() self:setFillColor(.5, .5, .5); self.xScale, self.yScale = .9, .9; end function fbBtnShare2:touchEnded() --audio.play(buttonSFX, {channel = audio.findFreeChannel()}); self:setFillColor(1, 1, 1); self.xScale, self.yScale = 1, 1; facebook.request( "me/feed", FBlistener ,"POST", { message = "teste" } ) end facebook.request( "me/feed", "POST", { message="teste" } ) end ------------------------------------------- function scene:createScene( event ) local screenGroup = self.view; local fbBtnShare = ragdogLib.newSimpleButton( grupoShare, "IMG/shareIMG/fbIcone.png", 45, 45); fbBtnShare.x, fbBtnShare.y = centerX + 50, centerY - 15; function fbBtnShare:touchBegan() self:setFillColor(.5, .5, .5); self.xScale, self.yScale = .9, .9; end function fbBtnShare:touchEnded() --audio.play(buttonSFX, {channel = audio.findFreeChannel()}); self:setFillColor(1, 1, 1); self.xScale, self.yScale = 1, 1; local var = 'facebook'; postaSocial( var ); end end ------------------------------------------- -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) comecaFb() end ------------------------------------------- function scene:exitScene( event ) -- end ------------------------------------------- -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- bg = nil timerT = nil centerX = nil centerY = nil totalWidth = nil totalHeight = nil leftSide = nil rightSide = nil topSide = nil bottomSide = nil end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) --------------------------------------------------------------------------------- return scene