2014-06-27 233 views
1

我在IOS中爲phonegap創建了一個項目,我想在我的iOS瀏覽器中打開一個ulr,但不在我的應用程序中。我試圖使用inAppBrowser插件,但它似乎不工作。

我只用.html, .css, .js files and the config.xml,我在Windows和我建立我的在線工具​​phonegap inappbrowser IOS不能正常工作

如果我得到它的正確的項目,根據這個鏈接https: build.phonegap.com/plugins/658有沒有需要安裝要使用該插件,如一些建議與命令cordova plugin add...。您可以通過重寫​​3210文件中的插件來完成您的工作。我對嗎?

我的config.xml文件:

<?xml version="1.0" encoding="UTF-8"?> 

<widget xmlns = " www.w3.org/ns/widgets" 
     xmlns:gap = " phonegap.com/ns/1.0" 
    id = "com.test.testingApp" 
    version = "1.0.0"> 

    <name>test</name> 

    <!-- app icons and splashscreen --> 
    <icon src="icon.png" /> 
    <gap:splash src="splash.png" /> 

    <platform name="android"> 
     <icon density="mdpi" src="res/android/icon-48-hdpi.png" /> 
     <icon density="hdpi" src="res/android/icon-72-hdpi.png" /> 
     <icon density="xhdpi" src="res/android/icon-96-hdpi.png" /> 
     <icon density="xxhdpi" src="res/android/icon-144-hdpi.png" /> 

     <gap:splash gap:density="mdpi" src="splash.png" width="320" height="470" /> 
     <gap:splash gap:density="hdpi" src="splash.png" width="480" height="640" /> 
     <gap:splash gap:density="xhdpi" src="splash.png" width="720" height="960" /> 
     <gap:splash gap:density="xxhdpi" src="splash.png" /> 
    </platform> 

    <platform name="ios"> 
    <!-- iOS 7.0+ --> 
    <!-- iPhone/iPod Touch --> 
     <icon src="res/ios/icon-60.png" width="60" height="60" /> 
     <icon src="res/ios/[email protected]" width="120" height="120" /> 
     <!-- iPad --> 
     <icon src="res/ios/icon-76.png" width="76" height="76" /> 
     <icon src="res/ios/[email protected]" width="152" height="152" /> 
     <!-- iOS 6.1 --> 
     <!-- Spotlight Icon --> 
     <icon src="res/ios/icon-40.png" width="40" height="40" /> 
     <icon src="res/ios/[email protected]" width="80" height="80" /> 
     <!-- iPhone/iPod Touch --> 
     <icon src="res/ios/icon.png" width="57" height="57" /> 
     <icon src="res/ios/[email protected]" width="114" height="114" /> 
     <!-- iPad --> 
     <icon src="res/ios/icon-72.png" width="72" height="72" /> 
     <icon src="res/ios/[email protected]" width="144" height="144" /> 
     <!-- iPhone Spotlight and Settings Icon --> 
     <icon src="res/ios/icon-small.png" width="29" height="29" /> 
     <icon src="res/ios/[email protected]" width="58" height="58" /> 
     <!-- iPad Spotlight and Settings Icon --> 
     <icon src="res/ios/icon-50.png" width="50" height="50" /> 
     <icon src="res/ios/[email protected]" width="100" height="100" /> 
    </platform> 


    <preference name="phonegap-version" value="3.3.0" /> 



    <!-- splashscreen delay --> 
    <preference name="SplashScreenDelay" value="5000" /> 

    <access origin="*" browserOnly="true"/> 

    <!-- <content src=" mysite.com/myapp.html" /> for external pages --> 
    <content src="index.html" /> 

    <preference name="loglevel" value="DEBUG" /> 

    <!-- <preference name="orientation" value="portrait" /> --> 

    <preference name="loadUrlTimeoutValue" value="20000" /> 
    <preference name="InAppBrowserStorageEnabled" value="true" /> 
    <!-- 
    <preference name="splashscreen" value="resourceName" /> 
    <preference name="backgroundColor" value="0xFFF" /> 
    <preference name="loadUrlTimeoutValue" value="20000" /> 
    <preference name="InAppBrowserStorageEnabled" value="true" /> 
    <preference name="disallowOverscroll" value="true" /> 
    <preference name="keepRunning" value="false" /> 
    --> 

    <feature name="App"> 
    <param name="android-package" value="org.apache.cordova.App"/> 
    </feature> 
    <feature name="Geolocation"> 
    <param name="android-package" value="org.apache.cordova.GeoBroker"/> 
    </feature> 
    <feature name="Device"> 
    <param name="android-package" value="org.apache.cordova.Device"/> 
    </feature> 
    <!-- 
    <feature name="Accelerometer"> 
    <param name="android-package" value="org.apache.cordova.AccelListener"/> 
    </feature> 
    <feature name="Compass"> 
    <param name="android-package" value="org.apache.cordova.CompassListener"/> 
    </feature> 
    <feature name="Media"> 
    <param name="android-package" value="org.apache.cordova.AudioHandler"/> 
    </feature> 
    <feature name="Camera"> 
    <param name="android-package" value="org.apache.cordova.CameraLauncher"/> 
    </feature> 
    <feature name="Contacts"> 
    <param name="android-package" value="org.apache.cordova.ContactManager"/> 
    </feature> 
    <feature name="File"> 
    <param name="android-package" value="org.apache.cordova.FileUtils"/> 
    </feature> 
    --> 
    <feature name="NetworkStatus"> 
    <param name="android-package" value="org.apache.cordova.NetworkManager"/> 
    </feature> 
    <feature name="Notification"> 
    <param name="android-package" value="org.apache.cordova.Notification"/> 
    </feature> 
    <!-- 
    <feature name="Storage"> 
    <param name="android-package" value="org.apache.cordova.Storage"/> 
    </feature> 
    <feature name="FileTransfer"> 
    <param name="android-package" value="org.apache.cordova.FileTransfer"/> 
    </feature> 
    <feature name="Capture"> 
    <param name="android-package" value="org.apache.cordova.Capture"/> 
    </feature> 
    <feature name="Battery"> 
    <param name="android-package" value="org.apache.cordova.BatteryListener"/> 
    </feature> 
    --> 
    <feature name="SplashScreen"> 
    <param name="android-package" value="org.apache.cordova.SplashScreen"/> 
    </feature> 
    <feature name="SplashScreen"> 
     <param name="ios-package" value="CDVSplashScreen" /> 
    </feature> 
    <!-- 
    <feature name="Echo"> 
    <param name="android-package" value="org.apache.cordova.Echo"/> 
    </feature> 
    <feature name="Globalization"> 
    <param name="android-package" value="org.apache.cordova.Globalization"/> 
    </feature> 
    --> 
    <feature name="InAppBrowser"> 
     <param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/> 
    </feature> 
    <feature name="InAppBrowser"> 
     <param name="ios-package" value="CDVInAppBrowser" /> 
    </feature> 

    <!-- Deprecated plugins element. Remove in 3.0 --> 
    <plugins> 
     <gap:plugin name="org.apache.cordova.inappbrowser" version="0.3.3" /> 
    </plugins> 
</widget> 


我的index.html文件是:

<html> 
<head>  
    <meta charset="utf-8" /> 
    <meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" /> 

    <title>Hello World</title> 

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script> 
    <script type="text/javascript" charset="utf-8" src="cordova_plugins.js"></script> 

    <link rel="stylesheet" href=" code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css"> 
    <script src=" code.jquery.com/jquery-1.10.2.min.js"></script> 
    <script src=" code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script> 
</head> 

<body> 
<div data-role="page"> 

    <!-- MAIN BODY --> 
    <div data-role="content" role="main" style="padding-bottom:230px;"> 
     <div class="main_header"> 
        <br />  
        <a href="#" onclick="window.open(' www.google.com', '_blank', 'location=yes'); return false;">PlanTech</a> 
        <br />  
        <a href="#" onclick="window.open(' www.google.com', '_system', 'location=no');return false; ">PlanTech</a> 
     </div> 
    </div> 
</div> 

<div id="highlight"></div> 
</body> 
</html> 



的問題是,我的應用程序內的兩個鏈路開放(和不在他們認爲的獨立瀏覽器中)。因此,在沒有結束應用程序並重新啓動它之後,點擊其中一個鏈接後,沒有機會回到我的index.html頁面。

如果有人可以幫我解決這個問題,我將不勝感激,因爲我搜索了幾次互聯網,而且我被卡住了。

在此先感謝大家爲您的時間。

回答

0

最後,我自己找到了我的問題的解決方案。像往常一樣,它在我眼前,但如果我沒有幸運地看到它,我會發現它不是一千年。

由於​​3210本身表明:<!-- Deprecated plugins element. Remove in 3.0 -->

所以我不得不改變如下代碼

<plugins> 
    <gap:plugin name="org.apache.cordova.inappbrowser" version="0.3.3" /> 
</plugins> 


與此:

<gap:plugin name="org.apache.cordova.inappbrowser" version="0.3.3" /> 
1

我對這個... there is no chance to get back to my index.html page after one of the links clicked

一個解決方案,如果你經過完整documentation

1 - 返回窗口對象像

 var ref = window.open ('www.google.com', '_blank', 'location=yes'); 

2 - 添加的事件偵聽器退出事件。

ref.addEventListener(exit, myexitcallback); 

3 - close方法將關閉瀏覽器窗口。因此,在您的功能回調:

function myexitcallback{ 
    ref.close(); 
} 

希望這會解決您的問題。 祝你好運。

+0

這不解決我的問題。鏈接仍然在我的應用程序內部打開,而不是作爲單獨的應用程序。當然,沒有後退按鈕或類似的東西,表示在我的應用程序中返回而無需先退出。 所以我仍然懷疑'如果在config.xml中重新使用插件就足以讓在線構建器在我的應用程序中安裝inAppBrowser插件' – tzes

相關問題