katzer / cordova-plugin-background-mode

Keep app running in background
Apache License 2.0
1.38k stars 1.02k forks source link

Android 14 #596

Open Aliexpress2401 opened 1 month ago

Aliexpress2401 commented 1 month ago

Hi, i fixed the pending indent problem and it works on android 13, but now on samsung with android 14 it didn't work and it crashes my app. Someone knows how to help me?

thallesgomesmelo commented 1 month ago

Hi, I also had this problem. But this fork helped me https://github.com/brunochikuji/cordova-plugin-background-mode.git

Neelam1990 commented 2 days ago

By using this, the play console is requiring me to declare tasks and provide videos for foreground services. Is there an alternative way to avoid this process?

Aliexpress2401 commented 2 days ago

@Neelam1990 I used it and I didn't had this problem. Are you working on Android or iOS? For Android have you added the android permissions like:

android.permission.FOREGROUND_SERVICE" android.permission.WAKE_LOCK" android.permission.FOREGROUND_SERVICE_DATA_SYNC"

in the AndroidManifest?

For iOS insted you have to add keys: • BGTaskSchedulerPermittedIdentifiers and • UIBackgroundModes

in the (nameoftheproject)-Info.plist

Neelam1990 commented 2 days ago

Yes, these permissions are already available in my AndroidManifest.xml. I'm sorry I forgot to mention that I'm asking for Android and google play console forcing to declare tasks and provides video for foreground services. An exact error is: Your app uses the FOREGROUND_SERVICE_DATA_SYNC permission. You can only use this permission if your app performs tasks noticeable to the user when they're not directly interacting with your app.

Aliexpress2401 commented 2 days ago

@Neelam1990 can I ask you what is your goal for your project to understand better? Just to make sure have you added the plugin in the quasar.config.js?

Neelam1990 commented 2 days ago

This plugin is being used by me to continuously play my music audios in background mode. After implementing the functionality, I uploaded it to the Google Play console and it shows the message that I mentioned earlier. Can you tell me the location of quasar.config.js in the ionic Cordova project? Thank you for this quick help.

Aliexpress2401 commented 2 days ago

@Neelam1990 Ok, that's mine:

const { configure } = require("quasar/wrappers"); const path = require("path");

module.exports = configure(function (/ ctx /) { return { eslint: { // fix: true, // include: [], // exclude: [], // rawOptions: {}, warnings: true, errors: true, },

// https://v2.quasar.dev/quasar-cli-vite/prefetch-feature
// preFetch: true,

// app boot file (/src/boot)
// --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli-vite/boot-files
boot: ["i18n", "axios", "background"],

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: ["app.scss"],

// https://github.com/quasarframework/quasar/tree/dev/extras
extras: [
  // 'ionicons-v4',
  // 'mdi-v5',
  "fontawesome-v6",
  // 'eva-icons',
  // 'themify',
  // 'line-awesome',
  // 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!

  "roboto-font", // optional, you are not bound to it
  "material-icons", // optional, you are not bound to it
],

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#build
build: {
  target: {
    browser: ["es2019", "edge88", "firefox78", "chrome87", "safari13.1"],
    node: "node16",
  },

  vueRouterMode: "hash", // available values: 'hash', 'history'
  // vueRouterBase,
  // vueDevtools,
  // vueOptionsAPI: false,

  // rebuildCache: true, // rebuilds Vite/linter/etc cache on startup

  // publicPath: '/',
  // analyze: true,
  // env: {},
  // rawDefine: {}
  // ignorePublicFolder: true,
  // minify: false,
  // polyfillModulePreload: true,
  // distDir

  // extendViteConf (viteConf) {},
  // viteVuePluginOptions: {},

  vitePlugins: [
    [
      "@intlify/vite-plugin-vue-i18n",
      {
        // if you want to use Vue I18n Legacy API, you need to set `compositionOnly: false`
        // compositionOnly: false,

        // if you want to use named tokens in your Vue I18n messages, such as 'Hello {name}',
        // you need to set `runtimeOnly: false`
        // runtimeOnly: false,

        // you need to set i18n resource including paths !
        include: path.resolve(__dirname, "./src/i18n/**"),
      },
    ],
  ],
},

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#devServer
devServer: {
  // https: true
  open: true, // opens browser window automatically
},

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#framework
framework: {
  config: {
    cordova: {
      // Quasar handles app exit on mobile phone back button.
      backButtonExit: false / ["/app", "/license", "/policy", "/settings"],
      // On the other hand, the following completely
      // disables Quasar's back button management.
      backButton: false,
    },
  },

  // iconSet: 'material-icons', // Quasar icon set
  lang: "it", // Quasar language pack

  // For special cases outside of where the auto-import strategy can have an impact
  // (like functional components as one of the examples),
  // you can manually specify Quasar components/directives to be available everywhere:
  //
  // components: [],
  // directives: [],

  // Quasar plugins
  plugins: ["Dialog", "Notify", "LocalStorage"],
},

// animations: 'all', // --- includes all animations
// https://v2.quasar.dev/options/animations
animations: [],

// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#property-sourcefiles
// sourceFiles: {
//   rootComponent: 'src/App.vue',
//   router: 'src/router/index',
//   store: 'src/store/index',
//   registerServiceWorker: 'src-pwa/register-service-worker',
//   serviceWorker: 'src-pwa/custom-service-worker',
//   pwaManifestFile: 'src-pwa/manifest.json',
//   electronMain: 'src-electron/electron-main',
//   electronPreload: 'src-electron/electron-preload'
// },

// https://v2.quasar.dev/quasar-cli-vite/developing-ssr/configuring-ssr
ssr: {
  // ssrPwaHtmlFilename: 'offline.html', // do NOT use index.html as name!
  // will mess up SSR

  // extendSSRWebserverConf (esbuildConf) {},
  // extendPackageJson (json) {},

  pwa: false,

  // manualStoreHydration: true,
  // manualPostHydrationTrigger: true,

  prodPort: 3000, // The default port that the production server should use
  // (gets superseded if process.env.PORT is specified at runtime)

  middlewares: [
    "render", // keep this as last one
  ],
},

// https://v2.quasar.dev/quasar-cli-vite/developing-pwa/configuring-pwa
pwa: {
  workboxMode: "generateSW", // or 'injectManifest'
  injectPwaMetaTags: true,
  swFilename: "sw.js",
  manifestFilename: "manifest.json",
  useCredentialsForManifestTag: false,
  // useFilenameHashes: true,
  // extendGenerateSWOptions (cfg) {}
  // extendInjectManifestOptions (cfg) {},
  // extendManifestJson (json) {}
  // extendPWACustomSWConf (esbuildConf) {}
  manifest: {
    name: `X-Pass`,
    short_name: `X-Pass`,
    description: `A Trexom App`,
    display: "standalone",
    orientation: "portrait",
    background_color: "#ffffff",
    theme_color: "#f44e1a",
    icons: [
      {
        src: "icons/icon-128x128.png",
        sizes: "128x128",
        type: "image/png",
      },
      {
        src: "icons/icon-192x192.png",
        sizes: "192x192",
        type: "image/png",
      },
      {
        src: "icons/icon-256x256.png",
        sizes: "256x256",
        type: "image/png",
      },
      {
        src: "icons/icon-384x384.png",
        sizes: "384x384",
        type: "image/png",
      },
      {
        src: "icons/icon-512x512.png",
        sizes: "512x512",
        type: "image/png",
      },
    ],
  },
},

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-cordova-apps/configuring-cordova
cordova: {
  // noIosLegacyBuildFlag: true, // uncomment only if you know what you are doing
  appId: "net.test.xpass",
  plugins: ["cordova-plugin-background-mode"],
},

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-capacitor-apps/configuring-capacitor
capacitor: {
  hideSplashscreen: true,
},

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-electron-apps/configuring-electron
electron: {
  // extendElectronMainConf (esbuildConf)
  // extendElectronPreloadConf (esbuildConf)

  // specify the debugging port to use for the Electron app when running in development mode
  inspectPort: 5858,

  bundler: "packager", // 'packager' or 'builder'

  packager: {
    // https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
    // OS X / Mac App Store
    // appBundleId: '',
    // appCategoryType: '',
    // osxSign: '',
    // protocol: 'myapp://path',
    // Windows only
    // win32metadata: { ... }
  },

  builder: {
    // https://www.electron.build/configuration/configuration

    appId: "x-pass",
  },
},

// Full list of options: https://v2.quasar.dev/quasar-cli-vite/developing-browser-extensions/configuring-bex
bex: {
  contentScripts: ["my-content-script"],

  // extendBexScriptsConf (esbuildConf) {}
  // extendBexManifestJson (json) {}
},

}; }); thats mine