How to restrict UIWebView to a specific facebook user page

I am creating a UIWebView to load a specific facebook page:

NSString *urlAddress = [NSString stringWithFormat:@"http://www.facebook.com/%@",self.userID]; //Create a URL object. NSURL *url = [NSURL URLWithString:urlAddress]; //URL Requst Object NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; //Load the request in the UIWebView. [webView loadRequest:requestObj]; 

I need to know how to intercept the UIWebView navigation so that it only loads the URL of this particular user page. For example, this will allow navigation on the Wall page, Info and Photos page of this user ID.

I tried to use the delegate method shouldStartLoadWithRequest: It works well when a user clicks on external links such as Youtube or something else, but this method is never called if, say, the user clicks the homebook home button, which redirects to the main page of a registered user who is not the corresponding user of the identifier user passed in the url.

Any help? Thank you very much!

+4
source share
1 answer

You should be able to use NSURLProtocol to intercept requests and filter only those that match the criteria for viewing.

http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSURLProtocol_Class/Reference/Reference.html

0
source

All Articles