Hey Rob,
here is my code.
The “already authenticated” dialog appears everytime I call e.g. the CheckPageLike() function, that checks if the user
likes a page on facebook.
On login I request the userdata first to get username (not needed here) and then calling the particular action (here the like page).
It seems that the facebook plugin does not buffer the users access token? Do I have to handle it my own?
But then the user get annoyed everytime he starts the application with the auth-dialog?
Thanks for yout help!
EDIT: Found out that if I do a login() without any permissions before calling any login with a permission, it works.
Maybe corona loads the already existing permissions on the first login?
So is it a possible solution to call the first login without any permissions, and then a second login inside the listener
depending the action I want to do?
-- Facebook Commands local fbCommand -- forward reference local LOGOUT = 1 local POST\_MSG = 2 local CHECK\_LIKE = 3 local fbUserRequest = false local callback = nil local user\_firstname = nil local user\_lastname = nil local user\_name = nil local like\_page\_id = "" local msg\_content = nil local FbHandling = {} ------------------------------------------------------------------------------- -- FUNCTIONS ------------------------------------------------------------------------------- -- -- Facebook listener -- local function listener(event) -- After a successful login event, get user information if ("session" == event.type) then if(event.phase == "login") then -- Request user information fbUserRequest = true facebook.request("me") end elseif("request" == event.type) then local response = event.response if(event.isError) then -- Error else response = json.decode( event.response ) -- If user request, get the data and send command if(fbUserRequest == true) then fbUserRequest = false -- Userdata user\_firstname = response.first\_name user\_lastname = response.last\_name user\_name = response.name if fbCommand == POST\_MSG then facebook.request("me/feed", "POST", {message=replaceWildCards(msg\_content)}) -- posting the message -- Check page like elseif fbCommand == CHECK\_LIKE then facebook.request("me/likes/"..like\_page\_id) -- check if user likes end elseif fbCommand == POST\_MSG then -- Message posted elseif fbCommand == CHECK\_LIKE then -- Check if user likes the page local data = response.data for i=1,#data do local name = data[i].name if data[i].id == like\_page\_id then -- Like if callback then callback(true) end return end end -- Like not if callback then callback(false) end else -- Unknown command response end end elseif("dialog" == event.type) then -- showDialog response end end -- -- Post on users wall: -- function FbHandling:PostMessage(msg) msg\_content = msg fbCommand = POST\_MSG facebook.login(appId, listener, {"publish\_actions"} ) end -- -- Check if user linkes the passed page. -- function FbHandling:CheckPageLike(page\_id, cb) callback = cb like\_page\_id = page\_id fbCommand = CHECK\_LIKE facebook.login(appId, listener, {"user\_likes"}) end -- -- Logout user explicit. -- function FbHandling:Logout(event) fbCommand = LOGOUT facebook.logout() end return FbHandling