Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

facebook.showDialog() doesn't return a response on Android (but does in iOS)
Started by allbyself Jun 24 2013 03:21 AM

45 replies to this topic
showdialog facebook android
[TOPIC CONTROLS]
Page 2 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Hi,

I've pushed a fix and it should appear in build 1158.



[TOPIC: post.html]
#27

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Hi Danny.  It's working for me now in build 1158.  Thanks for turning this around!

 

- Andrew



[TOPIC: post.html]
#28

Joel_DGS

[GLOBAL: userInfoPane.html]
Joel_DGS
  • Observer

  • 21 posts
  • Corona SDK

Hi guys, we have been pondering this problem for the past 2 days and thought I'd give some feedback. The tests have been made on 2 different Android devices (3.1 and 4.0). This is our experience so far...

 

 

 

Corona build 1168:

 

With Facebook App installed (v3.4)

  • Invoking facebook.login suspends the Corona app
  • Native Android alert saying "Facebook - xxxxx would like to access your public profile and friends list. OK | CANCEL"
  • Clicking OK resumes the Corona app
  • An empty "session" event is received by the facebook listener (no event.phase or token), i.e. the login FAILS

 

Without Facebook App installed

  • Invoking facebook.login suspends the Corona app
  • A browser based Facebook dialog appear, requesting user to login and granting permissions
  • After completing the dialogs, the Corona app resumes and crashes ("The application xxxxx has stopped unexpectedly. Please try again")

 

 

Corona build 1131:

 

With Facebook App installed (v3.4)

  •  invoking facebook.login suspends the Corona app
  •  Facebook App asking for permission to access profile and friends list
  •  After accepting permissions the Corona app resumes
  •  A "session" event with event.phase and event.token is received by the facebook listener
  •  Invoking facebook.showDialog("apprequests") summons the request dialog
  •  Upon completing (or canceling) the dialog, the app continues normally, but:
  •  An empty "dialog" event is received by the facebook listener. I.e. it's not possible to verify the requests (as with IOS).
  • Edit: Cancelling the dialog fires an isError event with event.response set to"Dialog cancelled". This seems to be the only dialog event that actually generates a response.

 

Without Facebook App installed

  •  The process is identical to the above except the login- and permission dialogs are browser based.

 

 

Example code:

local function fbListener( event )
    if event.isError then		
        -- handle error
    else
        if (event.type == "session") then
            if (event.phase == "login") then
                facebook.showDialog("apprequests");
	    end;
	elseif (event.type == "dialog") then
            -- handle dialog results
        end;
    end;
end;


facebook.login( FB_APP_ID, fbListener, {} );  -- no extended permissions needed

Edited by Joel_DGS, 24 July 2013 - 07:42 AM.


[TOPIC: post.html]
#29

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

@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



[TOPIC: post.html]
#30

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

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

[TOPIC: post.html]
#31

Joel_DGS

[GLOBAL: userInfoPane.html]
Joel_DGS
  • Observer

  • 21 posts
  • Corona SDK

@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

 

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

 

 

 

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

 

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.


Edited by Joel_DGS, 24 July 2013 - 07:53 PM.


[TOPIC: post.html]
#32

Anderoth

[GLOBAL: userInfoPane.html]
Anderoth
  • Contributor

  • 278 posts
  • Corona SDK

I am having similar problems. :(

 

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



[TOPIC: post.html]
#33

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Enterprise

Hahahaha, @Anderoth, I feel the same way.

 

Naomi



[TOPIC: post.html]
#34

sajent

[GLOBAL: userInfoPane.html]
sajent
  • Observer

  • 22 posts
  • Corona SDK

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



[TOPIC: post.html]
#35

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

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



[TOPIC: post.html]
#36

sajent

[GLOBAL: userInfoPane.html]
sajent
  • Observer

  • 22 posts
  • Corona SDK

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?



[TOPIC: post.html]
#37

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,328 posts
  • Corona Staff

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. 



[TOPIC: post.html]
#38

sajent

[GLOBAL: userInfoPane.html]
sajent
  • Observer

  • 22 posts
  • Corona SDK

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?



[TOPIC: post.html]
#39

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

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



[TOPIC: post.html]
#40

sajent

[GLOBAL: userInfoPane.html]
sajent
  • Observer

  • 22 posts
  • Corona SDK

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?



[TOPIC: post.html]
#41

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

@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



[TOPIC: post.html]
#42

sajent

[GLOBAL: userInfoPane.html]
sajent
  • Observer

  • 22 posts
  • Corona SDK

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]



[TOPIC: post.html]
#43

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

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



[TOPIC: post.html]
#44

croftware_dev

[GLOBAL: userInfoPane.html]
croftware_dev
  • Observer

  • 2 posts
  • Corona SDK

I hope its okay to post this here, even if its not 100% align with topic.

 

I have implemented the share dialog, and it works fine. But on Android (could not test on iphone) the dialog has 3 options:

1. "X" in the upper left

2. "Cancel" on the left side of the title

3. "Send" on the right side of the title

 

When I use send, it works quite good and I get a result. If I click the "X" to close the share dialog I get a response with "isError" true AND "didComplete" false, wich is a little confusing but not the main problem. The main problem is, that hitting "Cancel" returns the exact same as if I use "Send". I did not find a way to check if the post was actually submitted.

 

I/Corona  (30585): phase:nil type: dialog
I/Corona  (30585): ### type: dialog
I/Corona  (30585): ### name: fbconnect
I/Corona  (30585): ### didComplete: true
I/Corona  (30585): ### isError: false
I/Corona  (30585): ### response: fbconnect://success

 

I am giving the user a feedback that a post was sucessfully sent. Now the user gets the feedback, that the post has been submitted even if he cancelled the dialog. And this can be very confusing for the user!

 

Is this a bug? Or am I doing something wrong?



[TOPIC: post.html]
#45

jandjstudiosllc

[GLOBAL: userInfoPane.html]
jandjstudiosllc
  • Enthusiast

  • 56 posts
  • Corona SDK

croftware - I just started testing this out myself and you can tell the difference between a "Cancel" and "Send" event.  The "Send" event includes the post id in the response field.

 

 [response] => "fbconnect://success?post_id=1423...

 

A "Cancel" event does not, i.e. 

 

 [response] => "fbconnect://success"

 

I haven't tried this on iOS yet but it seems to hold for Android so far.

 

Hope that helps!



[TOPIC: post.html]
#46

john.armstrong

[GLOBAL: userInfoPane.html]
john.armstrong
  • Contributor

  • 132 posts
  • Corona SDK

I'm using latest build 2520 and I get the fbconnect://success?..... as a response too when I use apprequests on showdialog. I am not receiving any requests on any of my users. Can we get this to work ?? 




[topic_controls]
Page 2 of 2 1 2
 
[/topic_controls]