cancel
Showing results for 
Search instead for 
Did you mean: 

how to handle the session from the native to webview?

0 Kudos

Hi Experts,

Our mobile APP team is trying to load the website screens on the webview of the native app(specifically the cart & payment page). we are finding difficulties to handle the session from the native to webview. please suggest if anyone has solution.

Thanks and Regards, Subbu.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Subbu & Gernot,

This question has come up in the past and I'm not sure if anyone has solved it successfully. The problem is that the storefront manages the session differently than does OCC. One option might be to pass the token from the web view using javascript, but we've never actually tried it ourselves to see if this works well.

I've seen an answer on stackoverflow that might be of use: http://stackoverflow.com/questions/30108265/use-facebook-ios-sdk-auth-token-in-webview

Posted on Stackoverflow

I am assuming that your question is simply how to pass data from native app to a webview. You can use js. e.g. Suppose this is the code on your webview which uses the access token saved as test.html:

 <html>
   <head></head>
   <body>
       <script type="text/javascript">
         function usesAccessToken(access_token_string) {
          // use access token 
           alert(access_token_string);
         }
         </script>
   </body>
 </html>

You can pass values to the js function in the following manner:

[self.myAppWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"html"]isDirectory:NO]]];

In the UIWebViewDelegate delegate method:

(void)webViewDidFinishLoad:(UIWebView *)webView { NSString *accessToken = [FBSDKAccessToken currentAccessToken].tokenString; NSString *functionToCall = [NSString stringWithFormat:@"usesAccessToken('%@')", accessToken]; [self.myAppWebView stringByEvaluatingJavaScriptFromString:functionToCall]; }

Former Member
0 Kudos

have there ever been response on that. I'm highly interested, too!