构建phonegap通知插件时遇到问题

时间:2016-06-09 17:46:39

标签: android ios cordova phonegap-plugins

我是phonegap的新手。我已经安装了Cordova Local-Notification插件。 但我收到错误“无法读取未定义的phonegap的属性'本地'”

这是我的代码

<!DOCTYPE html>
   
<html>
    <head>
        
       <!-- <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">-->
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
    </head>
    <body>
        <div class="appa">
            <h1>Apache Cordovadas</h1>
            <!--<div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>-->
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="phonegap.js"></script>
        <script type="text/javascript" src="../plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js"></script>
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
        <script src="http://localhost:8080/target/target-script-min.js#anonymous"></script>
       <!-- <script type="text/javascript" src="js/index.js"></script>-->
        <script type="text/javascript" charset="utf-8">

    // Call onDeviceReady when PhoneGap is loaded.
    //
    // At this point, the document has loaded but phonegap-1.0.0.js has not.
    // When PhoneGap is loaded and talking with the native device,
    // it will call the event `deviceready`.
    // 
	// A $( document ).ready() block.
	$( document ).ready(function() {
		console.log( "ready!" );
		 
	});
    document.addEventListener('deviceready', function () {
		alert("start");
    // Schedule notification for tomorrow to remember about the meeting
    cordova.plugins.notification.local.schedule({
        id: 10,
        title: "Meeting in 15 minutes!",
        text: "Jour fixe Produktionsbesprechung",
        at: tomorrow_at_8_45_am,
        data: { meetingId:"#123FG8" }
    });

    // Join BBM Meeting when user has clicked on the notification 
    cordova.plugins.notification.local.on("click", function (notification) {
        if (notification.id == 10) {
            joinMeeting(notification.data.meetingId);
        }
    });

    // Notification has reached its trigger time (Tomorrow at 8:45 AM)
    cordova.plugins.notification.local.on("trigger", function (notification) {
        if (notification.id != 10)
            return;

        // After 10 minutes update notification's title 
        setTimeout(function () {
            cordova.plugins.notification.local.update({
                id: 10,
                title: "Meeting in 5 minutes!"
            });
        }, 600000);
    });
	alert("start");
   }
   
   , 
 false);
    </script>

    </body>
</html>

请帮助我解决这个问题,让我暂时坚持到最近3天。

先谢谢。

1 个答案:

答案 0 :(得分:0)

尝试在实际手机或仿真上运行它。 许多插件在浏览器上进行测试时无法完全正常工作。