Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8546815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:07:20+00:00 2026-06-11T13:07:20+00:00

I am currently trying to use the PhoneGap LocalNotification Plugin , using Android 4.1

  • 0

I am currently trying to use the PhoneGap LocalNotification Plugin,
using Android 4.1 together with Cordova 2.0.0 and Sketcha (UI Library).

UPDATE #2 20/9/12: I’ve used Bozzzi’s code with some fixes:

  1. Added }) to the end of localnotification.js (syntax error).
  2. changed cordova.define("cordova/plugin/LocalNotification", function(require, exports, module) to:
    cordova.define("cordova/plugin/LocalNotification", function(require, exports, module),
    so the modules name will match for this function (before the module wasn’t found):

    window.plugins.LocalNotification =
    cordova.require(“cordova/plugin/LocalNotification”);

  3. change from this:

    if (!window.plugins) {
    window.plugins = {};
    }
    else if (!window.plugins.LocalNotification) {
    window.plugins.LocalNotification = cordova.require(“cordova/plugin/LocalNotification”);
    }

to this:

if (!window.plugins) {
    window.plugins = {};
}

if (!window.plugins.LocalNotification) {
    window.plugins.LocalNotification = cordova.require("cordova/plugin/LocalNotification");
}

before this change, if window.plugins is not found, it will be created but the window.plugins.LocalNotification wouldn’t.

After all these fixes I am getting this error:

> 09-20 01:22:27.355: D/CordovaLog(8297):
> file:///android_asset/www/index.html: Line 21 : PAPA AMERICANO ready
> 09-20 01:22:27.360: I/Web Console(8297): PAPA AMERICANO ready at
> file:///android_asset/www/index.html:21 09-20 01:22:27.370:
> D/CordovaLog(8297): Uncaught TypeError: Cannot call method 'add' of
> undefined 09-20 01:22:27.375: D/CordovaLog(8297):
> file:///android_asset/www/index.html: Line 35 : Uncaught TypeError:
> Cannot call method 'add' of undefined 09-20 01:22:27.375: E/Web
> Console(8297): Uncaught TypeError: Cannot call method 'add' of
> undefined at file:///android_asset/www/index.html:35 09-20
> 01:22:29.185: D/DroidGap(8297): onMessage(spinner,stop) 09-20
> 01:22:30.255: E/SKIA(8297): FimgApiStretch:stretch failed 09-20
> 01:22:41.755: E/SKIA(8297): FimgApiStretch:stretch failed 09-20
> 01:22:52.565: D/CordovaWebView(8297): >>> loadUrlNow() 09-20
> 01:22:52.565: D/webkit(8297): Firewall not null 09-20 01:22:52.565:
> D/webkit(8297): euler: isUrlBlocked = false

For some reason the cordova.require("cordova/plugin/LocalNotification") dont set the window.plugins.LocalNotification value and it keeps being undefined.
Here is my updated index.html (Update #2):

<!DOCTYPE HTML>
<html manifest="" lang="en-US">
<head>
    <meta charset="UTF-8">
    <title>AndroidSencha</title>
    <script id="microloader" type="text/javascript" src="cordova-2.0.0.js"></script>
    <script id="microloader" type="text/javascript" src="LocalNotification.js"></script>
    <script id="microloader" type="text/javascript">

    function onDeviceReady() {
        if (!window.plugins) {
            window.plugins = {};
        } else if (!window.plugins.LocalNotification) {
            window.plugins.LocalNotification = cordova.require("cordova/plugin/LocalNotification");
        }
    }

    window.document.addEventListener("deviceready", appReady, false);

    function appReady() {
        console.log("PAPA AMERICANO ready");

        var d = new Date();
        d = d.getTime() + 2 * 1000; //60 seconds from now
        d = new Date(d);

        if (!window.plugins) {
            window.plugins = {};
        }

        if (!window.plugins.LocalNotification) {
            window.plugins.LocalNotification = cordova.require("cordova/plugin/LocalNotification");
        }

        window.plugins.localNotification.add({
            date: d,
            message: 'This is an Android alarm using the statusbar',
            id: 123
        });
    }

    </script>
    <style type="text/css">
         /**
         * Example of an initial loading indicator.
         * It is recommended to keep this as minimal as possible to provide instant feedback
         * while other resources are still being loaded for the first time
         */
        html, body {
            height: 100%;
            background-color: #1985D0
        }

    </style>

    <!-- The line below must be kept intact for Sencha Command to build your application -->
    <script id="microloader" type="text/javascript" src="sdk/microloader/development.js"></script>
        <style type="text/css">
.loadingText{
color: white;
font-family: "Avant Garde", Avantgarde, "Century Gothic", CenturyGothic, "AppleGothic", sans-serif;
text-align: center;
font-size: 20px;
padding-top: 10%;
}
</style>
</head>
<body>
    <div id="appLoadingIndicator">
    <div class="loadingText"><div style="margin-bottom: 10px;">Loading, Please wait..</div>
    <div><img src="resources\images\smileloading.gif"></div></div>
    </div>

</body>
</html>

Here is my localnotificaiton.js after my fixes (Update #2):

cordova.define("cordova/plugin/LocalNotification", function(require, exports, module) {      

var exec = require("cordova/exec");
var LocalNotification = function () {};

LocalNotification.prototype.add = function(options) {
            var defaults = {
                date : new Date(),
                message : '',
                ticker : '',
                repeatDaily : false,
                id : ""
            };
        if (options.date) {
                options.date = (options.date.getMonth()) + "/" + (options.date.getDate()) + "/"
                        + (options.date.getFullYear()) + "/" + (options.date.getHours()) + "/"
                        + (options.date.getMinutes());
            }

            for ( var key in defaults) {
                if (typeof options[key] !== "undefined")
                    defaults[key] = options[key];
            }

            cordova.exec(null, null, "LocalNotification", "add",  new Array(defaults));
};

LocalNotification.prototype.cancel = function(notificationId) {
    cordova.exec(null, null, 'LocalNotification', 'cancel', new Array({
        id : notificationId
    }));
};

LocalNotification.prototype.cancelAll = function() {
    cordova.exec(null, null, 'LocalNotification', 'cancelAll', new Array());
};


var LocalNotification = new LocalNotification();
module.exports = LocalNotification
});

UPDATE #1: I’ve already added the plugin to the plugins.xml file:

<plugins>
...
  <plugin name="LocalNotification" value="com.phonegap.plugin.localnotification.LocalNotification"/>
...
</plugins>

I’ve done the steps mentioned here and replaced the broken java expressions as mentioned here.

Unfortunately, when I run the application I get the following error (Both in emulator and device):

09-16 16:46:16.330: E/Web Console(27875): Uncaught ReferenceError:
plugins is not defined at file:///android_asset/www/index.html:74

This guy was facing the same problem but I’ve referenced the cordova javascript file in my index.html and its still not working.

This is how my package explorer looks like (You might find something missing):
I am not sure if I should have plugins.xml or have config.xml and have the plugins in it,
I have both just in case

Package Explorer

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:07:22+00:00Added an answer on June 11, 2026 at 1:07 pm

    I changed LocalNotification.js so you can copy code. It works with cordova 2.0 (tested!)

    cordova.define("cordova/plugin/js/LocalNotification", function(require, exports, module) {      
    
    var exec = require("cordova/exec");
    var LocalNotification = function () {};
    
    LocalNotification.prototype.add = function(options) {
                var defaults = {
                    date : new Date(),
                    message : '',
                    ticker : '',
                    repeatDaily : false,
                    id : ""
                };
            if (options.date) {
                    options.date = (options.date.getMonth()) + "/" + (options.date.getDate()) + "/"
                            + (options.date.getFullYear()) + "/" + (options.date.getHours()) + "/"
                            + (options.date.getMinutes());
                }
    
                for ( var key in defaults) {
                    if (typeof options[key] !== "undefined")
                        defaults[key] = options[key];
                }
    
                cordova.exec(null, null, "LocalNotification", "add",  new Array(defaults));
    };
    
    LocalNotification.prototype.cancel = function(notificationId) {
        cordova.exec(null, null, 'LocalNotification', 'cancel', new Array({
            id : notificationId
        }));
    };
    
    LocalNotification.prototype.cancelAll = function() {
        cordova.exec(null, null, 'LocalNotification', 'cancelAll', new Array());
    };
    
    
    var LocalNotification = new LocalNotification();
    module.exports = LocalNotification;
    

    });

    now you can call the notif. with:

        datum = '2012-09-20 15:51:00';  
    tt1 = datum.split(/[- :]/);
        dd = new Date(tt1[0], tt1[1]-1, tt1[2], tt1[3], tt1[4], tt1[5]);
    
    window.plugins.LocalNotification.add({ date: dd, message: "Some message", ticker : "Some ticker", repeatDaily : false, id: 1234 });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to use the android library android fu to help me
I am currently trying to research how to use Android with an existing java
I'm a beginner coder in Ruby and currently I'm trying to use this plugin:
I am currently trying to use cucumber together with capybara for some integration tests
I'm currently trying to use the core-plot library to graph some data I get
I'm trying to use a Phonegap plugin and am having trouble. This is my
I'm currently trying to use Quicksand, a jquery plugin that allows you to animate
I am currently trying to use the Thrust library and I am having issues
I'm currently trying to use the YouTube API as part of a jQuery plugin
I'm trying to create an Android (2.2) app using Phonegap (version 1.9.0) and jQuery

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.