Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I open an URL(a Facebook page) in a FBDialog or something in FBConnect?

I am struggling to find this. Can I open a URL in a FBDialog or using something in FBConnect. I tried to do it like the following. But it doesn't seem to be working.

FBDialog *dlg = [FBDialog new];
[dlg loadURL:@"http://www.facebook.com/pages/Apple-Inc/137947732957611" get:nil];

I don't even know whether this is possible or not. Can you guys please help me?

like image 257
EmptyStack Avatar asked Oct 23 '22 17:10

EmptyStack


1 Answers

There are 2 problem to prevent you from your code. First, when you pass a url to -loadURL:get: method, Facebook iOS SDK rebuild the real url base on yours. So, the url you passed will not get into the webview finally. What you need to do is implementing a method in FBDialog.m like this:

-(void)hackLoadURL:(NSString*)url withDelegate:(id)delegate {
    _webView.delegate = delegate;
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}

The second problem is that you need to hack the

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

delegate method and replaced with the one you make implementation. But in order to keep the original Facebook SDK works, you need to add below code to FBDialog.m

_webView.delegate = self;

within -loadURL:get: method, and before this line

[_webView loadRequest:request];

finally, you need to implement

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

yourselves in your class, and use

FBDialog *dlg = [FBDialog new];
[dlg hackLoadURL: yourExpectUrl withDelegate: self];

to do what you wanted.

like image 65
GeFo.GT Avatar answered Oct 31 '22 09:10

GeFo.GT