Reputation: 141
I am using Xcode for a social media network site and I have a quick about the login/ signup process. For instance, I have a UIWebView that is linked to the login API page. (ex. www._.com/api_login.php?) When the user logs in with their credentials on that page the website redirects them to the success page (www._.com/api_success.php?) with the API authentication token that is stored in the iOS app for user specific tasks embedded in the website source code.
Here is my question: How can I tell Xcode to execute Javascript to grab the authentication token once it is on the (www._.com/api_success.php?) page? Keep in mind that the URL is specific to the user and has a user specific api key at the end of the link. (www._.com/api_success.php?apiconnectkey=123456789)
Thanks in advance for help with this, Technology Guy
Upvotes: 2
Views: 4708
Reputation: 89172
I'm not sure I follow 100%, but here are some things to look at:
Implement UIWebViewDelegate in your view controller and set the delegate property, then implement this message
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:
Docs
This will let you see each URL that is being set on the web view. So, you could grab apiconnectkey.
Also, you can execute JavaScript on the page with
[self.webView stringByEvaluatingJavaScriptFromString:@"getToken()"]
where getToken()
is a function on the page. This will return a string.
Upvotes: 4