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

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 = &nbsp;&nbsp;&nbsp;&nbsp;table: 0x1d599260 Jun 24 07:05:18 Daves-iPhone fbtest[1290] \<Warning\>: Got event.response =&nbsp; 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 = &nbsp;&nbsp;&nbsp;&nbsp;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 =&nbsp; Jun 24 07:05:33 Daves-iPhone fbtest[1290] \<Warning\>: key = &nbsp;&nbsp;&nbsp;&nbsp;type&nbsp;&nbsp;&nbsp;&nbsp;, value = &nbsp;&nbsp;&nbsp;&nbsp;dialog Jun 24 07:05:33 Daves-iPhone fbtest[1290] \<Warning\>: key = &nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;, value = &nbsp;&nbsp;&nbsp;&nbsp;fbconnect Jun 24 07:05:33 Daves-iPhone fbtest[1290] \<Warning\>: key = &nbsp;&nbsp;&nbsp;&nbsp;didComplete&nbsp;&nbsp;&nbsp;&nbsp;, value = &nbsp;&nbsp;&nbsp;&nbsp;true Jun 24 07:05:33 Daves-iPhone fbtest[1290] \<Warning\>: key = &nbsp;&nbsp;&nbsp;&nbsp;isError&nbsp;&nbsp;&nbsp;&nbsp;, value = &nbsp;&nbsp;&nbsp;&nbsp;false Jun 24 07:05:33 Daves-iPhone fbtest[1290] \<Warning\>: key = &nbsp;&nbsp;&nbsp;&nbsp;response&nbsp;&nbsp;&nbsp;&nbsp;, value = &nbsp;&nbsp;&nbsp;&nbsp;fbconnect://success?request=565383560171851&to%5B0%5D=2209182

The output on Android (Nexus 7) is:

--I/Corona &nbsp;( 8559): \*\*\* fbListener event = &nbsp; &nbsp;table: 0x68845628 --I/Corona &nbsp;( 8559): Got event.response =&nbsp; --I/Corona &nbsp;( 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).

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?

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.

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.

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.

Don’t suppose there is an update on this?

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:

[lua]

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

[/lua]

  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?

Hi,

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

This should be fixed in build 1154.

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

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): &nbsp;&nbsp;&nbsp;&nbsp;at com.ansca.corona.facebook.FacebookController$FacebookWebDialogOnCompleteListener.onComplete(FacebookController.java:173) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at com.facebook.widget.WebDialog.sendSuccessToListener(WebDialog.java:225) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at com.facebook.widget.WebDialog.access$200(WebDialog.java:52) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at com.facebook.widget.WebDialog$DialogWebViewClient.shouldOverrideUrlLoading(WebDialog.java:312) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at android.webkit.CallbackProxy.uiOverrideUrlLoading(CallbackProxy.java:270) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:372) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at android.os.Looper.loop(Looper.java:137) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at android.app.ActivityThread.main(ActivityThread.java:5041) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at java.lang.reflect.Method.invoke(Method.java:511) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) E/AndroidRuntime( 4672): &nbsp;&nbsp;&nbsp;&nbsp;at dalvik.system.NativeStart.main(Native Method) W/ActivityManager( &nbsp;443): &nbsp; Force finishing activity com.freetherobots.shadowarc/com.ansca.corona.CoronaActivity I/InputReader( &nbsp;443): Reconfiguring input devices. &nbsp;changes=0x00000004 I/InputReader( &nbsp;443): Device reconfigured: id=2, name='elan-touchscreen', size 800x1280, orientation 0, mode 1, display id 0 &nbsp;

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)

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

Hey,

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

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

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.

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.

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

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

Can you post the stack trace?