Social popup doesn't work with screenshot !

I tested with social popup, It worked perfectly with message,url and image with “icon.png” in source.

The sample code below

https://github.com/coronalabs/plugins-sample-native-popup-social/

But when I used display.save( background,“share.jpg”, system.DocumentsDirectory ) I used “share.jpg”  instead of using “icon.png”. The result is worked but the photo is empty. Anyone can help me? Thanks

Can you post your code where you’re calling native.showPopup()?

Make sure to click the <> in the editing bar with B I U and so on.

Rob

Did you add a delay between the screenshot and the post?  You may need a few milliseconds for it to work.

Ex (pseudo code): 

  1. Snap shot

  2. timer.performWithDelay( post )

I only changed some red code from source code.

https://github.com/coronalabs/plugins-sample-native-popup-social/

local function onShareButtonReleased( event ) &nbsp;&nbsp; &nbsp;local serviceName = event.target.id &nbsp;&nbsp; &nbsp;local isAvailable = native.canShowPopup( popupName, serviceName ) &nbsp;&nbsp; &nbsp;-- For demonstration purposes, we set isAvailable to true here for Android. &nbsp;&nbsp; &nbsp;if "Android" == system.getInfo( "platformName" ) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;isAvailable = true &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;-- If it is possible to show the popup &nbsp;&nbsp; &nbsp;if isAvailable then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local listener = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;function listener:popup( event ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print( "name(" .. event.name .. ") type(" .. event.type .. ") action(" .. tostring(event.action) .. ") limitReached(" .. tostring(event.limitReached) .. ")" )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local options = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.service = serviceName &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.listener = listener &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendMessage then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.message = "I saved the planet using Corona SDK" &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendURL then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.url = { "http://www.coronalabs.com" } &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendImage then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.image = { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ filename = "share.jpg", baseDir = system.ResourceDirectory }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Show the popup &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showPopup( popupName, options ) &nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if isSimulator then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showAlert( "Build for device", "This plugin is not supported on the Corona Simulator, please build for an iOS/Android device or the Xcode simulator", { "OK" } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Popup isn't available.. Show error message &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showAlert( "Cannot send " .. serviceName .. " message.", "Please setup your " .. serviceName .. " account or check your network connection (on android this means that the package/app (ie Twitter) is not installed on the device)", { "OK" } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;end end local function onSwitchPress( event ) &nbsp;&nbsp;&nbsp; local switch = event.target &nbsp;&nbsp;&nbsp; print( "Switch with ID '"..switch.id.."' is on: "..tostring(switch.isOn) ) &nbsp;&nbsp;&nbsp; if switch.id == "message" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendMessage = switch.isOn &nbsp;&nbsp;&nbsp; elseif switch.id == "url" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendURL = switch.isOn &nbsp;&nbsp;&nbsp; elseif switch.id == "image" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendImage = switch.isOn &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;display.save( background,"share.jpg", system.DocumentsDirectory ) &nbsp;&nbsp;&nbsp; end end
  1. Please format all code posts when posting to the forums.

formatyourcode.jpg

  1.  So, you didn’t add a delay.  Well try it.  i.e. Give the app time to actually save the file.  You probably need to give it a few frames to get stored before trying to read and send it.

That example isn’t really designed to be used the way you’re trying to use it.  However it is doable.

Start with the ORIGINAL code and REPLACE just this part:

 if sendImage then display.save( background,"share.jpg", system.DocumentsDirectory ) -- ROAMING GAMER options.image = { { filename = "share.jpg", baseDir = system.DocumentsDirectory }, -- ROAMING GAMER } end -- ROAMING GAMER timer.performWithDelay( 100, function() native.showPopup( popupName, options ) end ) 

I marked the lines I changed with ‘-- ROAMING GAMER’

Thanks roaming gamer. Like a miracle it worked !!!

Miracles are Rob’s department.   :wink:

I know Rob, bad joke… but the setup was there. 

*snicker*

Can you post your code where you’re calling native.showPopup()?

Make sure to click the <> in the editing bar with B I U and so on.

Rob

Did you add a delay between the screenshot and the post?  You may need a few milliseconds for it to work.

Ex (pseudo code): 

  1. Snap shot

  2. timer.performWithDelay( post )

I only changed some red code from source code.

https://github.com/coronalabs/plugins-sample-native-popup-social/

local function onShareButtonReleased( event ) &nbsp;&nbsp; &nbsp;local serviceName = event.target.id &nbsp;&nbsp; &nbsp;local isAvailable = native.canShowPopup( popupName, serviceName ) &nbsp;&nbsp; &nbsp;-- For demonstration purposes, we set isAvailable to true here for Android. &nbsp;&nbsp; &nbsp;if "Android" == system.getInfo( "platformName" ) then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;isAvailable = true &nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;-- If it is possible to show the popup &nbsp;&nbsp; &nbsp;if isAvailable then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local listener = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;function listener:popup( event ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;print( "name(" .. event.name .. ") type(" .. event.type .. ") action(" .. tostring(event.action) .. ") limitReached(" .. tostring(event.limitReached) .. ")" )&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;local options = {} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.service = serviceName &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.listener = listener &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendMessage then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.message = "I saved the planet using Corona SDK" &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendURL then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.url = { "http://www.coronalabs.com" } &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if sendImage then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;options.image = { &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{ filename = "share.jpg", baseDir = system.ResourceDirectory }, &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Show the popup &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showPopup( popupName, options ) &nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if isSimulator then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showAlert( "Build for device", "This plugin is not supported on the Corona Simulator, please build for an iOS/Android device or the Xcode simulator", { "OK" } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;else &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;-- Popup isn't available.. Show error message &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;native.showAlert( "Cannot send " .. serviceName .. " message.", "Please setup your " .. serviceName .. " account or check your network connection (on android this means that the package/app (ie Twitter) is not installed on the device)", { "OK" } ) &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;end &nbsp;&nbsp; &nbsp;end end local function onSwitchPress( event ) &nbsp;&nbsp;&nbsp; local switch = event.target &nbsp;&nbsp;&nbsp; print( "Switch with ID '"..switch.id.."' is on: "..tostring(switch.isOn) ) &nbsp;&nbsp;&nbsp; if switch.id == "message" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendMessage = switch.isOn &nbsp;&nbsp;&nbsp; elseif switch.id == "url" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendURL = switch.isOn &nbsp;&nbsp;&nbsp; elseif switch.id == "image" then &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sendImage = switch.isOn &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;display.save( background,"share.jpg", system.DocumentsDirectory ) &nbsp;&nbsp;&nbsp; end end
  1. Please format all code posts when posting to the forums.

formatyourcode.jpg

  1.  So, you didn’t add a delay.  Well try it.  i.e. Give the app time to actually save the file.  You probably need to give it a few frames to get stored before trying to read and send it.

That example isn’t really designed to be used the way you’re trying to use it.  However it is doable.

Start with the ORIGINAL code and REPLACE just this part:

 if sendImage then display.save( background,"share.jpg", system.DocumentsDirectory ) -- ROAMING GAMER options.image = { { filename = "share.jpg", baseDir = system.DocumentsDirectory }, -- ROAMING GAMER } end -- ROAMING GAMER timer.performWithDelay( 100, function() native.showPopup( popupName, options ) end ) 

I marked the lines I changed with ‘-- ROAMING GAMER’

Thanks roaming gamer. Like a miracle it worked !!!

Miracles are Rob’s department.   :wink:

I know Rob, bad joke… but the setup was there. 

*snicker*