ios - InAppBrowser 未在 Phonegap 3.1.0 中调用
<p><p>我从 NPM 获取了最新版本的 phonegap 并安装了它。我创建了一个新项目,并根据 PhoneGap <a href="http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface" rel="noreferrer noopener nofollow"></a> 上的文档添加了 InAppBrowser 插件。 .然后我从我的 webapp 进行 JavaScript 调用,但我从来没有看到我在下面编码的警报,也没有看到我在 Xcode 中为插件设置的任何断点。 </p>
<p>这是 JS 的代码:</p>
<pre><code>var pdfViewer = {
loadPdf: function(record, successCallback, errorCallback) {
var filename = record.get('building') + "-" + record.get('floor') + ".pdf";
var url = People.app.srvcUrl + Global.floorPlanUri + filename + "?access_token=" + People.app.bearerToken.access_token;
if (Ext.os.is.iOS) {
// cordova.exec(successCallback, errorCallback, "PDFViewer", "loadRemotePdf", );
var ref = window.open(url, '_blank', 'location=yes');
ref.addEventListener('loadstart', function() { alert("You made it!"); });
} else {
window.open(url, '_system', 'location=yes');
}
}
};
</code></pre>
<p>会发生什么情况是,该 url 被启动以在我现有的应用程序顶部显示一个 PDF,没有警报,也没有位置/关闭按钮。为什么不使用 InAppBrowser 的任何想法?我需要让它显示在一个带有关闭按钮的窗口中。</p>
<p>这是我在运行应用程序时在 Xcode 中看到的输出:</p>
<pre><code>2013-10-23 09:39:02.380 mobile-xxx-ios Multi-tasking -> Device: YES, App: YES
2013-10-23 09:39:02.426 mobile-xxx-ios Unlimited access to network resources
2013-10-23 09:39:02.564 mobile-xxx-ios 0.477016ms
2013-10-23 09:39:02.567 mobile-xxx-ios 0.230014ms
2013-10-23 09:39:02.569 mobile-xxx-ios 0.252008ms
2013-10-23 09:39:02.571 mobile-xxx-ios 7.416010ms
2013-10-23 09:39:02.957 mobile-xxx-ios Resetting plugins due to page load.
2013-10-23 09:39:05.789 mobile-xxx-ios Finished load of: file:///var/mobile/Applications/5916FB20-FDEC-40A7-AE77-9EF14AF30585/mobile-xxx-ios.app/www/index.html
2013-10-23 09:39:18.168 mobile-xxx-ios Resetting plugins due to page load.
2013-10-23 09:39:18.680 mobile-xxx-ios Finished load of: https://pdfs.xxx.com/noauth/plans/x-1.pdf
FAILED to create agar for HelveticaLTMM.
FAILED to create agar for TimesLTMM.
</code></pre>
<p>这是我的 config.xml:</p>
<pre><code><widget xmlns = "http://www.w3.org/ns/widgets"
id = "io.cordova.helloCordova"
version = "2.0.0">
<name>Mobile App</name>
<description>
Mobile Phonegap Application
</description>
<access origin="*" subdomains="true"/>
<content src="index.html" />
<!-- Preferences for iOS -->
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="UIWebViewBounce" value="true" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="EnableLocation" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="OpenAllWhitelistURLsInWebView" value="false" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="false" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<preference name="android-minSdkVersion" value="7" />
<preference name="android-installLocation" value="auto" />
<feature name="SSLSelfCertOverride">
<param name="ios-package" value="SSLSelfCertOverride" />
</feature>
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage"/>
</feature>
<feature name="PhoneDialer">
<param name="ios-package" value="PhoneDialer"/>
<param name="onload" value="true" />
</feature>
<feature name="Sms">
<param name="ios-package" value="Sms"/>
<param name="onload" value="true" />
</feature>
<feature name="EmailComposer">
<param name="ios-package" value="EmailComposer"/>
<param name="onload" value="true" />
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<feature name="PackageInfo">
<param name="ios-package" value="PackageInfo" />
</feature>
<feature name="PDFViewer">
<param name="ios-package" value="PDFViewer" />
</feature>
</widget>
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>请检查以下内容:</p>
<p><strong>第 1 步</strong> </p>
<p>在您的“platforms/ios/www/plugins/”中,是否有“org.apache.cordova.inappbrowser”目录?
如果答案是否定的,则没有添加成功。</p>
<p><strong>解决方案</strong>:创建目录“org.apache.cordova.inappbrowser/www/”,并将“InAppBrowser.js”放入其中。您可以在 PhoneGap 项目根目录“<em>yourproject</em>/plugins/org.apache.cordova.inappbrowser/www/”中找到它。然后转到第 2 步。</p>
<p><strong>第 2 步</strong> </p>
<p>打开“platforms/ios/www/cordova_plugins.js”。在“module.exports”中,添加:</p>
<pre><code> {
"file": "plugins/org.apache.cordova.inappbrowser/www/InAppBrowser.js",
"id": "org.apache.cordova.inappbrowser.InAppBrowser",
"clobbers": [
"window.open"
]
}
</code></pre>
<p>在“module.exports.metadata”中,添加:</p>
<pre><code> "org.apache.cordova.inappbrowser": "0.2.5"
</code></pre>
<p>并保存。 “0.2.5”是插件的版本,可以在plugin.xml中找到。 (看起来这个数字无关紧要。)</p>
<p>然后运行它,打开检查器并检查“InAppBrowser.js”是否已成功添加到 head 标签中。 </p>
<p><strong>注意:</strong>在不修改“cordova_plugins.js”的情况下手动将“InAppBrowser.js”添加到head标签中将不起作用。如果1的回答是肯定的,直接进入步骤2。</p>
<p>希望这能解决您的问题。</p></p>
<p style="font-size: 20px;">关于ios - InAppBrowser 未在 Phonegap 3.1.0 中调用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/19530598/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/19530598/
</a>
</p>
页:
[1]