odemolliens / react-native-sim-cards-manager

React Native plugin to manage Sim card(s) & eSim
MIT License
67 stars 29 forks source link

Error when creating pendingIntent for setupEsim #73

Closed chougron closed 5 months ago

chougron commented 5 months ago

I'm on Android 14 with a Xiaomi 12T Pro.

When trying to add an eSIM with the setupEsim method, I'm getting the following error :

Targeting U+ (version 34 and above) disallows creating or retrieving a PendingIntent with FLAG_MUTABLE, an implicit Intent within and without FLAG_NO_CREATE and FLAG_ALLOW_UNSAFE_IMPLICIT_INTENT for security reasons. To retrieve an already existing PendingIntent, use FLAG_NO_CREATE, however, to create a new PendingIntent with an implicit Intent use FLAG_IMMUTABLE.

In SimCardsManagerModule.java, I indeed see that the intent is created in the following way :

    PendingIntent callbackIntent = PendingIntent.getBroadcast(
        mReactContext,
        0,
        new Intent(ACTION_DOWNLOAD_SUBSCRIPTION),
        PendingIntent.FLAG_UPDATE_CURRENT |
            PendingIntent.FLAG_MUTABLE);

Is there a reason it is created with FLAG_MUTABLE ? Can we change it to FLAG_IMMUTABLE ?

odemolliens commented 5 months ago

Hey @chougron. I have seen your #74 but its closed now. Any reason? Not working/required?

chougron commented 5 months ago

I created it by error, I wanted to make it on my fork repo. I tried setting the flag to IMMUTABLE on my side, and I don't get an error anymore, but then nothing is happening, so I'm not sure if I'm missing something.

odemolliens commented 5 months ago

Merged. will be included in the next release. thank you @chougron !