0

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 UIWebView 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.

Maniganda saravanan
  • 2,188
  • 1
  • 19
  • 35
  • why you are not doing user authentication through web services? why use web view for it? – rohit Sidpara Oct 19 '16 at 06:13
  • what do you mean by webService ? User need to login to their account on the mobile. Like when we connect facebook. We authenticate the user and then move on – user6930094 Oct 19 '16 at 06:42

1 Answers1

0

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

Community
  • 1
  • 1
KKRocks
  • 8,222
  • 1
  • 18
  • 84
  • Actually What i tried is Opend the URL in safari and after loggin in my server redirected me to my App. But safari promted that do you want to open "MyApplication" ? now user say yes an I cam back to my applicatoion. But How Can I detect that is the user is logged in ? – user6930094 Oct 19 '16 at 06:51
  • you need to register URL scheme in your app and post while successful login in safari . and handle url application:openURL:sourceApplication:annotation: in appdelgate – KKRocks Oct 19 '16 at 06:59
  • check url for register url scheme : http://stackoverflow.com/questions/8201724/how-to-register-a-custom-app-opening-url-scheme-with-xcode-4 – KKRocks Oct 19 '16 at 07:00