Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] [Android] Not working in background since Android SDK 29 #365

Open
mobilemarines opened this issue Sep 9, 2020 · 2 comments
Open

Comments

@mobilemarines
Copy link

Describe the bug
I was able to send http posts in background (after 5 minutes) with this plugin (version 2.2.0) on the Android target SDK 28 using ionic 4 and Cordova 8.1.2.
As we are all forced to use Android SDK 29 in November I migrated to Cordova 9 und upgraded this plugin to 3.0.1.
Since then I am not able to send http posts in background after 5 minutes anymore. They are postponed and sent in a burst after app returns in foreground.

System info

  • affected HTTP plugin version: 3.0.1
  • affected platform(s) and version(s): Android 10
  • affected device(s): All
  • cordova version: 9.0.0
  • cordova platform version(s): 9.0.0

Are you using ionic-native-wrapper?

  • ionic-native-wrapper version: no
  • did you check [ionic-native issue tracker]: yes

Minimum viable code to reproduce

If applicable, add formatted sample coding to help explain your problem.

this.advancedHttp.setDataSerializer('json');
const response: HTTPResponse = await this.advancedHttp.post(LocationService.POSITION_UPDATE_URL, position, headers);

Screenshots

  • None

Hints
Since Android SDK 29 services need android:foregroundServiceType="dataSync" to be set in order to send data in background.
See:
https://developer.android.com/guide/components/foreground-services
https://developer.android.com/reference/android/R.attr#foregroundServiceType

@tobika
Copy link

tobika commented Nov 19, 2020

In order to fix this you also have to add some more permissions as described here:
mauron85/cordova-plugin-background-geolocation#688 (comment)

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

@chacabuk
Copy link

mobilemarines:
i have exactly same issue.
Do you solve it?

I try adding permission, like tobika said:

It's work... but android going to remove my app from they store if i not explain why using this permission.
And.. all of my explanation not conform they...
Because they said: you not in background... you have a foreground service with an notification icon...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants