Вопрос

I'm sending a Facebook app-invite from my iOS app, and am trying to implement a success/fail flow using blocks.

I have created a class to wrap my communication with the Facebook SDK which exposes a send invite method.

In that method, I have the following code:

[self.facebook dialog:@"apprequests"
            andParams:params
          andDelegate:self];

as explained in the documentation.

My wrapper class conforms to the FBDialogDelegate protocol, and I have implemented 5 of the delegate methods:

dialog:(FBDialog *)dialog didFailWithError:(NSError *)error, 
dialogCompleteWithUrl:(NSURL *)url, 
dialogDidComplete:(FBDialog *)dialog, 
dialogDidNotCompleteWithUrl:(NSURL *)url 
dialogDidNotComplete:(FBDialog *)dialog

The problem is that wether the user cancels the dialog or sends the request, the only method that is being called is the dialogCompleteWithUrl:(NSURL *)url method. Can anyone explain this?

Это было полезно?

Решение

This seems to be an outstanding issue that has been reported several times. The fact that didComplete is called when the user presses the cancel button is indeed a valid action so it is by design that didComplete gets called. The documentation might be outdated and we have a task to fix it, but reporting a doc bug on our developer site will allow you to track the progress.

So to answer your question, if the user presses the 'x' button it should call didNotComplete. User pressing send or cancel will call didComplete as it is designed that way.

However, this person came up with a good workaround for FBDialog where you can probably do something similar, such as checking the value of the URL when it succeeded vs when the user presses cancel and have an if check that checks for that case.

Hope this helps.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top