0

I have an existing native android application. I need to implement a local notification on trigger of some event on webview. Here, i am using cordova plugin using jar file. I have performed the following: 1. Copied the java files of plugin(de.appplant.cordova.plugin.localnotification) in src folder 2. copied the cordova.js and localNotification.js in assets folder 3. added plugin in config.xml code snippet in local js file:

 window.plugin.notification.local.add({
id:         7,  // A unique id of the notifiction
date:       now,    // This expects a date object
message:    "Yup! tHiS iS nOtIfiCaTioN..",  // The message that is displayed
title:      "Notify user",  // The title of the message
repeat:     'hourly',  // Either 'secondly', 'minutely', 'hourly', 'daily', 'weekly', 'monthly' or 'yearly'
autoCancel: true, // Setting this flag and the notification is automatically canceled when the user clicks it
ongoing:    false, // Prevent clearing of notification (Android only)

});

I am getting error as "Uncaught type error: cannot read property "notification"of undefined at line(Where i had written the code to refer plugin)

I have to integrate a web-application into existing native application using webView and generate local notifications based on some events triggered from web application.

Appreciate help!!!

  • What version of cordova are you using? You're supposed to use either the cli or plugman to addd plugins, not just copy files. – QuickFix Dec 02 '14 at 10:24
  • I'm not so sure about how to handle plugins when you use the webview in an existing app... maybe have a look at this post about discussion about files to update when adding plugins manually : http://stackoverflow.com/questions/27099507/what-is-the-correct-way-to-manually-add-cordova-plugin-to-cordova-project – QuickFix Dec 02 '14 at 10:27
  • @Quickfix, i have to integrate a URL on webView in native application. I am not creating a new application. I am trying to add plugins to an existing native app.It is not a pure cordova application. Please provide any inputs on this requirement. Thanks for looking into this query. –  Dec 02 '14 at 10:30
  • even if you're using a webview, don't you have a config.xml file to configure cordova? (should be /res/xml/config.xml) – QuickFix Dec 02 '14 at 10:41
  • Entry for using local notification plugin is present in the config.xml file. –  Dec 02 '14 at 12:42
  • So you have ``lines in config.xml, cordova_plugin.js file in assesss/www, java files in src, required athorisations in the manifest? – QuickFix Dec 02 '14 at 12:55
  • @Quickfix, I have all the files in place. i have checked the js files as well and they are getting loaded properly. Now, i am getting exception as "channel not fired: onCordovaInfoReady". I think, i am missing somewhere in adding cordova properties to the native app. Could you please provide any pointer on transforming an existing native app to use cordova plugins. Thanks for your help!!! –  Dec 03 '14 at 06:53

0 Answers0