Rapsssito / react-native-background-actions

React Native background service library for running background tasks forever in Android & iOS.
MIT License
818 stars 117 forks source link

fix(Android): Fix Android 14 crash with implicit intent #208

Closed devtyty closed 5 months ago

contactsimonwilson commented 10 months ago

Thanks for this. I have some users reporting issues on Android 14 and will use this with patch-package to get by for now

sssajjad007 commented 9 months ago

its work for me

GaelCO commented 9 months ago

Hi, I was making the same modifications on my end when I saw your PR. I agree with the changes on the RNBackgroundActionsTask.java class. But for this, I think compileSDKVersion need to pass at least to 34 to assure have UPSIDE_DOWN_CAKE constant.

For the foreground type, an action is not always of type shortService. I try to found a way to set a dynamically foregroundService

contactsimonwilson commented 9 months ago

Hi, I was making the same modifications on my end when I saw your PR. I agree with the changes on the RNBackgroundActionsTask.java class. But for this, I think compileSDKVersion need to pass at least to 34 to assure have UPSIDE_DOWN_CAKE constant.

For the foreground type, an action is not always of type shortService. I try to found a way to set a dynamically foregroundService

Agreed with the service type. I'm using specialUse for my app with this patch. If using expo, this could easily be dynamic with a config plugin

GaelCO commented 9 months ago

The foreground type could be pass by parameter since API Level 29. I'm going to try a solution with adding type(s) in options. /!\ Some types need permission on manifest. I consider that they should not be added to the library and that it is the responsibility of each application.

devtyty commented 9 months ago

The foreground type could be pass by parameter since API Level 29. I'm going to try a solution with adding type(s) in options. /!\ Some types need permission on manifest. I consider that they should not be added to the library and that it is the responsibility of each application.

Right! Thanks for your feedback, i think we should set compileSDKVersion to 34 for library and foreground type to be is the responsibility of each application.

Maybe i will update this patch

GaelCO commented 9 months ago

After some test and read the document, it seems to be impossible to set the foregroundType directly in the startForeground method without declare it in the service tag (manifest). If we had all the possible tags, we must declare all the corresponding permissions. Imho, It's not an option This parameter is just useful if a service could have different type and precise when it is called.

I don't see any other solution than indicating in the documentation that the service must be redeclared in the application manifest with the correct foregroundType.

devtyty commented 9 months ago

After some test and read the document, it seems to be impossible de set the foregroundType directly in the startForeground method without declare it in the service tag (manifest). If we had all the possible tags, we must declare all the corresponding permissions. Imho, It's not an option This parameter is just useful if a service could have different type and precise when it is called.

I don't see any other solution than indicating in the documentation that the service must be redeclared in the application manifest with the correct foregroundType.

I updated compileSdk to 34 and remove foregroundSeviceType in lib's manifest. We should to declare in self application with permission related.

Refer

To startForeground with dynamic type, i think lib must be to chang with param is permission type corresponding

MarkNaArea commented 8 months ago

Worked for me!

marcosinigaglia commented 7 months ago

Hi, is there any news with respect to this PR? Need help with anything?

rolandvar commented 6 months ago

Worked for me too!

ansarikhurshid786 commented 6 months ago

i am going to use it now. seem working for you guys

Sushanthsp commented 5 months ago

I'm facing issue with Restricted app setting, which is not allowing to my app because of this library and it is only in Android 14. In other versions works fine.

github-actions[bot] commented 5 months ago

:tada: This PR is included in version 4.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: