Here is what I did and it took the picture from the camera but returned back to the main screen to tap to launch the camera. It did not show the Facebook login part. Why?
-----------------------------------------------------------------------------------------
--
-- main.lua
--
-----------------------------------------------------------------------------------------
-- Your code here
local facebook = require "facebook"
local appId = "12434435235325432543254"
local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 128, 0, 0 )
local text = display.newText( "Tap anywhere to launch Camera", 0, 0, nil, 16 )
text:setTextColor( 255, 255, 255 )
text.x = 0.5 \* display.contentWidth
text.y = 0.5 \* display.contentHeight
local onComplete = function(event)
local photo = event.target
photo.isVisible = false
facebook.login( appId, fbListener, { "publish\_stream" } )
end
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 function
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
local function onLoginSuccess()
-- Upload 'iheartcorona.jpg' to current user's account
local attachment = {
message = "Just a description of the photo.",
source = { baseDir=system.ResourceDirectory, filename="picture1.jpg", type="image" }
}
facebook.request( "me/photos", "POST", attachment )
end
local listener = function( event )
if media.hasSource( media.Camera ) then
media.show( media.Camera, onComplete,{ baseDir=system.ResourceDirectory, filename="picture1.jpg", type="image" } )
else
native.showAlert("Corona", "Camera not found.")
end
return true
end
bkgd:addEventListener( "tap", listener )
[import]uid: 184193 topic_id: 32551 reply_id: 130062[/import]