carsten-klaffke / send-intent

Repository for send-intent Capacitor plugin
MIT License
106 stars 12 forks source link

multiple file when app working on background not get catch #73

Open tarangshah19 opened 1 year ago

tarangshah19 commented 1 year ago

i am using vue js in app.vue i have following code

async checkIntent() {
    console.log("Checking Intent")
    try {
      let result = await SendIntent.checkSendIntentReceived();

      if (result) {
        //console.log("SendIntent found", JSON.stringify(result));
      }

      if (result && result.url) {
        let resultUrl = decodeURIComponent(result.url);
        //console.log("resultUrl:", resultUrl);
        await this.$store.dispatch("sendIntent/getIntent", result);
        this.$router.push("/create-post");
        
        // this.intentData.value = {
        //   url: resultUrl
        // }
        // Filesystem.getUri({path: resultUrl})
        // .then((content) => {
        //     console.log('hi this is test',content);
        // })
        // .catch((err) => console.error(err));
      }
    } catch (error) {
      console.log("Error handing sendIntent:", error);
    }
  },

for single image its working fin but more then 1 its not working not get catch files can you tell me how to to solved this issue

in mainActivity.java

public class MainActivity extends BridgeActivity {
    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        String action = intent.getAction();
        String type = intent.getType();
        if (Intent.ACTION_SEND.equals(action) && type != null) {
            bridge.getActivity().setIntent(intent);
            bridge.eval("window.dispatchEvent(new Event('sendIntentReceived'))", new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String s) {
                }
            });
        }
    }

have this code also

carsten-klaffke commented 1 year ago

Hey tarangshah19, is this still an issue? I saw you got help in another thread (https://github.com/carsten-klaffke/send-intent/issues/75) already?!

tarangshah19 commented 1 year ago

yes still not able to do can you please help me

carsten-klaffke commented 1 year ago

The way you configured your MainActivity, you will need to register a Listener in your app like that:

window.addEventListener("sendIntentReceived", () => {
   Plugins.SendIntent.checkSendIntentReceived().then((result: any) => {
        if (result) {
            // ...
        }
    });
})

However, I do recommend to configure a separate activity in AndroidManifest.xml starting the SendIntentActivity and closing it after processing the intent with "finish()". See the current Readme or https://github.com/carsten-klaffke/send-intent/issues/69 if you want to implement it this way!

tarangshah19 commented 1 year ago

ok i will check