Giter Club home page Giter Club logo

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. about react-native-share HOT 10 CLOSED

vaish8529 avatar vaish8529 commented on June 16, 2024 2
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.

from react-native-share.

Comments (10)

amdrade avatar amdrade commented on June 16, 2024 1

Same issue
"react-native": "0.62.2", "react-native-share": "^3.3.2"

from react-native-share.

yaeda avatar yaeda commented on June 16, 2024 1

I think this problem has been fixed in v7.0.1.

https://github.com/react-native-share/react-native-share/blob/main/android/src/main/java/cl/json/social/TargetChosenReceiver.java#L56-L59

Or is there some other problem?

from react-native-share.

jamieGardyn avatar jamieGardyn commented on June 16, 2024 1

@yaeda that also fixes it with better code, thank you!

But, I am using an older version of react-native-share and cannot update at the moment so need to do it in a patch.

from react-native-share.

dangnguyen1004 avatar dangnguyen1004 commented on June 16, 2024 1

I think this problem has been fixed in v7.0.1.

https://github.com/react-native-share/react-native-share/blob/main/android/src/main/java/cl/json/social/TargetChosenReceiver.java#L56-L59

Or is there some other problem?

Thanks @yaeda Fixed here

from react-native-share.

lkhore avatar lkhore commented on June 16, 2024

Same issue

from react-native-share.

vaish8529 avatar vaish8529 commented on June 16, 2024

I fixed the issue by adding the following code to the AndroidManifest.xml file.

<queries>
        <package android:name="com.example.store" />
        <package android:name="com.example.services" />

        <!--for example, to share via instagram -->
        <package android:name="com.instagram.android" />
        <package android:name="com.whatsapp.android" />
        <intent>
          <action android:name="android.intent.action.SEND" />
          <data android:mimeType="image/jpeg" />
        </intent>
    </queries>

And

const shareOptions = {
            url: uri,
            social: Share.Social.WHATSAPP,
        };
    Share.shareSingle(shareOptions);

But it only shares on WhatsApp.
The error persists when using the Share.open() function.

from react-native-share.

DevCraftsmanShubham avatar DevCraftsmanShubham commented on June 16, 2024

any updates? how to fix this issue??

from react-native-share.

kaayso avatar kaayso commented on June 16, 2024

Same issue

from react-native-share.

jamieGardyn avatar jamieGardyn commented on June 16, 2024

Found a fix, you have to go into react-native-share/android/src/main/java/cl/json/social/TargetChosenReceiver.java and change to the code below. Then use a library like patch-package to save the patch so it works on every npm install...

This...

        Intent intent = new Intent(sTargetChosenReceiveAction);
        intent.setPackage(reactContext.getPackageName());
        intent.putExtra(EXTRA_RECEIVER_TOKEN, sLastRegisteredReceiver.hashCode());
        final PendingIntent callback = PendingIntent.getBroadcast(reactContext, 0, intent,
                PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);```

To...

        Intent intent = new Intent(sTargetChosenReceiveAction);
        intent.setPackage(reactContext.getPackageName());
        intent.setClass(reactContext, TargetChosenReceiver.class);
        intent.putExtra(EXTRA_RECEIVER_TOKEN, sLastRegisteredReceiver.hashCode());

        final PendingIntent callback;
        if (android.os.Build.VERSION.SDK_INT >= 23) {
            callback = PendingIntent.getBroadcast(reactContext, 0, intent, PendingIntent.FLAG_IMMUTABLE);
        } else {
            callback = PendingIntent.getBroadcast(reactContext, 0, intent,
                    PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_ONE_SHOT);
        }

from react-native-share.

github-actions avatar github-actions commented on June 16, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and i will leave this open

from react-native-share.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.