Shashwat Gupta
Shashwat Gupta

Reputation: 5264

Background mode is not working in ionic 5

Uncaught TypeError: Object(...) is not a function
    at index.js:249
    at Module../node_modules/@ionic-native/background-mode/index.js (index.js:405)
    at __webpack_require__ (bootstrap:84)
    at Module../src/app/app.component.ts (main.js:865)
    at __webpack_require__ (bootstrap:84)
    at Module../src/app/app.module.ts (app.component.ts:30)
    at __webpack_require__ (bootstrap:84)
    at Module../src/main.ts (environment.ts:19)
    at __webpack_require__ (bootstrap:84)
    at Object.0 (main.ts:13)

in package.json

"@angular/core": "^8.2.14",
    "@angular/forms": "^8.2.14",
    "@angular/http": "^7.2.16",
    "@angular/material": "^8.2.3",
    "@angular/platform-browser": "^8.2.14",
    "@angular/platform-browser-dynamic": "^8.2.14",
    "@angular/pwa": "^0.803.23",
    "@angular/router": "^8.2.14",
    "@angular/service-worker": "^8.2.14",
    "@capacitor/android": "^1.5.1",
    "@capacitor/core": "1.5.1",
    "@ionic-native/background-mode": "^4.19.0",
    "@ionic-native/camera": "^5.24.0",
    "@ionic-native/clipboard": "^5.28.0",
    "@ionic-native/core": "5.0.0-beta.15",
    "@ionic-native/deeplinks": "^5.28.0",
    "@ionic-native/file": "^5.22.0-beta-1",
    "@ionic-native/file-path": "^5.22.0-beta-1",
    "@ionic-native/file-transfer": "^5.26.0",

Upvotes: 0

Views: 2446

Answers (2)

Shashwat Gupta
Shashwat Gupta

Reputation: 5264

Check your project type in ionic.config.json file.

If the type is "ionic-angular", then install 4.x.x version.

npm i -s @ionic-native/[email protected]
If the type is "angular", then install 5.x.x-beta version

npm i -s @ionic-native/[email protected]

Credit goes to - Diego Desenvolvedor for this link here

Upvotes: 1

Diego Desenvolvedor
Diego Desenvolvedor

Reputation: 388

Try this:

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

Documentation

Upvotes: 0

Related Questions