KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
318 stars 364 forks source link

chat from whatsapp is missing #200

Open Giacomo1993 opened 2 years ago

Giacomo1993 commented 2 years ago

Hi, @xal @danReynolds @nrikiji @KasemJaffer,

I want to share with you my problem with this library. My goal is to create a demo app that receives a chat (with images or video and text) from whatsapp. The issue is that I don't receive anything. I'm working and testing with my Android Device, a Samsung A50 (Android 11). If I try to share images, videos from the gallery then this plugin works correctly, also when I try to share text it works correctly, but if I try to share my chat from the export chat of WhatsApp, then the plugin doesn't receive anything.

Could you please help me? Could you please give me some advice?

Thank you in advance, Giacomo.

xal commented 2 years ago

@Giacomo1993

  1. Explore whats app api documentation, find 'export chat' entity type, I think it should be raw text or data like json
  2. Explore plugin java/kotlin code. Add print to log in all methods in chain

I have similar issues with iOS and exploring swift code + logging worked for me to be able work with custom group id

Giacomo1993 commented 2 years ago

Hi @xal,

Thank you very much!

I'll try it!

benstm commented 2 years ago

@Giacomo1993 I was wondering the same thing. Have you found a solution yet?

Giacomo1993 commented 2 years ago

@benhlr @xal @KasemJaffer @danReynolds The problem is that when I export chat from Whatsapp If I want to share Images, text, or both together the Intent is built with IntentType = "text/*" and IntentAction = "SEND_MULTIPLE".
So, I believe that the code of this library isn't compatible with Export Chat from Whatsapp. You can see the images below. I took these snapshots from debugging my app after the chat's export.

Screenshot 2022-02-09 at 11 36 01

Screenshot 2022-02-09 at 11 36 14

This is the HandleIntent function on this library for android side:

private fun handleIntent(intent: Intent, initial: Boolean) { when { (intent.type?.startsWith("text") != true) && (intent.action == Intent.ACTION_SEND || intent.action == Intent.ACTION_SEND_MULTIPLE) -> { // Sharing images or videos

            val value = getMediaUris(intent)
            if (initial) initialMedia = value
            latestMedia = value
            eventSinkMedia?.success(latestMedia?.toString())
        }
        (intent.type == null || intent.type?.startsWith("text") == true)
                && intent.action == Intent.ACTION_SEND -> { // Sharing text
            val value = intent.getStringExtra(Intent.EXTRA_TEXT)
            if (initial) initialText = value
            latestText = value
            eventSinkText?.success(latestText)
        }
        intent.action == Intent.ACTION_VIEW -> { // Opening URL
            val value = intent.dataString
            if (initial) initialText = value
            latestText = value
            eventSinkText?.success(latestText)
        }
    }
}

As you can see, The intent from whatsapp chat doesn't work with this structure.

Could you please make some modifies to this structure in order to make it available for my goal?

Thank you in advance, Giacomo.