Facebook listener close the app

I want to make it possible to post image to facebook in my app. I tried social plugin, but it did not work unless I just posted an URL and a picture from the URL. So i tried facebook plugin, but i got stuck really fast. When i called on the facebookListener the app just closed. I am very new to corona and this is my first app so it can be something obvious, but i have tried to get it to work for 2 days now.

Here is my main.lua file:

local facebook = require(“facebook”)

local fbAppID = “438465966325354”

local function facebookListener(event)

    if ( “session” == event.type ) then

        --options are “login”, “loginFailed”, “loginCancelled”, or “logout”

        if ( “login” == event.phase ) then

            local access_token = event.token

            --code for tasks following a successful login

        end

    elseif ( “request” == event.type ) then

        print(“facebook request”)

        if ( not event.isError ) then

            local response = json.decode( event.response )

            --process response data here

        end

    elseif ( “dialog” == event.type ) then

        print( “dialog”, event.response )

        --handle dialog results here

    end

end

local function fbLogin( event )

facebook.login( fbAppID, facebookListener)

end

local fbBtn = display.newCircle(340, 500, 100)

fbBtn:addEventListener(“tap”, fbLogin)

And her is my build.settings file:

settings =

{

plugins =

{

[“facebook”] =

{

publisherId = “com.coronalabs”,

supportedPlatforms = { iphone=true, [“iphone-sim”]=true },

},

},

iphone =

{

plist =

{

UIApplicationExitOnSuspend = false,

FacebookAppID = 438465966325354,

CFBundleURLTypes =

{

{CFBundleURLSchemes = { “fb438465966325354”,} }

},

[“URL types”] =

{

item =

{

[“URL Shemes”] = { [“item 0”] = “fb438465966325354” },

},

},

}

}

}

Information about my facebook app:

App ID: 438465966325354

Bundle ID: the id i used to make the development provisioning profile that i used to build the app for ios

iPhone Store ID and iPad Store ID: i used the Apple ID from a game i made earlier with another SDK

Single sign in: turned to “yes”

Deep linking: turned to “yes”

Go back and look at the Activity plugin: https://docs.coronalabs.com/plugin/CoronaProvider_native_popup_activity/index.html

Rob

I tried the Activity plugin now, but it has the same problem as the social plugin. It does not work if i use an image from the apps directory. And since i want the score to be displayed on the image i can not use the image from the url.

You can certainly use images from system.DocumentsDirectory.  People save screen shots and post them all the time.

Rob

I tried to download this sample app and build it on my iPhone 5, with iOS 8.3:

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

Everything seemed to work, but the post didn’t appear on facebook. I also tried to share something from another app i downloaded from the App Store and that didn’t work either. So do you think the problem might be on my iPhone or on my facebook account (some settings perhaps)?

Finally i found a solution. It turned out that everything worked as is should all along, expect the settings on my iPhone. I logged out of facebook, went to settings -> Facebook -> logged in there -> accepted something -> logged into facebook on my the native facebook app again and then i could share images from the DocumentsDirectory to every app i tried. Sooooo annoying that i have spent days on this little problem that actually worked all along :slight_smile:

Go back and look at the Activity plugin: https://docs.coronalabs.com/plugin/CoronaProvider_native_popup_activity/index.html

Rob

I tried the Activity plugin now, but it has the same problem as the social plugin. It does not work if i use an image from the apps directory. And since i want the score to be displayed on the image i can not use the image from the url.

You can certainly use images from system.DocumentsDirectory.  People save screen shots and post them all the time.

Rob

I tried to download this sample app and build it on my iPhone 5, with iOS 8.3:

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

Everything seemed to work, but the post didn’t appear on facebook. I also tried to share something from another app i downloaded from the App Store and that didn’t work either. So do you think the problem might be on my iPhone or on my facebook account (some settings perhaps)?

Finally i found a solution. It turned out that everything worked as is should all along, expect the settings on my iPhone. I logged out of facebook, went to settings -> Facebook -> logged in there -> accepted something -> logged into facebook on my the native facebook app again and then i could share images from the DocumentsDirectory to every app i tried. Sooooo annoying that i have spent days on this little problem that actually worked all along :slight_smile: