Facebook photo uploading is not working when Fb app is already installed in the phone,its working fine when FB app is not installed in the phone as it calls the browser. i have posted my code please help me to resolve this issue
local facebook = require “facebook”
– You must use your own app id for this sample to work
local fbAppID = “123456789” --fake
local group=display.newGroup()
local img=display.newImageRect(group,“splash.png”,207/2,310/2)
img.x=display.contentCenterX;img.y=display.contentCenterY
baseDir=system.DocumentsDirectory
function share(event)
function saveimage()
display.save(group,“shareimg.jpg”)
end
timer.performWithDelay(500,saveimage)
local function onLoginSuccess()
– Upload ‘iheartcorona.jpg’ to current user’s account
local attachment = {
message = “First image sharing in fb”,
source = { baseDir=system.DocumentsDirectory, filename=“shareimg.jpg”, type=“image” }
}
facebook.request( “me/photos”, “POST”, attachment )
end
– facebook listener
local function fbListener( event )
if event.isError then
native.showAlert( “ERROR”, event.response, { “OK” } )
else
if event.type == “session” and event.phase == “login” then
– login was a success; call functions
onLoginSuccess()
elseif event.type == “request” then
– this block is executed upon successful facebook.request() call
native.showAlert( “Success”, “The photo has been uploaded.”, { “OK” } )
end
end
end
– photo uploading requires the “publish_stream” permission
facebook.login( fbAppID, fbListener, { “publish_stream” } )
end
img:addEventListener(“touch”,share)