2012-07-04 3 views
0

Google과 같은 앵커 태그를 사용하여 외부 링크에 연결하려고합니다.iOS PhoneGap에서 외부 링크 열기

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{ 
    NSURL *url = [request URL]; 

    // Intercept the external http requests and forward to Safari.app 
    // Otherwise forward to the PhoneGap WebView 
    if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) { 
     [[UIApplication sharedApplication] openURL:url]; 
     return NO; 
    } 
    else { 
     return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ]; 
    } 
} 

하지만 난 여전히 구글 ... 오전에 링크 할 수 없습니다 오전 :

그렇게하기 위해, 나는 (: https://gist.github.com/2012253 코드는 여기에서이다) appDelegate.m이 코드를 추가 뭔가 잘못하고 있는거야? 도움이 필요해.

+0

'ExtrernalHosts' 속성을 올바르게 설정 했습니까 ?? 귀하의 응용 프로그램에서 귀하의 URL 열기 ?? – dhaval

+0

URL이 앱에서 열리지 않고 있습니다 ... 어떻게 외부 호스트를 설정 하시겠습니까? – lakesh

+0

을 Cordova.plist 파일에 넣으세요. 자세한 내용은 http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide – dhaval

답변

1

ExternalHosts 속성이 Cordova.plist 파일에 올바르게 설정되어 있는지 확인하십시오. ExternalHosts는 응용 프로그램에서 액세스 할 수 있도록 허용 목록에 포함 된 호스트의 배열입니다.

구글 (HTTP 및 HTTPS)

google.com 

http://docs.phonegap.com/en/1.9.0/guide_whitelist_index.md.html#Domain%20Whitelist%20Guide

예를 들어, 내 데모 애플리케이션 내가 코르도바 1.7 MainViewController.m 코드의 조각을 사용했다 here

+0

ExternalHosts가 될 필요가 지정 ... 더 도움이 될 수 있습니다 .. 그게 왜 ... – lakesh

0

확인합니다. 0 cordova 1.9.0 및 cordova 2.1.0 그리고 꽤 잘 작동합니다. 이 코드를 올바른 파일로 옮기면됩니다.