我试图从我的应用程序中邀请Facebook好友。
它适用于webDialog
。但是当我点击发送按钮时,它会给出
例外
WebKit丢弃了一个未被捕获的异常 web视图:decidePolicyForNavigationAction:请求:帧:decisionListener: 委托:+ [NSInvocation _invocationWithMethodSignature:frame:]:方法签名参数不能为nil
我无法理解我的代码有什么问题。这是我正在使用的代码
-(void)inviteFriends
{
if ([[FBSession activeSession] isOpen])
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:@"Sending from facebook chat"
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
[self requestFailedWithError:error];
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
[self requestFailedWithError:nil];
}
else if([[resultURL description] hasPrefix:@"fbconnect://success?request="])
{
// Facebook returns FBWebDialogResultDialogCompleted even user
// presses "Cancel" button, so we differentiate it on the basis of
// url value, since it returns "Request" when we ACTUALLY
// completes Dialog
[self requestSucceeded];
}
else
{
// User Cancelled the dialog
[self requestFailedWithError:nil];
}
}
}
];
}
else
{
/*
* open a new session with publish permission
*/
[FBSession openActiveSessionWithPublishPermissions:[NSArray arrayWithObject:@"publish_stream"]
defaultAudience:FBSessionDefaultAudienceFriends
allowLoginUI:YES
completionHandler:^(FBSession *session, FBSessionState status, NSError *error)
{
if (!error && status == FBSessionStateOpen)
{
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:nil];
[FBWebDialogs presentRequestsDialogModallyWithSession:nil
message:@"Sending from facebook chat"
title:nil
parameters:params
handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error)
{
if (error)
{
[self requestFailedWithError:error];
}
else
{
if (result == FBWebDialogResultDialogNotCompleted)
{
[self requestFailedWithError:nil];
}
else if([[resultURL description] hasPrefix:@"fbconnect://success?request="])
{
// Facebook returns FBWebDialogResultDialogCompleted even user
// presses "Cancel" button, so we differentiate it on the basis of
// url value, since it returns "Request" when we ACTUALLY
// completes Dialog
[self requestSucceeded];
}
else
{
// User Cancelled the dialog
[self requestFailedWithError:nil];
}
}
}];
}
else
{
[self requestFailedWithError:error];
}
}];
}
}
// These methods for requestSucceeded and requestFailed
- (void)requestSucceeded
{
NSLog(@"requestSucceeded1");
id owner = [_fbDelegate class];
SEL selector = NSSelectorFromString(@"OnFBSuccess");
NSMethodSignature *sig = [owner instanceMethodSignatureForSelector:selector];
_callback = [NSInvocation invocationWithMethodSignature:sig];
[_callback setTarget:owner];
[_callback setSelector:selector];
[_callback invokeWithTarget:_fbDelegate];
}
- (void)requestFailedWithError:(NSError *)error
{
NSLog(@"requestFailed");
id owner = [_fbDelegate class];
SEL selector = NSSelectorFromString(@"OnFBFailed:");
NSMethodSignature *sig = [owner instanceMethodSignatureForSelector:selector];
_callback = [NSInvocation invocationWithMethodSignature:sig];
[_callback setTarget:owner];
[_callback setSelector:selector];
[_callback setArgument:&error atIndex:2];
[_callback invokeWithTarget:_fbDelegate];
}
-(void)OnFBSuccess
{
NSLog(@"successful");
}
-(void)OnFBFailed:(NSError *)error
{
if(error == nil)
NSLog(@"user cancelled");
else
NSLog(@"failed");
}
我也在宣布
@protocol FBLoginDelegate <NSObject>
viewController.h
。我不知道代码有什么问题。任何人都可以 请帮我解决这个问题? Here is the webDialog appearing with friend list but when i click on send.It doesn't send any message.