Skip to content

Foreground service permission is required since Android 28 #623

Closed
@HarelM

Description

@HarelM

Your Environment

  • Plugin version: 3.0.6
  • Platform: Android
  • OS version: 7.2
  • Device manufacturer and model: N/A
  • Running in Simulator: NO
  • Cordova version (cordova -v): 9.0.0 (cordova-lib@9.0.1)
  • Cordova platform version (cordova platform ls): android 8.0.0
  • Plugin configuration options:
  • Link to your project: https://github.com/IsraelHikingMap/Site/

Context

I have recently updated cordova and min sdk version due to Goggle requirements
When using a newer version and using foreground service true the following permissions are needed, otherwise the plugin crashes with the following exception:
09-13 09:17:07.430 10150 10150 E com.marianhello.bgloc.service.LocationServiceImpl: processCommand: exceptionjava.lang.SecurityException: Permission Denial: startForeground from pid=10150, uid=10273 requires android.permission.FOREGROUND_SERVICE

Expected Behavior

The documentation should specify it or the plugin should configure it.

Actual Behavior

App doesn't work for no apparent reason.

Possible Fix

Add docs or update plugin.xml
Workaround: use this in the config.xml:

        <edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/uses-permission" xmlns:android="http://schemas.android.com/apk/res/android">
          <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
        </edit-config>

Steps to Reproduce

  1. use the following when creating the app in config.xml:
        <preference name="android-targetSdkVersion" value="28" />
        <preference name="android-minSdkVersion" value="28" />

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions