<legend id='0bui2'><style id='0bui2'><dir id='0bui2'><q id='0bui2'></q></dir></style></legend>

        <bdo id='0bui2'></bdo><ul id='0bui2'></ul>
        <tfoot id='0bui2'></tfoot>

        <small id='0bui2'></small><noframes id='0bui2'>

        <i id='0bui2'><tr id='0bui2'><dt id='0bui2'><q id='0bui2'><span id='0bui2'><b id='0bui2'><form id='0bui2'><ins id='0bui2'></ins><ul id='0bui2'></ul><sub id='0bui2'></sub></form><legend id='0bui2'></legend><bdo id='0bui2'><pre id='0bui2'><center id='0bui2'></center></pre></bdo></b><th id='0bui2'></th></span></q></dt></tr></i><div id='0bui2'><tfoot id='0bui2'></tfoot><dl id='0bui2'><fieldset id='0bui2'></fieldset></dl></div>
      1. 使用 UIWebView 在 iOS 应用程序中登录 Instagram 时出错

        时间:2023-10-21
      2. <small id='REG1p'></small><noframes id='REG1p'>

          <tbody id='REG1p'></tbody>
        <tfoot id='REG1p'></tfoot>

            <bdo id='REG1p'></bdo><ul id='REG1p'></ul>

                • <legend id='REG1p'><style id='REG1p'><dir id='REG1p'><q id='REG1p'></q></dir></style></legend>
                  <i id='REG1p'><tr id='REG1p'><dt id='REG1p'><q id='REG1p'><span id='REG1p'><b id='REG1p'><form id='REG1p'><ins id='REG1p'></ins><ul id='REG1p'></ul><sub id='REG1p'></sub></form><legend id='REG1p'></legend><bdo id='REG1p'><pre id='REG1p'><center id='REG1p'></center></pre></bdo></b><th id='REG1p'></th></span></q></dt></tr></i><div id='REG1p'><tfoot id='REG1p'></tfoot><dl id='REG1p'><fieldset id='REG1p'></fieldset></dl></div>
                  本文介绍了使用 UIWebView 在 iOS 应用程序中登录 Instagram 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在遵循

                  这里已经有另一个问题了.

                  好像是 Cookies 的问题.不过,我还没有修复它.

                  解决方案

                  我在一个小时前解决了这个问题.

                  首先,不要使用 UIWebView 或 WebView;改用 WKWebView.

                  你看,你需要实现方法

                  - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error

                  当 instagram 的登录页面将您转发到您的 redirect_url 时,它无法导航.可能是因为我们没有进行服务器端身份验证,而只是进行客户端身份验证,并且 redirect_url 不是有效的 url.我们希望页面重定向到一个无效的 url,但是当这种情况发生时,WKWebView 不会调用该方法

                  - (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation

                  或方法

                  - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation

                  所以.您需要做的就是关注第一种方法,检查 error 变量,然后提取 error.userInfo.

                  就我而言,这就是我解决问题的方法:

                  - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error{NSURL *err = [error.userInfo objectForKey:@"NSErrorFailingURLKey"];if([err.absoluteString hasPrefix:INSTA_REDIRECT_URL]){NSString *token = [[err.absoluteString componentsSeparatedByString:@"#access_token="] objectAtIndex:1];[使用 saveToken:token];[self.webView setHidden:YES];//打开下一个视图控制器}别的{//TODO:没有互联网?还有什么问题..NSLog(@"错误: %@", 错误);}}

                  希望对您有所帮助.祝你好运!;)

                  I'm following Instagram authentication [recommended] steps using UIWebView on an iOS app. After entering credentials, hitting login loads a page with following error.

                  This page could not be loaded. If you have cookies disabled in your browser, or you are browsing in private mode, please try enabling cookies or turning off private mode, and then retrying your action.

                  And, this only happens on first run through the steps of authentication; on the next attempt, everything works smooth as silk. I get the code suffixed to redirect url and I request access token using it.

                  Screenshot:

                  There's already another question here and it doesn't help.

                  EDIT: It seems like Cookies issue. Though, I haven't been able to fix it yet.

                  解决方案

                  I managed to solve this problem about an hour ago.

                  First, DON'T use UIWebView or WebView; use a WKWebView instead.

                  You see, you need to implement the method

                  - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error
                  

                  when instagram's login page forwards you to your redirect_url , it FAILS to navigate. Probably because we're not doing the server-side auth, but only the client-side auth, and the redirect_url is not a valid url. We're expecting the page to REDIRECT to an invalid url, but when that happens, the WKWebView doesn't call the method

                  - (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
                  

                  or the method

                  - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
                  

                  So. What you need to do is focus on that first method, check the error variable, and extract error.userInfo.

                  In my case, this is how I solved the problem:

                  - (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error
                  {
                     
                      NSURL *err = [error.userInfo objectForKey:@"NSErrorFailingURLKey"];
                  
                      if([err.absoluteString hasPrefix:INSTA_REDIRECT_URL]){
                          NSString *token = [[err.absoluteString componentsSeparatedByString:@"#access_token="] objectAtIndex:1];
                          
                       
                          [Utils saveToken:token];
                          [self.webView setHidden:YES];
                          //open next view controller
                      }else{
                          //TODO: No internet? something else went wrong..
                          
                          NSLog(@"Error: %@", error);
                      }
                      
                  }
                  

                  Hope it helps. Best of luck! ;)

                  这篇关于使用 UIWebView 在 iOS 应用程序中登录 Instagram 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何从 UIWebView 创建 UIImage 下一篇:Web 应用程序自动重定向到 iOS 问题的初始页面(不应重定向)

                  相关文章

                  <small id='E5ivP'></small><noframes id='E5ivP'>

                    <i id='E5ivP'><tr id='E5ivP'><dt id='E5ivP'><q id='E5ivP'><span id='E5ivP'><b id='E5ivP'><form id='E5ivP'><ins id='E5ivP'></ins><ul id='E5ivP'></ul><sub id='E5ivP'></sub></form><legend id='E5ivP'></legend><bdo id='E5ivP'><pre id='E5ivP'><center id='E5ivP'></center></pre></bdo></b><th id='E5ivP'></th></span></q></dt></tr></i><div id='E5ivP'><tfoot id='E5ivP'></tfoot><dl id='E5ivP'><fieldset id='E5ivP'></fieldset></dl></div>
                        <bdo id='E5ivP'></bdo><ul id='E5ivP'></ul>

                    1. <legend id='E5ivP'><style id='E5ivP'><dir id='E5ivP'><q id='E5ivP'></q></dir></style></legend>
                      <tfoot id='E5ivP'></tfoot>