Hi all,
I get trouble in using Facebook plugins. The problem will be explain in cases below:
1. In this case, the game ask for facebook permission right on start screen (or splash screen)
--on game.lua
if application:getDeviceInfo() == "Android" then
require "facebook"
facebook:addEventListener(Event.LOGIN_COMPLETE, function()
print("login successful")
facebook:extendAccessTokenIfNeeded()
end)
facebook:setAppId("624491254238494");
facebook:authorize();
end
--after that, on share button click we check facebook:isSessionValid() then call facebook:dialog("feed", {}) |
2. In this case, when we click Share button, the game ask for facebook permission then crash, start the game and click again, facebook feed dialog appear.
--on share button click we call everything
local function onClick()
require "facebook"
facebook:addEventListener(Event.LOGIN_COMPLETE, function()
print("login successful")
facebook:extendAccessTokenIfNeeded()
end)
facebook:setAppId("624491254238494");
facebook:authorize();
if facebook:isSessionValid() then
facebook:dialog("feed", {})
end
end |
=> I want: when we click Share button, if this is the first time, facebook ask for permission, then call feed dialog. Next time, only feed dialog appear.
What event I need to check when permission is granted, or facebook:authorize() is success?
Comments
Sorry I am still too busy to test it, so I should ask before fixing so I may save my time.
Ultimate Games on Appstore
Ultimate Games on Google Play
Firstly you need to require "facebook" somewhere globally and not everytime you need it.
And isn't facebook always already authorized in second case after game.lua?