我尝试在我的phonegap /离子应用程序中包含Push服务,但我卡住了,案例是:我按照教程,我从其他人那里搜索 教程,并有教程,显示相同的插件和方法的用法,插件是https://github.com/phonegap/phonegap-plugin-push, 我接受了错误:
Uncaught ReferenceError: cordova is not defined
代码
...
var PushNotification = function() {
};
// Call this to register for push notifications. Content of [options] depends on whether we are working with APNS (iOS) or GCM (Android)
PushNotification.prototype.register = function(successCallback, errorCallback, options) {
if (errorCallback == null) { errorCallback = function() {}}
if (typeof errorCallback != "function") {
console.log("PushNotification.register failure: failure parameter not a function");
return
}
if (typeof successCallback != "function") {
console.log("PushNotification.register failure: success callback parameter must be a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]);
};
...
我在index.html文件上的导入
...
<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>
<!-- your app's js -->
<script src="js/app.js"></script>
<script src="js/angular-datepicker.js"></script>
<script src="js/controllers.js"></script>
<script src="js/canvas-to-blob.min.js"></script>
<script src="js/RequestsService.js"></script>
<!-- Script for push -->
<script type="text/javascript" charset="utf-8" src="js/PushNotification.js"></script>
...
在PushNotification.js上没有名称 cordova 的变量,我下载了Push的示例,PushNotification.js与我的完全相同, 教程说如果cordova.js导入,必须在PushNotification.js之前,这是正确的,我注意到没有cordova.js文件 在Ionic的默认目录中,我尝试手动插入并引用它,但错误仍然发生,我记住,这个cordova.js是 自动加载Ionic,并且PushNotification.js在该javascript文件中有一个可见的cordova引用,我是一个想法,某人 用Ionic和Phonegap和Push传递这个问题?