question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ionic local notifications TypeError: Object(…) is not a function

See original GitHub issue

WARNING: IF YOU IGNORE THIS TEMPLATE, WE’LL IGNORE YOUR ISSUE. YOU MUST FILL THIS IN!

Provide a general summary of the issue. I got this error after i call the schedule method on localNotifications plugin.

Your Environment

  • Plugin version: ~0.9.0-beta.3
  • Platform: Windows x64
  • OS version: 10
  • Device manufacturer / model: Lenovo Z50-70
  • Cordova version (cordova -v): 8.1.2
  • Cordova platform version (cordova platform ls): Installed platforms: android 7.1.4
  • Plugin config: no config
  • Ionic Version (if using Ionic): 3.9.2

Expected Behavior

It should show me something like this in the console Ionic Native: tried calling StatusBar.styleDefault, but Cordova is not available. Make sure to a) run in a real device or simulator and b) include cordova.js in your index.html

like when trying to use StatusBar in the browser.

Actual Behavior

Uncaught TypeError: Object(...) is not a function at LocalNotifications.schedule (index.js:49) at HomePage.webpackJsonp.76.HomePage.launchNotification (home.ts:76) at home.ts:49 at PrivateChannel.Dispatcher.emit (pusher.js:1596) at PrivateChannel.Channel.handleEvent (pusher.js:3238) at pusher.js:136 at ConnectionManager.Dispatcher.emit (pusher.js:1596) at message (pusher.js:8168) at Connection.Dispatcher.emit (pusher.js:1596) at message (pusher.js:2984) I tried to update @ionic-native and i got the same error, but at the startup of the application.

Steps to Reproduce

  1. ionic cordova plugin add cordova-plugin-local-notification
  2. npm install @ionic-native/local-notifications
  3. add it to the app.module.ts providers from “@ionic-native/local-notifications/ngx”
  4. use it somewhere and call it’s schedule method like this: this.localNotifications.schedule({ title: 'Nouvelle reservation', text: Réservation No ${reservationCode}, data: { reservationId: reservationId, } });

Context

I want to send a notification when a reservation comes : just like this: `import {Component} from ‘@angular/core’; import {NavController} from ‘ionic-angular’; import {SocketsProvider} from “…/…/providers/sockets/sockets”; import {LocalNotifications} from “@ionic-native/local-notifications/ngx”;

@Component({ selector: ‘page-home’, templateUrl: ‘home.html’ }) export class HomePage {

constructor(public navCtrl: NavController, private socket: SocketsProvider, private localNotifications: LocalNotifications) { }

ionViewDidLoad() { this.socket.get().listen(‘ReservationGuideAssigned’, notification => { console.log(notification); this.data.incrementNotificationsCount(1); this.launchNotification(notification.reservation_id, notification.reservation_code); }); }

private launchNotification(reservationId, reservationCode) { this.localNotifications.schedule({ title: ‘Nouvelle reservation’, text: Réservation No ${reservationCode}, data: { reservationId: reservationId, } }); } }`

Debug logs

there is just the console which shown above.

More information

I also tried to work directly with cordova, with code like this :

cordova.plugins.notification.local.schedule(…) but cordova is unknown in the browser, so the application crashes.

please help me, I need to work with ionic native, so that i can test the other components of the application without being blocked by cordova.

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
husainsrcommented, Jan 26, 2019

Please check version in package.json of your local notification if it was 5.0.0 then delete lcal notification inside from node-modules and then changed package.json to 4.7.0 and then run npm install.

I had face this issue this works for me.

0reactions
derweisecommented, Jul 30, 2021

Im also facing this issue

Read more comments on GitHub >

github_iconTop Results From Across the Web

ionic local notifications TypeError: Object(...) is not a function
I got this error after i call the schedule method on localNotifications plugin. import {Component} from '@angular/core'; import {NavController} ...
Read more >
Object(...) is not function, without any specifics plugin information
This is absolute weird, getting this error after fixing some compile problem, not giving any specific plugin error. Object(.
Read more >
Typeerror: Object(..) Is Not A Function At Inapppurchase2.Get
When the JS code runs it tries to call a mobiscroll function, but it's not finding it. Ionic 4/ Angular cli based app...
Read more >
TypeError: Object.fromEntries is not a function - Microsoft Learn
I am trying to setup my dev environment for SPFx development. I ran this command "npm install -g gulp yo @microsoft/generator-sharepoint" and ...
Read more >
Common errors and how to fix them - Mobiscroll Help Center
This error occurs when the Angular/Ionic application's typescript version is ... Error message: ... Plain Javascript: mobiscroll.range is not a function.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found