Posting screenshot on Facebook makes app crash

Hi there, I need help to solve this problem: I want to post on FB a save screen from my app (I got save screen by using display.save function). Everything works fine on Android while on my iPad it makes app crash! 

I tested on two iPAD, one with native FB app installed and one with no FB app installed. It crashes in both devices.

Please find the function code below:

local function postonFB( event)

display.save( tab3fields, { filename=“ticket.jpg”, baseDir=system.DocumentsDirectory, isFullResolution=true, backgroundColor={0, 0, 0, 0} } )

local fbAppID = “4531113981XXXXX” 
local function fbListener( event )
if event.phase == “login” then
local attachment = {
message=“I am a champion!”,
source= {baseDir=system.DocumentsDirectory, filename=“ticket.jpg”, type=“image”}
}

facebook.request(“me/photos”, “POST”, attachment)
native.showAlert(“Facebook”, “Submitted!”)
end
end

– photo uploading requires the “publish_actions” permission
facebook.login( fbAppID, fbListener, { “publish_actions” } )
end

I connected my iPAD to Xcode and i got this log errors: Jun 17 08:28:15 iPad-di-Ubaldo lineitup[1795] <Error>: *** Terminating app due to uncaught exception ‘com.facebook.sdk:InvalidOperationException’, reason: ‘FBSession: No AppID provided; either pass an AppID to init, or add a string valued key with the appropriate id named FacebookAppID to the bundle *.plist’ I think I pass all the info requested but for some reasons FB does not get them…:( –

Hi @u.baldi,

Please read through the entire guide on “Implementing Facebook”, especially the sections on iOS requirements:

https://docs.coronalabs.com/guide/social/implementFacebook/index.html

Take care,

Brent

Hi Brent, I double checked the build.settings and nothing seems to be different from what is shown on the link page you provided. I still get the same error from Apple:

un 24 08:25:46 iPad-di-Ubaldo lineitup[2366] <Error>: *** Terminating app due to uncaught exception ‘com.facebook.sdk:InvalidOperationException’, reason: ‘FBSession: No AppID provided; either pass an AppID to init, or add a string valued key with the appropriate id named FacebookAppID to the bundle *.plist’

Following is the build.settings Iphone section:

iphone =

{

plist =

{

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

UIAppFonts = { “RepriseStamp.ttf”, “REPRISESTAMP.dfont”},

CFBundleIconFiles =

{

“Icon.png”,

“Icon@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-60@3x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small@3x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

},

{

            UIApplicationExitsOnSuspend = false,

            FacebookAppID = “453111398192113”,  --replace XXXXXXXXXX with your Facebook App ID

            CFBundleURLTypes =

            {

                { CFBundleURLSchemes = { “fb453111398192113”, } }  --fb app id XXXXXXXXXX with your 

            },

            --UIRequiredDeviceCapabilities =

            – {

            –        “armv7”

            –    },

            --[“URL types”] =

            --{

            –    item =

            –    {

            –        [“URL Schemes”] = { [“Item 0”] = “fb453111398192113” },  --replace FB app

            –    },

            --},

        }

}

},

I really do not understand what is wrong! On Android it works, so I guess that main.lua code is right, isn’t it?Proble should be in build.settings but where?Thanks for your patience.

ub

Hi @u.baldi,

Can you surround that with “lua” or “code” tags, and clearly show how you’ve indented your tables? I think you may have put the Facebook details inside another table within “plist” which would be incorrect.

[lua] -- [/lua]

On that note, you should really read this tutorial on how to properly set up and “nest” tables within build.settings:

http://coronalabs.com/blog/2014/07/08/tutorial-understanding-build-settings/

Brent

Hi Brent, thanks for helping me.  I am still checking the code and I am pretty sure that I get the error while attempting the Facebook login, so definitely before I generate save screen or try to post it. Please find below the entire build.settings between “lua” tags:

[lua]

settings =

{

orientation =

{

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

default = “portrait”,

supported = { “portrait”, }

},

excludeFiles =

{

– Include only the necessary icon files on each platform

iphone = { “Icon-*dpi.png”, },

android = { “Icon.png”, “Icon-Small-*.png”, “Icon*@2x.png”, },

},

    plugins =

{

        [“CoronaProvider.native.popup.social”] =

        {

            publisherId = “com.coronalabs”

        },

        [“plugin.notifications”] =

        {

            publisherId = “com.coronalabs”,

        },

  

        [“facebook”] =

        {

            publisherId = “com.coronalabs”,

        },

    },

– iOS Section

iphone =

{

plist =

{

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

UIAppFonts = { “RepriseStamp.ttf”, “REPRISESTAMP.dfont”},

CFBundleIconFiles =

{

“Icon.png”,

“Icon@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-60@3x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small@3x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

},

{

            UIApplicationExitsOnSuspend = false,

            FacebookAppID = “453111398192113”,  --replace XXXXXXXXXX with your Facebook App ID

            CFBundleURLTypes =

            {

                { CFBundleURLSchemes = { “fb453111398192113”, } }  --fb app id XXXXXXXXXX with your 

            },

            --UIRequiredDeviceCapabilities =

            – {

            –        “armv7”

            –    },

            --[“URL types”] =

            --{

            –    item =

            –    {

            –        [“URL Schemes”] = { [“Item 0”] = “fb453111398192113” },  --replace FB app

            –    },

            --},

        }

}

},

– Android Section

android =

{

permissions =

        {

            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },

        },

usesPermissions =

{

“android.permission.WRITE_EXTERNAL_STORAGE”,

“android.permission.INTERNET”,

“android.permission.GET_ACCOUNTS”,

            “android.permission.RECEIVE_BOOT_COMPLETED”,

            “com.google.android.c2dm.permission.RECEIVE”,

            “.permission.C2D_MESSAGE”,

},

},

}

[/lua]

Hi again Brent, just checked indentation as you suggested and it worked! :). AS you understood it was a problem on build.settings. However I still have a  problem… now, after posting the saves screen,  I get the native alert popup with “Facebook submitted” and the app remain stucked on it…shall I putt a button to make native alert disappear?

Thanks again Brent!

ub

Hi @ub,

Do you get any error messages in the console output? 

HI Brent, no I don’t. But I’ve just inserted a native.CancelAlert after the Alert to remove it and everything works properly! Great! Moreover I’ve just realized that there is a new issue when I installed the app on iPAD where I do not have FB application installed. In this case when the app logs in Facebook a web browser open a new window and I get the message: “The app is still in development mode, and you don’t have access to it.Switch to a registered test user or ask an app admin for permissions.”. What shall I do?

Thanks again Brent, you gave me a really big help!

ub

Hi ub,

At this time it may be helpful to read the tutorial on FB authentication and the subtle differences around it:

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Brent

Hi @u.baldi,

Please read through the entire guide on “Implementing Facebook”, especially the sections on iOS requirements:

https://docs.coronalabs.com/guide/social/implementFacebook/index.html

Take care,

Brent

Hi Brent, I double checked the build.settings and nothing seems to be different from what is shown on the link page you provided. I still get the same error from Apple:

un 24 08:25:46 iPad-di-Ubaldo lineitup[2366] <Error>: *** Terminating app due to uncaught exception ‘com.facebook.sdk:InvalidOperationException’, reason: ‘FBSession: No AppID provided; either pass an AppID to init, or add a string valued key with the appropriate id named FacebookAppID to the bundle *.plist’

Following is the build.settings Iphone section:

iphone =

{

plist =

{

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

UIAppFonts = { “RepriseStamp.ttf”, “REPRISESTAMP.dfont”},

CFBundleIconFiles =

{

“Icon.png”,

“Icon@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-60@3x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small@3x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

},

{

            UIApplicationExitsOnSuspend = false,

            FacebookAppID = “453111398192113”,  --replace XXXXXXXXXX with your Facebook App ID

            CFBundleURLTypes =

            {

                { CFBundleURLSchemes = { “fb453111398192113”, } }  --fb app id XXXXXXXXXX with your 

            },

            --UIRequiredDeviceCapabilities =

            – {

            –        “armv7”

            –    },

            --[“URL types”] =

            --{

            –    item =

            –    {

            –        [“URL Schemes”] = { [“Item 0”] = “fb453111398192113” },  --replace FB app

            –    },

            --},

        }

}

},

I really do not understand what is wrong! On Android it works, so I guess that main.lua code is right, isn’t it?Proble should be in build.settings but where?Thanks for your patience.

ub

Hi @u.baldi,

Can you surround that with “lua” or “code” tags, and clearly show how you’ve indented your tables? I think you may have put the Facebook details inside another table within “plist” which would be incorrect.

[lua] -- [/lua]

On that note, you should really read this tutorial on how to properly set up and “nest” tables within build.settings:

http://coronalabs.com/blog/2014/07/08/tutorial-understanding-build-settings/

Brent

Hi Brent, thanks for helping me.  I am still checking the code and I am pretty sure that I get the error while attempting the Facebook login, so definitely before I generate save screen or try to post it. Please find below the entire build.settings between “lua” tags:

[lua]

settings =

{

orientation =

{

– Supported values for orientation:

– portrait, portraitUpsideDown, landscapeLeft, landscapeRight

default = “portrait”,

supported = { “portrait”, }

},

excludeFiles =

{

– Include only the necessary icon files on each platform

iphone = { “Icon-*dpi.png”, },

android = { “Icon.png”, “Icon-Small-*.png”, “Icon*@2x.png”, },

},

    plugins =

{

        [“CoronaProvider.native.popup.social”] =

        {

            publisherId = “com.coronalabs”

        },

        [“plugin.notifications”] =

        {

            publisherId = “com.coronalabs”,

        },

  

        [“facebook”] =

        {

            publisherId = “com.coronalabs”,

        },

    },

– iOS Section

iphone =

{

plist =

{

UIStatusBarHidden = false,

UIPrerenderedIcon = true, – set to false for “shine” overlay

–UIApplicationExitsOnSuspend = true, – uncomment to quit app on suspend

UIAppFonts = { “RepriseStamp.ttf”, “REPRISESTAMP.dfont”},

CFBundleIconFiles =

{

“Icon.png”,

“Icon@2x.png”,

“Icon-60.png”,

“Icon-60@2x.png”,

“Icon-60@3x.png”,

“Icon-72.png”,

“Icon-72@2x.png”,

“Icon-76.png”,

“Icon-76@2x.png”,

“Icon-Small.png”,

“Icon-Small@2x.png”,

“Icon-Small@3x.png”,

“Icon-Small-40.png”,

“Icon-Small-40@2x.png”,

“Icon-Small-50.png”,

“Icon-Small-50@2x.png”,

},

{

            UIApplicationExitsOnSuspend = false,

            FacebookAppID = “453111398192113”,  --replace XXXXXXXXXX with your Facebook App ID

            CFBundleURLTypes =

            {

                { CFBundleURLSchemes = { “fb453111398192113”, } }  --fb app id XXXXXXXXXX with your 

            },

            --UIRequiredDeviceCapabilities =

            – {

            –        “armv7”

            –    },

            --[“URL types”] =

            --{

            –    item =

            –    {

            –        [“URL Schemes”] = { [“Item 0”] = “fb453111398192113” },  --replace FB app

            –    },

            --},

        }

}

},

– Android Section

android =

{

permissions =

        {

            { name = “.permission.C2D_MESSAGE”, protectionLevel = “signature” },

        },

usesPermissions =

{

“android.permission.WRITE_EXTERNAL_STORAGE”,

“android.permission.INTERNET”,

“android.permission.GET_ACCOUNTS”,

            “android.permission.RECEIVE_BOOT_COMPLETED”,

            “com.google.android.c2dm.permission.RECEIVE”,

            “.permission.C2D_MESSAGE”,

},

},

}

[/lua]

Hi again Brent, just checked indentation as you suggested and it worked! :). AS you understood it was a problem on build.settings. However I still have a  problem… now, after posting the saves screen,  I get the native alert popup with “Facebook submitted” and the app remain stucked on it…shall I putt a button to make native alert disappear?

Thanks again Brent!

ub

Hi @ub,

Do you get any error messages in the console output? 

HI Brent, no I don’t. But I’ve just inserted a native.CancelAlert after the Alert to remove it and everything works properly! Great! Moreover I’ve just realized that there is a new issue when I installed the app on iPAD where I do not have FB application installed. In this case when the app logs in Facebook a web browser open a new window and I get the message: “The app is still in development mode, and you don’t have access to it.Switch to a registered test user or ask an app admin for permissions.”. What shall I do?

Thanks again Brent, you gave me a really big help!

ub

Hi ub,

At this time it may be helpful to read the tutorial on FB authentication and the subtle differences around it:

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

Brent