No provider found for LocalNotifications

Hello Guys,

I am trying to add LocalNotifications in my ionic 2 application. However I am getting below error.

I am using https://ionicframework.com/docs/native/local-notifications/ this tutorial.

Error: No provider for LocalNotifications!
    at NoProviderError.BaseError [as constructor] (http://localhost:8100/build/main.js:9068:34)
    at NoProviderError.AbstractProviderError [as constructor] (http://localhost:8100/build/main.js:55597:16)
    at new NoProviderError (http://localhost:8100/build/main.js:55628:16)
    at ReflectiveInjector_._throwOrNull (http://localhost:8100/build/main.js:104456:19)
    at ReflectiveInjector_._getByKeyDefault (http://localhost:8100/build/main.js:104484:25)
    at ReflectiveInjector_._getByKey (http://localhost:8100/build/main.js:104447:25)
    at ReflectiveInjector_.get (http://localhost:8100/build/main.js:104256:21)
    at AppModuleInjector.NgModuleInjector.get (http://localhost:8100/build/main.js:56312:52)
    at CompiledTemplate.proxyViewClass.AppView.injectorGet (http://localhost:8100/build/main.js:104998:45)
    at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (http://localhost:8100/build/main.js:105240:49)

You haven’t add it to the providers array in the app.module.ts.

Add this line to your app.module.ts header:

import {LocalNotifications} from "@ionic-native/local-notifications";

And add the LocalNotifications to your providers array in app.module.ts:

providers: [
...        
LocalNotifications
...        
]
5 Likes

Let me try. I am now using push notifications which also shows notifications in the notification panel.

Ionic 5 update:

The import should append /ngx (for angular) at the end:

import { LocalNotifications } from '@ionic-native/local-notifications/ngx';