In the previous post we showed off the code that allowed us to login into the Facebook and like a company. Here is the iOS version.
- (void)viewDidLoad {
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://m.facbook.com"]
[super viewDidLoad]
]];
;
}
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
NSURL *url = [request URL];
if([[url absoluteString] hasPrefix:@”https://m.facebook.com/home.php”]){
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@”http://www.facebook.com/translucent.computing”]]];
}
return YES;
}
The above code loads the Facebook login screen when the controller loads. After the user logs in the code redirects to the company website. This controller has only one outlet, UIWebview. The controller also implements the UIWebViewDelegate, shouldStartLoadingWithRequest is one of the delegate methods. We also added a header to the controller with a Facebook logout button that also closes the controller.
June 13th, 2012
by Patryk Golabek in Technology
⟵ Back
See more:
December 10th, 2021
Cloud Composer – Terraform Deploymentby Patryk Golabek in Data-Driven, Technology
December 2nd, 2021
Provision Kubernetes: Securing Virtual MachinesAugust 6th, 2023
The Critical Need for Application Modernization in SMEs