Extended permission for to post message not working on android

Hi All,

Please can anyone help me with a problem I’m having with Facebook v4. Its my first time using it and its taken me a bit of time to navigate through it all. The problem i’m having relates to the android version of my app, the IOS version is working fine.

The problem seems to centre around accessing certain features of Facebook through my app after login in. As mention above, I’m not having any problem accessing these features in the IOS version so I can safely rule out that I’ve entered something  in incorrectly when integrating Facebook into the app.

Basically though when a user wants to access Facebook through my app, they first have to login and authorise the read only aspect of Facebook, then they confirm and athorise the extended permissions so the user can post messages etc on Facebook. Both the IOS and the Android version build fine, load the plugin and allow the user to do the initial login without issue. On the Android version the app then appears to skip over requesting extended permission so when the user then attempts to send a post with an image after losing in nothing happens on the android version where as the IOS version with upload the message and image to Facebook.

I think there probably something slightly different I need to do with the Android version to be able to get complete access to all of Facebook features but when it came to looking at permission for Android it go very complicated. I can confirm I have the latest build of Xcode, Corona and I’m using Java SE 6,  which as mention has no problems running the app, its just certain feature that are’t working after logging into Facebook. 

I’ve set the app up to return a native alert message to confirm a successful login, so again I’m confident it only a minor issue but on that difficult to put a finger on.

Here is the actual code to login:

   function attributes.onComplete(event)        facebook.login( fbAppID, attributes.facebookExtendedListener, { "publish\_actions", "user\_birthday" },attributes.facebookExtendedListener);     end

        function attributes.facebookListener( event )         if ( "session" == event.type ) then             -- Upon successful login, request list of friends             if ( "login" == event.phase) then                 attributes.access\_token = event.token                 native.showAlert( "Notice", "Please confirm extended permissions.", { "OK" },attributes.onComplete);             end         elseif ( "dialog" == event.type ) then                 print( event.response );         end     end          facebook.login( fbAppID, attributes.facebookListener, { "user\_friends", "email" } );

(apologise for the way the code has pasted in the box, unfortunatley its made the code look a little messy ).

If any one can help please that be amazing, like wise if you need me to provide anything else to help please just let me know.

Many thanks

Kind Regards

Liam

Hi Liam,

Am I safe to assume that “publi sh_actions” is a typo, and the code you’re running requests “publish_actions” permission?

Hi Ajay, Thanks you for the message, apologise its a typo in the message. Yeah the code for the app is using the correct version, no space after the i. Kind Regards Liam

Hi All,

Also as well as the problem I’ve encountered with the Android version mentioned above, I can’t seem to get game invites to work on Facebook for either IOS or Android. I make the showDialog requests, it presents me with a list of friends, I select a friend and click send but no notification is sent through to the friend. I’m not getting a event.response or event.error to help with the problem. Does Game Invite work with Facebook v4 or has any encounter a similar issue which they managed to resolve?

Many thanks

Liam

Liam,

If you are using the Facebook friends picker (facebook.showDialog(“friends”, listener)) try looking in “event.data”. I think it returns a list of the users that were chosen. I don’t think there is anything in “event.response”. Also, I think it will have an “event.name” of “friends” but no “event.type”. That is what I am seeing.

Scott

Hi Scott,

Thank you for the message, I’m actually using game request at the moment. Here the code:

  function attributes.facebookListener(event)         if ( "dialog" == event.type ) then             local name = tostring(event.response);             local errorMsg = tostring(event.isError);             native.showAlert( "Friend", "Error check: "..errorMsg.." Response for game invite :"..name, { "OK" });         end   end   facebook.setFBConnectListener(attributes.facebookListener);           attributes.gameInvite = { message = "You should download this game!",filter = "APP\_NON\_USERS",title = " Water Jetters VS Megalodon"}; facebook.showDialog("requests", attributes.gameInvite);

Basically after selecting the friend and hitting send the alert notification comes up with the event.isError, in each instance this has returned as “true” which means there was no problems with the request. Then it comes up with the url of me and the recipient, however the recipent never receives any game invite message.

I’ve check the recipents setting to see if they can receive game invites and they can, I’ve checked and made sure my app is set as game under Category under Settings in the Facebook developer portal. I’m just at a loss as to the reason the invite is not been received, its puzzling?

Kind Regards

Liam   

Sorry, I haven’t used the “requests” function yet but plan to soon. Have you tried looking at the contents of the entire “event” table that is returned in your Facebook listener? That may give you a clue. I use “print_r” from the Corona community code. It is very helpful. It is recursive in that it navigates through all sub-tables no matter how deep they go.

function attributes.facebookListener(event) print\_r(event) if ( "dialog" == event.type ) then local name = tostring(event.response); local errorMsg = tostring(event.isError); native.showAlert( "Friend", "Error check: "..errorMsg.." Response for game invite :"..name, { "OK" }); end end

Hi All,

Thanks you for the email gsglawson. Unfortunately I don’t think I will be able to use print_r in this case. Facebook v4 doesn’t work on the simulator so I can’t make use of the console. There is a very similar way to check for errors by braking down the jason table returned when Facebook calls are made but it seems that we can only do that for  Facebook request methods, showDialog only returns a url which isn’t as helpful. At the moment though the alert is saying that isError is returning false so there is no problem, it then gives me the url of the recipient and of the game requesting to send the invite.

I did wonder if the game still been in development might be the cause? To test this I added another tester account to my Facebook developer account and tried sending a game invite between the two separate tester accounts but still the same problem. The isError returns false and the url at present doesn’t seem to offer an explanation to why the recipient receives nothing.

Could Facebook be considering it as spam and automatically ignoring the invite? What would cause Facebook to consider it to be spam if that is what happening to the invite? It a mystery at the moment to me because it telling all okay but the invite not been received.

Here the actual message sent and then check of the event after

  function attributes.facebookListener(event)         if ( "dialog" == event.type ) then             local response = tostring(event.response);             local errorMsg = tostring(event.isError);             native.showAlert( "Friend", "Error check: "..errorMsg.." Response for game invite :"..response, { "OK" });         end   end   facebook.setFBConnectListener(attributes.facebookListener);           attributes.gameInvite = { message = "You should download this game!",filter = "APP\_NON\_USERS",title = " Water Jetters VS Megalodon"}; facebook.showDialog("requests", attributes.gameInvite);

You are correct, nothing in the console for Facebook while running on the simulator, however, Facebook does return lots of information in  the event table that you do not see.

If it were me, I would go ahead and build the app with the “print_r” function in the code then load this build onto a device (iOS or Android). Then connect my device to my computer to view the results. The Xcode console will show you the results for iOS devices while “adb logcat Corona:v *:s” will do the same for Android devices. I think you will find your answer if you can see the “event” table in its entirety. That is the only way I have been able to figure out issues with Facebook. It is slow and painful to have to create a build after every minor change but until the Facebook plugin can run on the simulator it is all we have.

Hi  gsglawson,

 

Thanks you for the email gsglawson. I’m not familar with linking a app running on a device to the Xcode console?My Xcode knowledge is a little limited sorry gsglawson. I do however use Xcode to load the app onto my iOS phone after a build so the device being used is connected to the computer and the app shows up in Xcode devices if that is of any help towards getting things  set up to use the console? 

 

Many thanks

 

Liam

in Xcode, click on “Window” then “Devices”. Click on your device on the left. If you do not see the output for your device in the bottom right portion of the screen then look for the icon below. Click that icon to open up the console for that device. All your Corona “print” commands along with everything else should be displayed.

icon.png

Hi gsglawson,

Thank you for your email.

I managed to use the Xcode console for the print_r, it came back with the following: 

Jun 29 14:38:04 Pythagoras-2 SafariViewService[797] <Error>: Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>: # ERROR EVENT PRINT CHECK FOR FACEBOOK 

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>: table: 0x1412a6370 {

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>:   [type] => “dialog”

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>:   [name] => “fbconnect”

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>:   [didComplete] => true

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>:   [isError] => false

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>:   [response] => "fbconnect://success?RequestID=13*************7&Recipient=15*************0&Recipient=(

   15*************0

)"

Jun 29 14:38:04 Pythagoras-2 Water Jetters[1711] <Warning>: }

Jun 29 14:38:11 Pythagoras-2 SafariViewService[797] <Error>: Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Jun 29 14:39:06 Pythagoras-2 syncdefaultsd[1702] <Notice>: (Note ) marked “com.me.keyvalueservice” topic as “enabled” on <APSConnection: 0x144d12e00>

Jun 29 14:39:08 Pythagoras-2 SpringBoard[58] <Warning>: [MPUSystemMediaControls] Disabling lock screen media controls updates for screen turning off.

Jun 29 14:39:08 Pythagoras-2 backboardd[60] <Notice>: [HID] [MT] 

Some of what its returned I’m not entirely sure what the impact or implications are, it has returned a warning [1711] in the print but it does seem to confirm it was sent. I could be wrong though, I also notice it mention something about a service been unavailable?

Jun 29 14:38:04 Pythagoras-2 SafariViewService[797] <Error>: com.apple.WebKit.WebContent: 113: Could not find specified service

It mentions this twice, once before the print_r  and once after. Not sure if they are related, it still seems a bit of a mystery?

Kind Regards

Liam

Below are examples of the event table for my facebook.login command and a facebook.request( “me/friends” ) command I will see if I can setup a test of facebook.showDialog(“requests”, xxx) on my side and see what I get.

------- facebook.login ----------

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: print_r

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: table: 0x1b0c26a0 {

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [type] => “session”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [name] => “fbconnect”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [expiration] => 1472403789

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [phase] => “login”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [token] => “EAAGyQZBFZBZC3IBABtF9YMFGIm9oxreIrTxTrGUlGN1mgGli9znrAAQ3QFySkwQrZCHzw2O7DdmZC66Y6mHZAR8tIAQZBoKrGP4DK2jyATg3nbTpT3m0d3Kq2ZCZB6cS2TC9j8TvIIafLQUvmtZA8BrjTG6GL8Ho7FONGpTeuQdb26y5w9z4eeiwa3ykiG4ZACYQiUZD”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [isError] => false

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [response] => “”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: }

----- facebook.request(“me/friends”) -----

un 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: print_r

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: table: 0x1b0adde0 {

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [isError] => false

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [type] => “request”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [name] => “fbconnect”

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>:   [response] => "{“data”:[{“id”:“10153442260098321”,“name”:“Jennifer Leigh Johnson”},{“id”:“10207439306958476”,“name”:“Thomas Kroger”},{“id”:“1192029117475968”,“name”:“Tammy Conner Freeman”}],“paging”:{“cursors”:{“after”:“QVFIUjR3dUxJTEozRjBuYTYzVDQ4SGdpaXBGcTBfWXhscnczNnhGTkNvZAk9Fa016RTg1MnBIM1V6NHZASOGhXdzdqTzh0MnFGRFgxTnpQTDhrWVUyQlMxRENB”,“before”:“QVFIUklpTFVubFpkRjFWYmRlS04yRFdaWmtVMkZAmQlFtT3gybVptTkYydEdJQlpMb012VWdtb01wZAFBCSXljeXZAoWTYZD”}},“summary”:{“total_count”:400}}"

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: }

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: request

Jun 29 13:03:09 NRC-1st-Floor-Bridge Crackerjack Baseball[2186] <Warning>: event.response = , {“data”:[{“id”:“10153442260098321”,“name”:“Jennifer Leigh Johnson”},{“id”:“10207439306958476”,“name”:“Thomas Kroger”},{“id”:“1192029117475968”,“name”:“Tammy Conner Freeman”}],“paging”:{“cursors”:{“after”:“QVFIUjR3dUxJTEozRjBuYTYzVDQ4SGdpaXBGcTBfWXhscnczNnhGTkNvZAk9Fa016RTg1MnBIM1V6NHZASOGhXdzdqTzh0MnFGRFgxTnpQTDhrWVUyQlMxRENB”,“before”:“QVFIUklpTFVubFpkRjFWYmRlS04yRFdaWmtVMkZAmQlFtT3gybVptTkYydEdJQlpMb012VWdtb01wZAFBCSXljeXZAoWTYZD”}},“summary”:{“total_count”:400}}

Ok, the following code seems to work for me. I get logged in and I am presented with a list of friends who have my app installed. I can choose one, hit “send” and they received the FB message. I also changed the filter to “APP_NON_USERS” and was presented with a list of all my friends who do not have my app installed. However, I did not try sending any of them a message since I did not want to Spam them. 

local facebook = require( "plugin.facebook.v4" ) local util = require("Utility") function facebookListener( event ) print("facebookListener") util:print\_r(event) if ( "session" == event.type ) then if ( "login" == event.phase ) then accessToken = event.token if accessToken == nil then local alert = native.showAlert( "Notification", "Facebook error. Please check your Facebook credentials.", { "OK" } ) else facebook.showDialog( "requests", { message = "You should download this game!", filter = "APP\_USERS" }) end end elseif ( "request" == event.type ) then print( "request" ) elseif ( "dialog" == event.type ) then print( "dialog" ) elseif ( "friends" == event.name ) then print("friends") else print("none of the above", event.type) end end print("start facebook login") facebook.login( facebookListener, {"public\_profile","email","user\_friends"} )

EDIT: Hold the phones! I asked my buddy to send me a screen shot of the message and there wasn’t one there! I think he saw the FB notification light up from someone else and assumed it was from me. I have tried sending to my test account and have the same results as you. It appears to send, there are no errors but I never receive the game request. Unless someone from Corona’s staff thinks otherwise, I think you have found a bug. I would submit a bug report.

Hi gsglawson,

Thank you for the email and for checking that for me. I’ve submitted a bug report to see if they can shed some light on the problem. The fact it doing it for both of us definitely makes it more likely to be a bug issue rather then an implementation issue unfortunately. If they come back with a solution i’ll post it up on here so everyone thats followed the feed knows what the final out come is. Thanks all

Kind Regards

Liam 

Do you have the Case ID for the bug? Can you post it here?

Thanks

Rob

Hi Rob,

The case number is 46607, the title I gave it was GAME INVITE THROUGH FACEBOOK ON IOS.

Thanks Rob.

Kind Regards

Liam

Hi Rob,

Sorry to be a pain but I’ve not heard anything back from the case I logged. Is there any chance you could check to see if it has been looked at and all is ok? I can’t see any where on the website where i can check to see how the case is progressing and with not logging a case before I’m not sure what the normal turn around time is with these sort of things. Sorry to be a pain.

Kind regards

Liam

First, thank you for filing the bug report. I see you filed it late on Wednesday and it was assigned to our QA team to evaluate the bug on Thursday. However this was a holiday weekend and yesterday was the first day back to work for most people. It’s sitting in the in-queue for QA and has not been assigned to an engineer.

However, there is a very high probability that the bug report is going to be rejected. We require a complete test project: main.lua, build.settings, config.lua and any other files needed so that we can build the project, install it on a device and see the error happen. All of this must be put into a .zip file. You just uploaded just a .lua file. We can’t recreate your problem with just this.

Secondly, you’re using some 3rd party libraries (not included) and a fairly complex setup. The sample project needs to be the minimal code that demonstrates the issue.

If you still have the email the bug tracker sent, put together that zip file and attach it to a reply to the bug tracker email. Or just wait until it gets rejected and re-file it with the sample project.

Rob

Hi Rob,

Thank you for your email, no worries, I figured with holidays things might take a bit longer. Probably for the best as well with me just uploading the lua file sorry Rob, I should have checked first what they needed before sending. Rather then waiting for them to reject the case I’ve just uploaded a shortened working program for them to test. The program just runs the Facebook feature using the ui I created for the game I’m making. Thank you for checking for me on its progress Rob its been a big help.

Kind Regards

Liam