Uncaught TypeError:无法读取属性“OneSignal”的未定义",source:file:/// android_asset / www / js / app [英] Uncaught TypeError: Cannot read property 'OneSignal' of undefined", source: file:///android_asset/www/js/app

查看:660
本文介绍了Uncaught TypeError:无法读取属性“OneSignal”的未定义",source:file:/// android_asset / www / js / app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将OneSignal初始化为PhoneGap应用程式。我试过很多方法。但总是它给出未捕获TypeError:无法读取属性OneSignal未定义,源:file:///android_asset/www/js/app.js 错误。

I'm trying to initialize OneSignal to a PhoneGap application. I tried many ways. But always it gives "Uncaught TypeError: Cannot read property 'OneSignal' of undefined", source: file:///android_asset/www/js/app.js error.

这是我的app.js档案

This is my app.js file

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
oneSignal();
checkConnection();}

function oneSignal(){
console.log("It is calling");
    var notificationOpenedCallback = function(jsonData) {
        console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
    };

    window.plugins.OneSignal.init("my app id",
                             {googleProjectNumber: "my project number"},
                             notificationOpenedCallback);



 // Show an alert box if a notification comes in when the user is in your app.
    window.plugins.OneSignal.enableInAppAlertNotification(true);}

有人请帮助我初始化OneSignal到我的PhoneGap应用程序。

Somebody please help me to initialize OneSignal to my PhoneGap application.

推荐答案

只需尝试安装你的插件,Cross验证它的可用性在 plugins 文件夹。还请确认在 config.xml fetch.json (在plugins文件夹中)进行了相应的更新。

Just try installing your plugin, Cross verify for it's availablity in the plugins folder. Also confirm the corresponding update has been made in config.xml and fetch.json (in the plugins folder). The error usually arises in case the plugin is not installed properly.

希望这有助于...)

这篇关于Uncaught TypeError:无法读取属性“OneSignal”的未定义",source:file:/// android_asset / www / js / app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆