如何在 PhoneGap 中使用 Intent 处理传入内容
How to handle incoming content with Intent in PhoneGap
我正在构建 PhoneGap 应用程序。
我已成功将 Intent 过滤器添加到 AndroidManifest.xml,当使用指定的方案和主机单击 link 时,我的应用程序在能够打开 [=55] 的应用程序列表中=].
至此就完美了。
现在,当我的应用程序启动时,我想检测是哪个 link 启动了我的应用程序。
所以,如果有两个 link:
示例。com/temrs
示例。com/contact
我想知道是哪个元素启动了应用,以便在应用中显示相关内容。
我试过很多插件都没有成功。
插件:cordova-plugin-intent
https://github.com/napolitano/cordova-plugin-intent
我已经安装了这个插件。我的 config.xml 有这个:
<plugin name="com.napolitano.cordova.plugin.intent" spec="https://github.com/napolitano/cordova-plugin-intent" />
在index.html中,我有:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
在index.js中,我添加了这个:
document.addEventListener('deviceReady', function(){
window.plugins.intent.getCordovaIntent(function (Intent) {
console.log(Intent);
}, function () {
console.log('Error');
});
});
我在控制台中收到此错误:
Uncaught TypeError: Cannot read property 'getCordovaIntent' of undefined
我研究了两天,真希望有人能给我一个解决方案。
查看 Eddy 的 cordova-plugin-customurlscheme,它是 Cordova 中自定义 Url 方案的实际插件:
<plugin name="cordova-plugin-customurlscheme" />
我正在构建 PhoneGap 应用程序。
我已成功将 Intent 过滤器添加到 AndroidManifest.xml,当使用指定的方案和主机单击 link 时,我的应用程序在能够打开 [=55] 的应用程序列表中=].
至此就完美了。
现在,当我的应用程序启动时,我想检测是哪个 link 启动了我的应用程序。
所以,如果有两个 link:
示例。com/temrs
示例。com/contact
我想知道是哪个元素启动了应用,以便在应用中显示相关内容。
我试过很多插件都没有成功。
插件:cordova-plugin-intent
https://github.com/napolitano/cordova-plugin-intent
我已经安装了这个插件。我的 config.xml 有这个:
<plugin name="com.napolitano.cordova.plugin.intent" spec="https://github.com/napolitano/cordova-plugin-intent" />
在index.html中,我有:
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
在index.js中,我添加了这个:
document.addEventListener('deviceReady', function(){
window.plugins.intent.getCordovaIntent(function (Intent) {
console.log(Intent);
}, function () {
console.log('Error');
});
});
我在控制台中收到此错误:
Uncaught TypeError: Cannot read property 'getCordovaIntent' of undefined
我研究了两天,真希望有人能给我一个解决方案。
查看 Eddy 的 cordova-plugin-customurlscheme,它是 Cordova 中自定义 Url 方案的实际插件:
<plugin name="cordova-plugin-customurlscheme" />