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
}
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"
}
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With