Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Connect for iOS: dialogDidComplete response differentiation

Tags:

ios

facebook

I was wondering how to differentiate between the user tapping submit or skip in the inline post-to-stream FBDialog. Anyone know what to test for?

I am using the latest iOS Facebook Connect in a iOS 4.2 environment.

/**
 * Called when a UIServer Dialog successfully return.
 */
- (void)dialogDidComplete:(FBDialog *)dialog {
    if user tapped submit and post was successful
        alert user of successful post

    if user tapped "skip" (cancel equivalent)
        do not display alert
}
like image 618
Oh Danny Boy Avatar asked Dec 10 '10 18:12

Oh Danny Boy


3 Answers

As Fede and kennbrodhagen said, this looks like the easiest way (until Facebook fixes this bug):


- (void) dialogCompleteWithUrl:(NSURL*) url
{
    if ([url.absoluteString rangeOfString:@"post_id="].location != NSNotFound) {
        //alert user of successful post
    } else {
        //user pressed "cancel"
    }
}

like image 76
Pavel Alexeev Avatar answered Oct 31 '22 18:10

Pavel Alexeev


My understanding is that

- (void)dialogDidNotComplete:(FBDialog *)dialog;

would be called for the skip.

I haven't tested this theory though.

Edit: I tested it now, and my theory is wrong. The code looks like the dialog should call

- (void)dialogDidNotCompleteWithUrl:(NSURL *)url

on your delegate, but it practise it seems to not do so, as the web page is returning fbconnect://success for a press of the "skip" button. This sounds like a bug to me.

like image 5
Andy J Buchanan Avatar answered Oct 31 '22 16:10

Andy J Buchanan


I did some experimentation and it seems that when the post is submitted you will get two callbacks: dialogCompleteWithUrl and then dialogDidComplete. When the post is skipped, you will only receive the dialogDidComplete callback.

You could trigger your success alert on the dialogCompleteWithUrl callback. If you wanted to wait until you received the dialogDidComplete callback you could save some state during the dialogCompleteWithUrl callback and then based on that state fire your alert in dialogDidComplete.

During my test the url I received during dialogCompleteWithUrl was of the form "fbconnect://success/?post_id=1627754863_182914058401072"

So if need be you could even peek at this value to further confirm your success, although I expect that if the post really did fail (as opposed to a skip) you will get one of the fail callbacks instead.

like image 4
kennbrodhagen Avatar answered Oct 31 '22 16:10

kennbrodhagen