CrossGeeks / GeofencePlugin

Geofence Plugin for Xamarin iOS and Android
MIT License
48 stars 22 forks source link

Java.Lang.IllegalArgumentException: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.' #45

Open BhargavSai-17 opened 2 months ago

BhargavSai-17 commented 2 months ago

Hello @rdelrosario ,

I'm encountering an issue while trying to implement the Geofencing feature in my MAUI application targeting Android 34 (Android 14.0). When attempting to start monitoring a region, I receive the following exception:

Java.Lang.IllegalArgumentException: 'namespace': Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.'

I noticed that the Plugin.Geofence library uses PendingIntent.UpdateCurrent. Following the latest Android policies, I modified the PendingIntentFlags to Mutable instead of UpdateCurrent and rebuilt the solution, generating the Plugin.Geofence.dll.

I built the DLL based on the MonoAndroid10.0 framework and installed the necessary packages:

With these changes, I could create a geofence without encountering the above-mentioned exception. However, the geofencing events (Entry, Exit, and Stayed) are not triggering correctly. Specifically, the Entry event triggers immediately upon starting monitoring, even when the device is not within the geofence.

Could you provide guidance or support to resolve this issue? Any assistance in making the plugin fully compatible with higher Android versions would be greatly appreciated.

Thank you.