Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: undefined is not an object (evaluating 'cordova.plugins.notification.local') #1281

Closed
acgodoi opened this issue Apr 27, 2017 · 17 comments

Comments

@acgodoi
Copy link

acgodoi commented Apr 27, 2017

Hi guys,

I get this error when trying to schedule a local notification.

I am trying very hard to set this up but i still have this message:

[console.log] TypeError: undefined is not an object (evaluating 'cordova.plugins.notification.local')

I am using this version:

phonegap plugin add https://github.com/katzer/cordova-plugin-local-notifications#ios10

The test is been made on "phonegap app" on iphone, but i get the same message testing on a android device.

It seems to be some problem with the plugin instalation, but I did it with the command line above.

onDeviceReady: function() {
var d = new Date();
var now = d.getTime();
try{
cordova.plugins.notification.local.schedule({
id : "2",
at: new Date(now + 10000),
text : "Testing 1..2..3"
});
} catch (e) {
console.log(e);
alert(e);
}

},
@hanene2030
Copy link

iOS or android?
i did have same problem first time i use plugin

You have to be sure that your plugin is well installed

i remmenber after removing adding the platform it does work
if this doesn't work find the javascript of the plugin put a simple alert to be sure that the js is loaded correctly

@rwillett
Copy link
Collaborator

Uninstall and reinstall the plugin. Something has gone wrong at the sort of level. You also should check the the plugin is initialised.

@rwillett
Copy link
Collaborator

Normally you just install the plugin and thats it. Sometimes you get a bad download and that screws thing up.

I've never had to reinstall the platform for this plugin. Other plugins yes, but not that one. YMMV.

@hanene2030
Copy link

@rwillett i am not sure if it was or not this plugin :)
so maybe just a "Uninstall and reinstall the plugin " as u said will resolve this problem

@rwillett
Copy link
Collaborator

rwillett commented Apr 27, 2017

If its working I'll close this issue.

@hanene2030
Copy link

@rwillett maybe wait for @acgodoi answer
i just wanted to help him

@rwillett rwillett reopened this Apr 27, 2017
@rwillett
Copy link
Collaborator

Sorry, got the wrong person.

@acgodoi
Copy link
Author

acgodoi commented Apr 27, 2017

I am testing on a iPhone device, via Phonegap APP.
..
This is getting me crazy, because I have tried a lot of thing and it is not working.
...
I created a app by?
phonegap app create testApp
phonegap platform add ios --save
phonegap platform add android --save
phonegap plugin add https://github.com/katzer/cordova-plugin-local-notifications#ios10
...
www/js/index.js
onDeviceReady: function() {
var d = new Date();
var now = d.getTime();
try{
cordova.plugins.notification.local.schedule({
id : "2",
at: new Date(now + 10000),
text : "Testing 1..2..3"
});
} catch (e) {
console.log(e);
alert(e);
}
.....
...
I put some alerts and console.log in the files (but got nothing):
plugins/de.appplant.cordova.plugin.local-notification/www/local-notification.js
plugins/de.appplant.cordova.plugin.local-notification/www/local-notification-core.js
plugins/de.appplant.cordova.plugin.local-notification/www/local-notification-util.js

@rwillett
Copy link
Collaborator

Fill out #1188 as you gave not provided anywhere near enough information. Also don't use npm to install.

You sound like you are using Phonegap. Are you?

@acgodoi
Copy link
Author

acgodoi commented Apr 27, 2017

Yes!! I am using Phonegap!!

How can I install not using npm?

[]s

@acgodoi
Copy link
Author

acgodoi commented Apr 28, 2017

Hi!!

Thank you guys for your patience and here is the form filled.

I would like to know how can i install the plugin not using npm, and the 'best pratices' to get it working fine. I can see people here using it and i'm excidted to use it too. Mobile development is a new world for me.

Plugin version: 0.8.5 (https://github.com/katzer/cordova-plugin-local-notifications#ios10)

Platform: Android / iOS

OS version: Windows 10

Device manufacturer / model: Samsung Galaxy S3 / iPhone 5

Cordova version (cordova -v): (phonegap -v) 6.5.0

Cordova platform version (cordova platform ls):

Installed platforms:
android 6.1.2
browser 4.1.0
ios 4.3.1
Available platforms:
amazon-fireos ~3.6.3 (deprecated)
blackberry10 ~3.8.0
firefoxos ~3.6.3
webos ~3.7.0
windows ~4.4.0
wp8 ~3.8.2 (deprecated)

**Plugin config:**

installed with:
phonegap plugin add https://github.com/katzer/cordova-plugin-local-notifications#ios10

in file INDEX.JS
...
onDeviceReady: function() {
var d = new Date();
var now = d.getTime();
try{
cordova.plugins.notification.local.schedule({
id : "2",
at: new Date(now + 10000),
text : "Testing 1..2..3"
});
} catch (e) {
console.log(e);
alert(e);
}
...

Expected Behavior

Pop up local notification 'Testing 1... 2... 3"

Tell us what should happen

I expect notification to show up.

Actual Behavior

Tell us what happens instead

The code flows to "catch" section and the exception is:
TypeError: undefined is not an object (evaluating 'cordova.plugins.notification.local')

Steps to Reproduce

Put the code above in OnDeviceReady section of index.js

Start up phonegap server with the command:
phonegap serve

Access the server via PHONEGAP MOBILE APP

In this point, i get the error:
TypeError: undefined is not an object (evaluating 'cordova.plugins.notification.local')

Reproduce this issue; include code to reproduce, if relevant

Context
What were you trying to do?
Debug logs

I do not use xCode or adb

Include iOS / Android logs

ios XCode logs
Android: $ adb logcat

@Tawpie
Copy link

Tawpie commented Apr 28, 2017 via email

@rwillett
Copy link
Collaborator

@Tawpie

I don't use phonegap but this sounds like not checking for device ready. I'd be interested in the response.

@rwillett
Copy link
Collaborator

Why is onDeviceReady a function on a JSON element? Is that how phonegap does things?

@rwillett
Copy link
Collaborator

rwillett commented May 8, 2017

Closed as no update from original poster.

@rwillett rwillett closed this as completed May 8, 2017
@j4hangir
Copy link

Not working here neither, cordova.plugins is itself always undefined.

@davidseek
Copy link

davidseek commented Jun 11, 2019

Got this issue with Ionic 4, capacitor, iOS and https://github.com/triniwiz/capacitor-datepicker

Fixed it, by removing the compiled ios folder, building again, and adding ios with capacitor again.
Had to fix tiny stuff in Xcode then due to outdated syntax. But overall works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants