2014-06-27 120 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

相关问题