Need help with the social plugin for facebook

Hi

I’m using Windows daily build 2015.2646

I’ve been through all the docs, tutorials and blogs, webcasts and so forth.

I’m trying to use the simple social plugin for a user of my app to post a message on their timeline and my game will reward them with something for doing so, it’s all I need.

I’ve already got the code in place that checks they have facebook enabled on their device, then checks they have an internet connection.

But one thing is not explained in the social plugin docs, which is absolutely vital, did the user actually post a message to their timeline?

local options = { service = "facebook", message = "Check out this photo!", listener = eventListener, image = { { filename = "pic.jpg", baseDir = system.ResourceDirectory }, { filename = "pic2.jpg", baseDir = system.ResourceDirectory } }, url = "http://coronalabs.com" }

I can see that it’s the listener part of the options table but there are no examples that I can find to tell what values I should be “listening” for.

Scrumptious was mentioned as an example but that is not in the Corona folder on my computer. I watched the Scrumptious App Screencast and it was obvious that it didn’t apply to the simple social plugin.

In frustration, I took a look at https://github.com/coronalabs/plugins-sample-native-popup-social/

No help there either.

I looked through this forum and Rob told someone to put in a request for the feature, I can’t wait that long, this is the last thing I have to do to my app to make it ready for market release.

There must be thousands of Corona users that have used this plugin so can somebody please give me a code snippet of how to use the listener to get the desired response so I know the user did or did not post the message? I don’t want to experiment by continuously building the app and installing on the device until I get it right, it’s very frustrating.

Many thanks in advance.

Martin.

Update: While I’m waiting for a response I’ve been testing the other elements and they are not working on my Android device.

local isFacebookAvailable = native.canShowPopup( "social", "facebook" ) if isFacebookAvailable == true then showFB() end

showFB() is not getting called, I have a facebook account set up on my device for sure, in fact I got a message on it while I was testing the game.

My build.settings

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight" }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.READ\_EXTERNAL\_STORAGE" }, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon-xxhdpi.png", "Icon-xhdpi.png", "Icon-hdpi.png", "Icon-mdpi.png", "Icon-ldpi.png" }, versionCode = "10", usesFeatures = { { name = "android.hardware.camera", required = false }, { name = "android.hardware.location", required = false }, { name = "android.hardware.location.gps", required = false } }, plugins = { ["CoronaProvider.native.popup.social"] = { publisherId = "com.coronalabs" }, }, }, iphone = { plist = { UIAppFonts = { "Coaster.ttf", "Helsinki.ttf" }, CFBundleIconFile = "Icon.png", CFBundleIconFiles = { "Icon.png", "Icon@2x.png", "Icon-Small-40.png", "Icon-Small-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" }, }, }, }

Notice I’ve included the social plugin above.

Am I missing something? Do I need to require anything in my lua modules? Because I haven’t seen anything mentioned about that, do I need pro or enterprise subscription?

Any help would be greatly appreciated.

You need to provide a function (which you’ve chose to name ‘eventListener’. When that function triggers when the dialog closes, there is an event table passed in with an entry called event.action. This should let you know what happened with the call.

Rob

Thanks very much Rob, I will get to work on that.

I’m concerned that this isn’t working and if this doesn’t work then maybe the rest won’t either…

local isFacebookAvailable = native.canShowPopup( "social", "facebook" ) if isFacebookAvailable == true then showFB() end

Any ideas?

B.T.W. I’ve installed the latest daily build.

On Android the individual popup’s don’t work.  It’s called “share” there.

https://docs.coronalabs.com/plugin/CoronaProvider_native_popup_social/index.html

The “facebook” option you’re looking for is really an iOS option that was designed for iOS 6 and earlier. On Android there is only their “sharing” intent which has all sharing options on one screen that pops up.  This is similar to how iOS 7 and 8 do it. The iOS plugin is called “activity” if you want to use something more iOS 7+ like.

Rob

Oh, so what you’re saying is I have to change

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

to

local isFacebookAvailable = native.canShowPopup( “social”, “share” )

I feel like this is getting out of my league Rob.

I didn’t know, but I do now thanks to you, that event.action which is part of the Facebook Plugin also works with the Social Plugin, the Docs are not clear on this at the outset when you read “Implementing Facebook”.

Another thing, I followed the link you posted then clicked on native.canShowPopup…

Quote:

“On Android, this is the package name of the social service you wish to check is installed on the device. For example, if you set this to “twitter”, this function will check to see if any package names installed on the device contain the string twitter and, if a match is found, it will return true. If you don’t care about checking for a specific service, and simply want to check if at least one is available, set this to “share”.”

This is very vague to a newbie who has never used this feature, to me it says I can use “twitter” or “facebook” but if I don’t care then I can use “share”.

The package name installed on the device? What does this mean?

Am I trying to do something on Android that is really meant to be for IOS Rob?

Should I be trying to post a message to Facebook in a different way?

I have more questions but I will leave it at this for now before it gets too much.

native.showPopup(“social”, “twitter”) and native.showPopup(“social”, “facebook”) are iOS only.  For Android you have to use:

native.showPopup(“social”, “share”) and even if you want to use iOS, you should use: native.showPopup(“social”, “activity”).

When we do guides and such, we can’t cover every possible option and combination. This is why we have documentation for each API call and links from there to the things they return.

For the canShowPopup(), even though you would use “share” for showPopup(), it looks like you can check to see if an app is available using canShowPopup().  However, I think most everyone doesn’t do that check, they just show the popup and let the user choose what available service they want to share on. This gives you more options than just Twitter and Facebook.

Rob

Thanks for clearing that up for me.

The reason I’m interested in Facebook is because I’ve already got Twitter working in my app last year using Twitter Facade when this feature wasn’t available to poor people like me.

Now I know what I’m doing wrong maybe I can get this working, I’m going to work on it today and I might be posting my code if nothing works for you to take a look at if you don’t mind.

Thanks again for your wisdom.

Martin.

I finally got my head around the social plugin, it’s no good for me on android, shame but I will be using it when I build my app to IOS.

Looks like I have no option but to go the full hog and implement the Facebook Plugin, I don’t want that because I don’t like Facebook, they insist you use your personal Facebook page, I don’t have one and never will have one, I don’t like being spied on.

Anyhow, thanks for your help Rob.

You need to provide a function (which you’ve chose to name ‘eventListener’. When that function triggers when the dialog closes, there is an event table passed in with an entry called event.action. This should let you know what happened with the call.

Rob

Thanks very much Rob, I will get to work on that.

I’m concerned that this isn’t working and if this doesn’t work then maybe the rest won’t either…

local isFacebookAvailable = native.canShowPopup( "social", "facebook" ) if isFacebookAvailable == true then showFB() end

Any ideas?

B.T.W. I’ve installed the latest daily build.

On Android the individual popup’s don’t work.  It’s called “share” there.

https://docs.coronalabs.com/plugin/CoronaProvider_native_popup_social/index.html

The “facebook” option you’re looking for is really an iOS option that was designed for iOS 6 and earlier. On Android there is only their “sharing” intent which has all sharing options on one screen that pops up.  This is similar to how iOS 7 and 8 do it. The iOS plugin is called “activity” if you want to use something more iOS 7+ like.

Rob

Oh, so what you’re saying is I have to change

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

to

local isFacebookAvailable = native.canShowPopup( “social”, “share” )

I feel like this is getting out of my league Rob.

I didn’t know, but I do now thanks to you, that event.action which is part of the Facebook Plugin also works with the Social Plugin, the Docs are not clear on this at the outset when you read “Implementing Facebook”.

Another thing, I followed the link you posted then clicked on native.canShowPopup…

Quote:

“On Android, this is the package name of the social service you wish to check is installed on the device. For example, if you set this to “twitter”, this function will check to see if any package names installed on the device contain the string twitter and, if a match is found, it will return true. If you don’t care about checking for a specific service, and simply want to check if at least one is available, set this to “share”.”

This is very vague to a newbie who has never used this feature, to me it says I can use “twitter” or “facebook” but if I don’t care then I can use “share”.

The package name installed on the device? What does this mean?

Am I trying to do something on Android that is really meant to be for IOS Rob?

Should I be trying to post a message to Facebook in a different way?

I have more questions but I will leave it at this for now before it gets too much.

native.showPopup(“social”, “twitter”) and native.showPopup(“social”, “facebook”) are iOS only.  For Android you have to use:

native.showPopup(“social”, “share”) and even if you want to use iOS, you should use: native.showPopup(“social”, “activity”).

When we do guides and such, we can’t cover every possible option and combination. This is why we have documentation for each API call and links from there to the things they return.

For the canShowPopup(), even though you would use “share” for showPopup(), it looks like you can check to see if an app is available using canShowPopup().  However, I think most everyone doesn’t do that check, they just show the popup and let the user choose what available service they want to share on. This gives you more options than just Twitter and Facebook.

Rob

Thanks for clearing that up for me.

The reason I’m interested in Facebook is because I’ve already got Twitter working in my app last year using Twitter Facade when this feature wasn’t available to poor people like me.

Now I know what I’m doing wrong maybe I can get this working, I’m going to work on it today and I might be posting my code if nothing works for you to take a look at if you don’t mind.

Thanks again for your wisdom.

Martin.

I finally got my head around the social plugin, it’s no good for me on android, shame but I will be using it when I build my app to IOS.

Looks like I have no option but to go the full hog and implement the Facebook Plugin, I don’t want that because I don’t like Facebook, they insist you use your personal Facebook page, I don’t have one and never will have one, I don’t like being spied on.

Anyhow, thanks for your help Rob.