user6930094 user6930094 - 1 year ago 50
iOS Question

How to handle Call Back URL when opening link using a webView

I have a situation here. We are trying to connect Garmin tracker in our app. Now It does not support authentication like Fitbit etc. So we planned to handle it on server Side. Now My Server is giving me a link which I should open in a

or in Safari. User will enter their UserName and Password of Garmin account and when successful it will be send a link of our server. Now server wants to notify me weather the user is successfully logged in or not.

How Can I close the webView or Safari Browser in this case ? Can I provide a callBack URL to my server and server can redirect me to the app ?

Please guide me and instead of downVoting just guide me to a right direction.

Answer Source

you can check callurl as below :

 - (BOOL)webView:(UIWebView *)homeview shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    NSString *URLString = [[request URL] absoluteString];
    if ([URLString Compare:@"callback url"]==NSOrderedSame) {
        self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:2];
    return YES;

from link : If UIWebview url is equal to