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 1 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]
#1

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

I'm trying to use facebook.showDialog() with the "apprequests" dialog. On iOS, I get the response so I can count how many people the user invited. Unfortunately, I get no response when I run the same code on Android on my Nexus 7. Here's my code (I've set up SSO in the build.settings):

local facebook = require("facebook")
local json = require("json")
local fbAppId = "454571631296931"
local function printTable(t)
   for k,v in pairs(t) do
      print("key = ", k, ", value = ", v)
   end
end

local function fbListener(event)
   print("*** fbListener event = ", event)
   if event.response then print("Got event.response = " .. event.response) end
   if event.type == "session" then
      print("*** got session, requesting dialog...")
      facebook.showDialog("apprequests", {message = "check out this game, not sure what this link will take you though ..."})
   elseif event.type == "request" then
   elseif event.type == "dialog" then
      print("*** got dialog! event = ")
      printTable(event)
   end
end

facebook.login(fbAppId, fbListener, {"publish_stream"})

After I run the code, the dialog shows up. I select one friend and press "Send".

 

My output on iOS is:

Jun 24 07:05:18 Daves-iPhone fbtest[1290] <Warning>: *** fbListener event =     table: 0x1d599260
Jun 24 07:05:18 Daves-iPhone fbtest[1290] <Warning>: Got event.response = 
Jun 24 07:05:18 Daves-iPhone fbtest[1290] <Warning>: *** got session, requesting dialog...
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: *** fbListener event =     table: 0x1ed3fae0
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: Got event.response = fbconnect://success?request=565383560171851&to%5B0%5D=2209182
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: *** got dialog! event = 
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: key =     type    , value =     dialog
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: key =     name    , value =     fbconnect
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: key =     didComplete    , value =     true
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: key =     isError    , value =     false
Jun 24 07:05:33 Daves-iPhone fbtest[1290] <Warning>: key =     response    , value =     fbconnect://success?request=565383560171851&to%5B0%5D=2209182

The output on Android (Nexus 7) is:

--I/Corona  ( 8559): *** fbListener event =    table: 0x68845628
--I/Corona  ( 8559): Got event.response = 
--I/Corona  ( 8559): *** got session, requesting dialog...

 

It looks like my fbListener is never called upon the completion of the dialog. Is this a bug or am I missing something? Anyone have any ideas on how I could workaround this?

 

The reason I need to count how many people get invited is because I allow the user to invite friends instead of paying $0.99 to unlock the next set of levels. This is very important to my app as it gives non-paying users a way to access everything in the app but still gives me some benefit (word of mouth marketing).



[TOPIC: post.html]
#2

Tim Richardson

[GLOBAL: userInfoPane.html]
Tim Richardson
  • Observer

  • 26 posts
  • Corona SDK

I'm getting this as well. Works absolutely fine on iOS, but on Android the "dialog" event type for the facebook response listener doesn't come through.

 

Anyone else experiencing this?



[TOPIC: post.html]
#3

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Hi,

Can you guys try "requests" instead of "apprequests"?  If its what you expect then we've mapped the requests wrong and will change it accordingly.  Thanks.



[TOPIC: post.html]
#4

Tim Richardson

[GLOBAL: userInfoPane.html]
Tim Richardson
  • Observer

  • 26 posts
  • Corona SDK

Sorry I should've been more specific, I'm using "feed" and experiencing the problem, like so:

 

facebook.showDialog( "feed", {
    name = "",
    description = "",
    link = ""
})

 

The dialog is opened properly, but the dialog event type isn't coming back from facebook.



[TOPIC: post.html]
#5

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

Thanks for the response! I replaced "apprequests" with "requests" and still don't get a response in my facebook listener function.

 

I'm also having the same problem as timjonrichardson with the "feed" dialog as well.



[TOPIC: post.html]
#6

Tim Richardson

[GLOBAL: userInfoPane.html]
Tim Richardson
  • Observer

  • 26 posts
  • Corona SDK

Don't suppose there is an update on this?



[TOPIC: post.html]
#7

jeremy039

[GLOBAL: userInfoPane.html]
jeremy039
  • Observer

  • 9 posts
  • Enterprise

I am experiencing this same issue. iOS implementation works as expected, but there is absolutely no callback (or anything showing up in logcat) for android. Please push this up in priority.

 

For your debug purposes:

 

 
facebook.login( "XXXXXXXXXXX", friendListener, {"publish_stream"} )
 
function friendListener(event)
 
    print("Any JSON: " .. json.encode(event))
 
    if ( "session" == event.type ) then
        if ( "login" == event.phase ) then
            facebook.showDialog("apprequests", {title="Send to some friends",message="Check this out"})
        end
    elseif ( "dialog" == event.type) then
         print( event.response )        
    end
end
 
1. Login is successful and Any JSON prints to logcat
2. Dialog shows and friends are selectable, pressing send works.
3. Any JSON is never called again (for the dialog response)
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Additional note for apple:
 
4. Any JSON is called again for dialog, but event.response is the fbconnect:// command and not usable json feedback like most facebook.request returns.
 
fbconnect://success?request=XXXXXXXX&to%5B0%5D=YYYYYY
 
Is this in error? Do we have to write our own decoder for this return if we want to know the friend ids?


[TOPIC: post.html]
#8

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Hi,

Thanks for the information.  I'll look into this today.



[TOPIC: post.html]
#9

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

This should be fixed in build 1154.



[TOPIC: post.html]
#10

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

Awesome, great turnaround time, thanks! I'll give it a whirl when build 1154 comes out.



[TOPIC: post.html]
#11

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

So I tried build 1154 with the sample code I originally posted and it looks like I actually get a crash now after I select a friend and press "Send". The message, "Unfortunately, fbtest has stopped" pops up. This is the output in adb logcat:

 

 

 

D/AndroidRuntime( 4672): Shutting down VM
W/dalvikvm( 4672): threadid=1: thread exiting with uncaught exception (group=0x40f03930)
E/AndroidRuntime( 4672): FATAL EXCEPTION: main
E/AndroidRuntime( 4672): java.lang.NullPointerException
E/AndroidRuntime( 4672):     at com.ansca.corona.facebook.FacebookController$FacebookWebDialogOnCompleteListener.onComplete(FacebookController.java:173)
E/AndroidRuntime( 4672):     at com.facebook.widget.WebDialog.sendSuccessToListener(WebDialog.java:225)
E/AndroidRuntime( 4672):     at com.facebook.widget.WebDialog.access$200(WebDialog.java:52)
E/AndroidRuntime( 4672):     at com.facebook.widget.WebDialog$DialogWebViewClient.shouldOverrideUrlLoading(WebDialog.java:312)
E/AndroidRuntime( 4672):     at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:270)
E/AndroidRuntime( 4672):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:372)
E/AndroidRuntime( 4672):     at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4672):     at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 4672):     at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 4672):     at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4672):     at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 4672):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 4672):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 4672):     at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  443):   Force finishing activity com.freetherobots.shadowarc/com.ansca.corona.CoronaActivity
I/InputReader(  443): Reconfiguring input devices.  changes=0x00000004
I/InputReader(  443): Device reconfigured: id=2, name='elan-touchscreen', size 800x1280, orientation 0, mode 1, display id 0

 

 



[TOPIC: post.html]
#12

jeremy039

[GLOBAL: userInfoPane.html]
jeremy039
  • Observer

  • 9 posts
  • Enterprise

I am receiving the same error with build 1154--using my above posted code for "apprequests" immediately following hitting the send button on the dialog.

 

 

W/System.err(17755): java.lang.NullPointerException
W/System.err(17755):     at com.ansca.corona.facebook.FacebookController$FacebookWebDialogOnCompleteListener.onComplete(FacebookController.java:173)
W/System.err(17755):     at com.facebook.widget.WebDialog.sendSuccessToListener(WebDialog.java:225)
W/System.err(17755):     at com.facebook.widget.WebDialog.access$200(WebDialog.java:52)
W/System.err(17755):     at com.facebook.widget.WebDialog$DialogWebViewClient.shouldOverrideUrlLoading(WebDialog.java:312)
W/System.err(17755):     at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:336)
W/System.err(17755):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:461)
W/System.err(17755):     at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err(17755):     at android.os.Looper.loop(Looper.java:137)
W/System.err(17755):     at android.app.ActivityThread.main(ActivityThread.java:4895)
W/System.err(17755):     at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(17755):     at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err(17755):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:994)
W/System.err(17755):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:761)
W/System.err(17755):     at dalvik.system.NativeStart.main(Native Method)


[TOPIC: post.html]
#13

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Like @allbymyself and @jeremy039, I'm also getting a crash when using facebook.showDialog (the apprequests dialog) on Android in daily build 1154, but not in daily build 1153.  The crash occurs regardless of whether I actually send a request via the dialog or simply cancel out of the dialog after it displays.  (iOS continues to work fine.)

 

@dchan, since three of us are experiencing this, it looks like the fix that was pushed in daily build 1154 isn't working.

 

- Andrew



[TOPIC: post.html]
#14

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Hey,

Sorry about that guys.  Please try 1155 and see if that works.



[TOPIC: post.html]
#15

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Hi @dchan,

 

Build 1156 no longer crashes on Android, but I think there's still an issue.

 

After showing and dismissing the facebook apprequests dialog, my facebook listener receives a callback, but event.response is empty.  It seems like event.response isn't nil but rather an empty string.  As @jeremy039 noted above, on iOS, event.response contains information about the requests the user sent using the dialog in the format "fbconnect://success?request=XXXXXXXX&to%5B0%5D=YYYYYY".  I'd expect Android to do the same.  (A separate question is why the information is in this format rather than JSON, but the more important issue is that the information isn't even being provided on Android.)

 

Thanks.

 

- Andrew



[TOPIC: post.html]
#16

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

I'm seeing the same behavior as aukStudios on build 1156. I'm properly getting a callback now but event.response is an empty string instead of the fbconnect URL.



[TOPIC: post.html]
#17

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Hi,

This should be fixed in the next daily build.  The docs were wrong in that the fbconnect.response always returns a json string.  It only returns a json string when you do a facebook.request because that is what is returned by facebook.  When you call facebook.showDialog we actually get back a uri instead.  I will update the daily docs to reflect that fact.



[TOPIC: post.html]
#18

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Thanks David, sounds good.  Hopefully the next daily build will get released before the long weekend..?  :-)

 

That's a helpful clarification that the response for facebook.showDialog being a uri rather than json is the expected behavior.

 

- Andrew



[TOPIC: post.html]
#19

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Hi David, thanks for pushing out build 1157 before the long weekend.  Unfortunately I'm still encountering a crash on Android.

 

After opening the apprequest dialog with facebook.showDialog, if I simply dismiss the dialog, my callback is fired and event.response is populated as expected (with "fbconnect://success").  However, if I use the dialog to actually send a request to another user, then immediately after tapping the send button in the dialog, the app crashes.

 

- Andrew



[TOPIC: post.html]
#20

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Can you post the stack trace?



[TOPIC: post.html]
#21

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Yup, sorry about that, here's the stack trace.  I'm also including some lines from the log that appeared when the dialog was created, which looks like it might be relevant (particular the issue with the getString method).

07-04 17:27:43.681  1320  2103 W InputManagerService: Window already focused, ig
noring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40
ae1ab8
07-04 17:27:44.009  7324  7324 I dalvikvm: Could not find method android.os.Bund
le.getString, referenced from method com.ansca.corona.facebook.FacebookControlle
r$FacebookWebDialogOnCompleteListener.onComplete
07-04 17:27:44.025  7324  7324 W dalvikvm: VFY: unable to resolve virtual method
 672: Landroid/os/Bundle;.getString (Ljava/lang/String;Ljava/lang/String;)Ljava/
lang/String;
07-04 17:27:44.025  7324  7324 D dalvikvm: VFY: replacing opcode 0x6e at 0x0035
07-04 17:27:44.025  7324  7324 D dalvikvm: VFY: dead code 0x0038-003c in Lcom/an
sca/corona/facebook/FacebookController$FacebookWebDialogOnCompleteListener;.onCo
mplete (Landroid/os/Bundle;Lcom/facebook/FacebookException;)V
07-04 17:27:47.947  1320  1480 W InputManagerService: Window already focused, ig
noring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40
a120f8
07-04 17:27:49.994  1320  2436 W InputManagerService: Window already focused, ig
noring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40
9bd358
07-04 17:28:06.400  7324  7324 D AndroidRuntime: Shutting down VM
07-04 17:28:06.400  7324  7324 W dalvikvm: threadid=1: thread exiting with uncau
ght exception (group=0x40018560)
07-04 17:28:06.400  7324  7324 D FlurryAgent: Ending session
07-04 17:28:06.423  7324  7324 E AndroidRuntime: FATAL EXCEPTION: main
07-04 17:28:06.423  7324  7324 E AndroidRuntime: java.lang.NoSuchMethodError: an
droid.os.Bundle.getString
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.ansca.corona.face
book.FacebookController$FacebookWebDialogOnCompleteListener.onComplete(FacebookC
ontroller.java:176)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.facebook.widget.W
ebDialog.sendSuccessToListener(WebDialog.java:225)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.facebook.widget.W
ebDialog.access$200(WebDialog.java:52)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.facebook.widget.W
ebDialog$DialogWebViewClient.shouldOverrideUrlLoading(WebDialog.java:312)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at android.webkit.Callba
ckProxy.uiOverrideUrlLoading(CallbackProxy.java:223)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at android.webkit.Callba
ckProxy.handleMessage(CallbackProxy.java:330)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at android.os.Handler.di
spatchMessage(Handler.java:99)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at android.os.Looper.loo
p(Looper.java:130)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at android.app.ActivityT
hread.main(ActivityThread.java:3806)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at java.lang.reflect.Met
hod.invokeNative(Native Method)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at java.lang.reflect.Met
hod.invoke(Method.java:507)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.android.internal.
os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at com.android.internal.
os.ZygoteInit.main(ZygoteInit.java:597)
07-04 17:28:06.423  7324  7324 E AndroidRuntime:        at dalvik.system.NativeS
tart.main(Native Method)

- Andrew



[TOPIC: post.html]
#22

dchan

[GLOBAL: userInfoPane.html]
dchan
  • Contributor

  • 360 posts
  • Corona Staff

Ok thanks for that.  This seems like it should be an issue with 2.x devices for now.  It should work on 3.x and 4.x devices.  Unfortunately the office is closed until Monday, at that time I will fix this issue.  Sorry for the inconvenience.



[TOPIC: post.html]
#23

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

OK thanks Danny (I don't know what I was saying David!), sounds good.  Have a great weekend.

 

- Andrew



[TOPIC: post.html]
#24

allbyself

[GLOBAL: userInfoPane.html]
allbyself
  • Observer

  • 14 posts
  • Corona SDK

dchan: Build 1157 fixes it for me, but then again, I've only tested it on my Nexus 7. Thanks for the quick turnaround and making this fix happen!



[TOPIC: post.html]
#25

aukStudios

[GLOBAL: userInfoPane.html]
aukStudios
  • Corona Geek

  • 1,003 posts
  • Corona SDK

Cool, dchan's point is probably right then, since I was using a device running Android 2.x.

 

- Andrew




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