V. Pivet
V. Pivet

Reputation: 1328

Ionic 2 : Background mode error

I try to use this for Ionic 2 : https://ionicframework.com/docs/native/background-mode/

I ran the two command

$ ionic plugin add cordova-plugin-background-mode
$ npm install --save @ionic-native/background-mode

And I tried to declare the provider in my app.module.ts :

import {BackgroundMode} from "@ionic-native/background-mode";
 providers: [
    {provide: ErrorHandler, useClass: IonicErrorHandler},
    ...
      BackgroundMode
    ...
  ]

But when I run it on my device I have this error :

[INFO:CONSOLE(140848)] "Uncaught Error: Cannot find module "@ionic-native/core"", source: file:///android_asset/www/build/main.js (140848)

And an infite white screen on my device.

I tried to use it without declare in my app.module.ts and directly in my component but I had same error...

Someone know how to solve it ?

Upvotes: 1

Views: 1954

Answers (1)

Suraj Rao
Suraj Rao

Reputation: 29614

If you are using @ionic-native/background-mode it means you are using ionic-native 3.x.

You need to do:

npm install @ionic-native/core --save

Also you no longer need the ionic-native 2.x package. You can remove it from your package.json in case you have it.

Check the main page of ionic-native docs

Upvotes: 2

Related Questions