facebook.showDialog() doesn't return a response on Android (but does in iOS)

@Joel_DGS, that’s a really thorough report.  I appreciate that.  I filed a bug report (case #25128) about Facebook app issues on Android.  I sent Corona support a follow up email, pointing to your post.  I hope this whole thing will be looked at and resolved soon.

Naomi

The issue with the Facebook dialog not providing a response to the callback listener was a bug that was resolved around Daily Build 1158. So I think that addresses the second part of your post, Joel. - Andrew

Thanks Naomi. Looking forward to the response from Corona on that case.

Andrew, apparently it was not resolved as we tested with 1168.

I’m downloading 1170 right now, which is the latest nightly build, to check if it has been resolved.

Edit: I just tested with 1170 and the problem still remains.

I am having similar problems. :frowning:

Can we all agree…

…Facebook should be stabbed in the heart

…burned at the stake

…locked in a small iron box

…chained to an anchor

…thrown into the deepest part of the ocean

and then never heard from again except in spooky stories around a campfire?..

Am I the only one who hates it? lol

Hahahaha, @Anderoth, I feel the same way.

Naomi

The more I try to get apprequests to work, the more I seem to get wrapped around the axle. I’ve written my own friend selector for inviting players, so I want to use showDialog to send the requests, putting the user ids in params.to. The Facebook docs say this should be “A user ID or username, or a comma-separated list of them”. I tried a table of strings, and my app crashed. I tried a comma-delimited list in a single string, and the API ignored it and opened the default selector window. I tried multiple calls with a single id each time, and got an error “No valid recipients specified”. I must be overlooking something fundamental. Is anyone using the to keyword with success?

I’m on the most recent public build: 2013.1202

This is the latest thing I tried.

params.title = “Let’s play!”
params.message = “Let’s play!”
params.frictionless = “1” – Not sure this has any effect
for i = 1, #facebookRequestIds do – a table of ids
    local function requestDialog()
        params.to = facebookRequestIds[i]
        facebook.showDialog(“apprequests”, params)
    end
    performWithDelay(100, requestDialog) – staggered the requests just in case they were stepping on each other
end

For me, a comma-delimited list of Facebook IDs in a single string works fine.  If you post your code where you tried that, maybe we can figure out what went wrong.

  • Andrew

Thanks, Andrew. I’ve reinstated the comma-delimited string and I find that the result, with one id or a list, depends on how I’m signed into Facebook in the native app. Using my own account I get “No valid recipients” and no requests are sent. Signed on as one of my test users I’m taken to the multi-selector dialog, and the test users I select there do get the notification (the ids in the list string do not default to selected). All the test users have friended each other, whereas none of them are friends of my account. The Facebook description of the to keyword says this shouldn’t matter: “These may or may not be a friend of the sender.” That seems to be incorrect. Anyway, here’s my logic for building the string of ids.

local params = {}
params.title = “Let’s play!”
params.message = “Let’s play!”   
params.frictionless = “1”
local requestList = “”
for i = 1, #facebookRequestIds do
    if i > 1 then
        requestList = requestList…","
    end
    requestList  = requestList…facebookRequestIds[i]
end
params.to = requestList
print(params.to)                                                           – “100006487971020,100006532337310” (two test user ids)
facebook.showDialog(“apprequests”, params)            – print(event.response) => “fbconnect://success”

Incidentally, https://developers.facebook.com/docs/games/requests/has this to say about apprequests:

“New Facebook policy, effective January 8, 2014: App requests can no longer offer a select all option or pre-select multiple recipients to receive a request.” Should I read that to mean that in a few months I (we) will have to loop through the list with multiple requests anyway?

I would read that Jan 8 message to mean that this dialog can only pre-select one person.   This is an anti-spam measure and I understand why Facebook is making this change. 

Well, now I am confused. I just tested my app again after I’d made some changes completely unrelated to my Facebook logic; I’m still building the list string exactly as in my last post. But this time the apprequests call worked perfectly. Instead of the multi-select dialog it opened the send confirmation dialog with the “frictionless?” checkbox. So, yay? The only thing I can even imagine made a difference is the fact that in the meantime the native Facebook app had updated itself, but that doesn’t sound logical. I’ll wait and see if it keeps working. Thanks, Andrew, for leading me to try that again.

Now I have another question. Facebook says I’m supposed to delete my notifications when they’ve been accepted. How do I know when that happens? I do have one thought, but before I spend time coding it I’d like to get a sanity check. My user can be in multiple games at one time, and each of these sessions has a unique id. If I put that id in the data keyword of showDialog, can I request(user/apprequests), look for that id, and delete the request if it matches? It doesn’t look as if the apprequest data includes an accepted flag. Does this mean that user/apprequests returns only requests that haven’t been accepted yet? That wouldn’t help me much.

By the way, any idea why Facebook doesn’t just do this automatically? Why retain a notification indefinitely after it’s been received? Or why not just let the recipient clear it?

The requirement to delete an apprequest is a bit confusing, but yes, you have to do it yourself.  (If you don’t, they automatically expire after two weeks.)  I think Facebook’s reasoning is that app’s will vary in how they use apprequests, so it’s better to leave it to the app to delete it at the right time than for Facebook to make an assumption about when that should be.

Let’s say a user receives an apprequest.  You can query their apprequests via a GET to “me/apprequests”.  This’ll return a JSON that includes an array of all apprequests that user received, which includes a Facebook assigned id.  Once you’ve done whatever it is you want to do with it, you delete it by issuing a delete to “/<id>” where <id> is the id of the apprequest.

  • Andrew

When I see the confirmation dialog before sending an apprequest, the complete message text is visible. But when I get the notification on one of my test user accounts, the only message is “username has sent you a request” and my app name. The message I crafted so carefully is nowhere in sight. I’ve looked for any app or account settings that might affect how requests are viewed and I don’t find any, so is this just the way requests work on a mobile device? What is the purpose of attaching a message to an apprequest?

@sajent,

That’s a common misunderstanding of how the ‘message’ parameter in a Facebook request works.  Unfortunately, the recipient can only see the ‘message’ if they go to the Facebook App Center.  In their notification area, you can’t customize the message as far as I know.  It can only ever say “So and So invited you to play App” (if they don’t yet play the game) or “App: So and So sent you a request” (if they already play the game).

  • Andrew

Thanks for clearing that up, Andrew. Now I’m trying to delete my apprequests. Can anyone tell me why this doesn’t work?

local function facebookEvent(event)
  if event.isError then
    print(event.status)
  end
end
local headers = {}
headers[“Content-Type”] = “application/x-www-form-urlencoded”
headers[“Accept-Language”] = “en-US”
local params = {}
params.headers = headers
local tokenParm = “access_token=”…facebookToken  – token returned by facebook.login(), works OK to get me/apprequests
params.body = tokenParm
local urlReq = “https://graph.facebook.com/”…data[i].id  – element in the table returned from me/apprequests
network.request(urlReq, “DELETE”, facebookEvent, params)

event.status is not printing, so I assume event.isError is false. But all the apprequests are still there the next time I list them. The id I’m passing is definitely the concatenated request_user. I can’t figure out where I’ve gone wrong. I’m working from this example in Facebook:

DELETE https://graph.facebook.com/[<REQUEST_OBJECT_ID>_<USER_ID>]?access_token=[USER or APP ACCESS TOKEN]

You should probably be using facebook.request(), not network.request(), when making requests to facebook.  Aside from taking care of the access token for you, there may be other reasons why you have to use facebook.request() (although I’m intrigued by the idea of using network.request(), since it would let you set up callbacks for each request, among other things).

For me, I delete an apprequest with facebook.request("/apprequestID", “DELETE”).  Despite the fact that Facebook’s documentation suggests concatenating the apprequestID with the userID, I’ve found that doesn’t work, and you just need to use the apprequestID.

  • Andrew

The more I try to get apprequests to work, the more I seem to get wrapped around the axle. I’ve written my own friend selector for inviting players, so I want to use showDialog to send the requests, putting the user ids in params.to. The Facebook docs say this should be “A user ID or username, or a comma-separated list of them”. I tried a table of strings, and my app crashed. I tried a comma-delimited list in a single string, and the API ignored it and opened the default selector window. I tried multiple calls with a single id each time, and got an error “No valid recipients specified”. I must be overlooking something fundamental. Is anyone using the to keyword with success?

I’m on the most recent public build: 2013.1202

This is the latest thing I tried.

params.title = “Let’s play!”
params.message = “Let’s play!”
params.frictionless = “1” – Not sure this has any effect
for i = 1, #facebookRequestIds do – a table of ids
    local function requestDialog()
        params.to = facebookRequestIds[i]
        facebook.showDialog(“apprequests”, params)
    end
    performWithDelay(100, requestDialog) – staggered the requests just in case they were stepping on each other
end

For me, a comma-delimited list of Facebook IDs in a single string works fine.  If you post your code where you tried that, maybe we can figure out what went wrong.

  • Andrew

Thanks, Andrew. I’ve reinstated the comma-delimited string and I find that the result, with one id or a list, depends on how I’m signed into Facebook in the native app. Using my own account I get “No valid recipients” and no requests are sent. Signed on as one of my test users I’m taken to the multi-selector dialog, and the test users I select there do get the notification (the ids in the list string do not default to selected). All the test users have friended each other, whereas none of them are friends of my account. The Facebook description of the to keyword says this shouldn’t matter: “These may or may not be a friend of the sender.” That seems to be incorrect. Anyway, here’s my logic for building the string of ids.

local params = {}
params.title = “Let’s play!”
params.message = “Let’s play!”   
params.frictionless = “1”
local requestList = “”
for i = 1, #facebookRequestIds do
    if i > 1 then
        requestList = requestList…","
    end
    requestList  = requestList…facebookRequestIds[i]
end
params.to = requestList
print(params.to)                                                           – “100006487971020,100006532337310” (two test user ids)
facebook.showDialog(“apprequests”, params)            – print(event.response) => “fbconnect://success”

Incidentally, https://developers.facebook.com/docs/games/requests/has this to say about apprequests:

“New Facebook policy, effective January 8, 2014: App requests can no longer offer a select all option or pre-select multiple recipients to receive a request.” Should I read that to mean that in a few months I (we) will have to loop through the list with multiple requests anyway?

I would read that Jan 8 message to mean that this dialog can only pre-select one person.   This is an anti-spam measure and I understand why Facebook is making this change. 

Well, now I am confused. I just tested my app again after I’d made some changes completely unrelated to my Facebook logic; I’m still building the list string exactly as in my last post. But this time the apprequests call worked perfectly. Instead of the multi-select dialog it opened the send confirmation dialog with the “frictionless?” checkbox. So, yay? The only thing I can even imagine made a difference is the fact that in the meantime the native Facebook app had updated itself, but that doesn’t sound logical. I’ll wait and see if it keeps working. Thanks, Andrew, for leading me to try that again.

Now I have another question. Facebook says I’m supposed to delete my notifications when they’ve been accepted. How do I know when that happens? I do have one thought, but before I spend time coding it I’d like to get a sanity check. My user can be in multiple games at one time, and each of these sessions has a unique id. If I put that id in the data keyword of showDialog, can I request(user/apprequests), look for that id, and delete the request if it matches? It doesn’t look as if the apprequest data includes an accepted flag. Does this mean that user/apprequests returns only requests that haven’t been accepted yet? That wouldn’t help me much.

By the way, any idea why Facebook doesn’t just do this automatically? Why retain a notification indefinitely after it’s been received? Or why not just let the recipient clear it?