facebook canShowPopup returns false on iOS7 (Social Plugin)

Hi,

I have a problem to make the social plugin work. I added plugin in build.settings, 

I’m on iOS7, have a fb account set up on a device, but when I call

local canFB = native.canShowPopup(“social”, “facebook”)

it returns false :frowning: So even without canShowPopup conditional, nothing happens when I call: 

native.showPopup( “social”, {

               service = “facebook”,

               listener = listener,

                message = “Check out these photos!”,

               image = {

                    filename = “screenCap.jpg”,

                  baseDir = system.TemporaryDirectory,

               }

            } )

Nothing appears in the console output either (apart from ‘canFB = false’). Any ideas what I’m missing here? Help :slight_smile:

If you go into the Settings app and scroll down to the Facebook entry.  Make sure you’re signed in there.  This isn’t the Facebook App, but the iOS sign in that lets the Facebook sharing from other apps work.

Rob

Hi @Rob, yes - I’m signed in. There’s my account data filled in and I could only delete it (there’s no sign-in button). I’m using pretty latest daily build, have updated facebook app and latest xcode 5.0.2 - canShowPopup still returns false 

here’s my code:

local function captureScreen()          local cap = display.captureScreen( true )             local saveOptions = {                 filename = "screenCap.jpg",                 baseDir = system.TemporaryDirectory,                 isFullResolution = true,             }             display.save( cap, saveOptions)             cap:removeSelf()             cap = nil;             saveOptions = nil end function fb:tap(e) if e.numTaps == 1 then captureScreen(); local function listener( event ) print( "name(" .. event.name .. ") type(" .. event.type .. ") action(" .. tostring(event.action) .. ") limitReached (" .. tostring(event.limitReached) .. ")" ) end local canFB = native.canShowPopup("social", "facebook") print("can show = ".. tostring(canFB)) native.showPopup( "social", { service = "facebook", listener = listener, message = "Check out these photos!", image = { filename = "screenCap.jpg", baseDir = system.TemporaryDirectory, } } ) end end fb:addEventListener("tap", fb);

In the console it just outputs: “can show = false”

What’s also curious, is that when I tap the fb button - the screen is captured and saved to camera roll, not to system.TemporaryDirectory. I use the exact same captureScreen() method for twitter and mail, and there it works like it should - just share via twitter/email and doesn’t save to camera roll.

and here’re my build settings:

settings = { android = { versionCode = "1" }, androidPermissions = { "android.permission.VIBRATE", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, iphone = { components = {}, plist = { CFBundleIconFiles = { "iTunesArtwork.png", "Icon.png", "Icon@2x.png", "Icon-40.png", "Icon-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png" }, UIPrerenderedIcon = true, UIStatusBarHidden = true, UILaunchImageFile = "Default", }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, }, orientation = { default = "portrait", supported = { "portraitUpsideDown", "portrait" } }, }, }

I don’t know what’s going on with the facebook save, but the reason your saving to the camera roll is the “true” that you’re passing to display.capture().  See the documentation:

http://docs.coronalabs.com/api/library/display/captureScreen.html

If you pass true, it will save it to the camera roll.

Rob

Ok, that’s right. Thanks but my main concern is why it doesn’t post to facebook :frowning:

do I need to register my app on fb to be able to use the Social Plugin?

I tested the app on iOS6 - it’s the same, it returns false for canShowPopup

I’ll ask engineering and see if they know any reasons why it would return false.  I don’t believe that you need anything setup with facebook for this.

Rob

Thanks @Rob, I appreciate. Let me know if they come up with the solution, please.

Hey @Rob, I fixed it. I moved a plugins table code on the top of a settings table in build.settings file. When it’s at the first place - before Android or iPhone settings, then social plugin works fine. If I move it down in the table (exact same code) - it doesn’t load the plugin library. Strange thing :slight_smile: Anyway, it works now.

This works fine:

settings = { plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, }, android = { versionCode = "1" }, androidPermissions = { "android.permission.VIBRATE", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, iphone = { components = {}, plist = { UIAppFonts = { "Moon Flower Bold.ttf", }, CFBundleIconFiles = { "iTunesArtwork.png", "Icon.png", "Icon@2x.png", "Icon-40.png", "Icon-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png" }, UIPrerenderedIcon = true, UIStatusBarHidden = true, UILaunchImageFile = "Default", }, orientation = { default = "portrait", supported = { "portraitUpsideDown", "portrait" } }, }, }

this doesn’t work:

settings = { android = { versionCode = "1" }, androidPermissions = { "android.permission.VIBRATE", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, iphone = { components = {}, plist = { UIAppFonts = { "Moon Flower Bold.ttf", }, CFBundleIconFiles = { "iTunesArtwork.png", "Icon.png", "Icon@2x.png", "Icon-40.png", "Icon-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png" }, UIPrerenderedIcon = true, UIStatusBarHidden = true, UILaunchImageFile = "Default", }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, }, orientation = { default = "portrait", supported = { "portraitUpsideDown", "portrait" } }, }, }

Ah!  Then there is likely an error in your build.settings file further down that was causing it to stop parsing.  If you have lua installed locally you can do:

lua build.settings

and if there are syntax errors, it should give you an error. 

Rob

could you tell me how can I check it in sublime text? I’m testing corona editor now

I don’t know of a way using sublime text other than using your eye’s to look for problems.  I took yours and it didn’t have any syntax errors, so there is something besides a syntax error tricking it out.

I don’t know a good way to identify that.

Rob

Me neither :slight_smile: You mentioned lua installotion so I thought you were saying about some particullar lua sdk or sth. Before sublime text I’ve been using eclipse koneki for lua and it instantly showed when a syntax error appeared. But it didn’t give me any errors in this build settings file. Anyway, I’ll just leave it on the top of the table. Thanks for your help

BTW: do you know if there is a way in Corona Editor to check if there weren’t accidentally any global variables left (due to local name typo’es in local registrations etc). Eclipse highlighted them with a bold font, but in sublime text there’s no visually difference between locals and globals

You can also just paste your build.settings into main.lua and that should tell if if there are any syntax errors.

thanks @dchan, I changed the extension, but your idea is easier :slight_smile: Anyway - it didn’t show me any syntax errors, so it’s magic! :slight_smile:

If you go into the Settings app and scroll down to the Facebook entry.  Make sure you’re signed in there.  This isn’t the Facebook App, but the iOS sign in that lets the Facebook sharing from other apps work.

Rob

Hi @Rob, yes - I’m signed in. There’s my account data filled in and I could only delete it (there’s no sign-in button). I’m using pretty latest daily build, have updated facebook app and latest xcode 5.0.2 - canShowPopup still returns false 

here’s my code:

local function captureScreen()          local cap = display.captureScreen( true )             local saveOptions = {                 filename = "screenCap.jpg",                 baseDir = system.TemporaryDirectory,                 isFullResolution = true,             }             display.save( cap, saveOptions)             cap:removeSelf()             cap = nil;             saveOptions = nil end function fb:tap(e) if e.numTaps == 1 then captureScreen(); local function listener( event ) print( "name(" .. event.name .. ") type(" .. event.type .. ") action(" .. tostring(event.action) .. ") limitReached (" .. tostring(event.limitReached) .. ")" ) end local canFB = native.canShowPopup("social", "facebook") print("can show = ".. tostring(canFB)) native.showPopup( "social", { service = "facebook", listener = listener, message = "Check out these photos!", image = { filename = "screenCap.jpg", baseDir = system.TemporaryDirectory, } } ) end end fb:addEventListener("tap", fb);

In the console it just outputs: “can show = false”

What’s also curious, is that when I tap the fb button - the screen is captured and saved to camera roll, not to system.TemporaryDirectory. I use the exact same captureScreen() method for twitter and mail, and there it works like it should - just share via twitter/email and doesn’t save to camera roll.

and here’re my build settings:

settings = { android = { versionCode = "1" }, androidPermissions = { "android.permission.VIBRATE", "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", }, iphone = { components = {}, plist = { CFBundleIconFiles = { "iTunesArtwork.png", "Icon.png", "Icon@2x.png", "Icon-40.png", "Icon-40@2x.png", "Icon-60.png", "Icon-60@2x.png", "Icon-72.png", "Icon-72@2x.png", "Icon-76.png", "Icon-76@2x.png", "Icon-Small-50.png", "Icon-Small-50@2x.png", "Icon-Small.png", "Icon-Small@2x.png" }, UIPrerenderedIcon = true, UIStatusBarHidden = true, UILaunchImageFile = "Default", }, plugins = { -- key is the name passed to Lua's 'require()' ["CoronaProvider.native.popup.social"] = { -- required publisherId = "com.coronalabs", }, }, orientation = { default = "portrait", supported = { "portraitUpsideDown", "portrait" } }, }, }

I don’t know what’s going on with the facebook save, but the reason your saving to the camera roll is the “true” that you’re passing to display.capture().  See the documentation:

http://docs.coronalabs.com/api/library/display/captureScreen.html

If you pass true, it will save it to the camera roll.

Rob

Ok, that’s right. Thanks but my main concern is why it doesn’t post to facebook :frowning:

do I need to register my app on fb to be able to use the Social Plugin?

I tested the app on iOS6 - it’s the same, it returns false for canShowPopup

I’ll ask engineering and see if they know any reasons why it would return false.  I don’t believe that you need anything setup with facebook for this.

Rob

Thanks @Rob, I appreciate. Let me know if they come up with the solution, please.