carsten-klaffke / send-intent

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

ERROR Error: Uncaught (in promise): Error: No processing needed #2

Closed makinox closed 4 years ago

makinox commented 4 years ago

When I try to share something, instead of getting the share string, I get this error.

On capacitor:

ERROR Error: Uncaught (in promise): Error: No processing needed
Error: No processing needed
    at Object.fromNative (capacitor-runtime.js:226)
    at <anonymous>:1:18
    at T (polyfills-es2015.4883a353adcafadf59fa.js:1)
    at T (polyfills-es2015.4883a353adcafadf59fa.js:1)
    at polyfills-es2015.4883a353adcafadf59fa.js:1
    at l.invokeTask (polyfills-es2015.4883a353adcafadf59fa.js:1)
    at Object.onInvokeTask (main-es2015.25dfe17caf5202989528.js:1)
    at l.invokeTask (polyfills-es2015.4883a353adcafadf59fa.js:1)
    at i.runTask (polyfills-es2015.4883a353adcafadf59fa.js:1)
    at m (polyfills-es2015.4883a353adcafadf59fa.js:1)

On android studio:

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 87673061, pluginId: SendIntent, methodName: checkSendIntentReceived
V/Capacitor: callback: 87673061, pluginId: SendIntent, methodName: checkSendIntentReceived, methodData: {}
D/Capacitor: Sending plugin error: {"save":false,"callbackId":"87673061","pluginId":"SendIntent","methodName":"checkSendIntentReceived","success":false,"error":{"message":"No processing needed"}}
V/Capacitor/PushNotifications: Notifying listeners for event registration
E/Capacitor/Console: File: http://localhost/main-es2015.25dfe17caf5202989528.js - Line 1 - Msg: ERROR Error: Uncaught (in promise): Error: No processing needed
    Error: No processing needed
        at Object.fromNative (capacitor-runtime.js:230:14)
        at <anonymous>:1:18

My code looks like this:

app.component.ts

import { Plugins, PushNotification, PushNotificationToken, PushNotificationActionPerformed, registerWebPlugin } from '@capacitor/core';

...

registerWebPlugin(SendIntent);

Plugins.SendIntent.checkSendIntentReceived().then((result: any) => {
  if (result.text) {
    console.log({ app: 'APP: Test', intent: result.text });
   }
});

I´m using:

carsten-klaffke commented 4 years ago

Your configuration on the Ionic side looks good to me. The message "no processing needed" is basically saying that the plugin didn't find a suitable intent with "ACTION_SEND" or "ACTION_SEND_MULTIPLE". So maybe your Android configuration is incomplete (you have to register the plugin in MainActivity and you have to edit the AndroidManifest for targets) or you are executing the plugin at the wrong time. Be aware that the plugin is just doing a poll, it is not triggered by the intent. To have it get triggered by the intent, please see my recent update of the readme with the section "use checkIntent as a listener".

makinox commented 4 years ago

Well i´m not sure, i think i'm not using the correct libraries from the plugin, in the docs they are not specified

MainActivity.java

import android.content.Intent;
import android.webkit.ValueCallback;
import de.mindlib.sendIntent.SendIntent;

...

@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Initializes the Bridge
  this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{

    ...

    add(SendIntent.class);

  }});
}

@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) {
          }
      });
  }
}

AndroidManifest.xml

<activity
    android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
    android:name="io.ionic.starter.MainActivity"
    android:label="@string/title_activity_main"
    android:theme="@style/AppTheme.NoActionBarLaunch"
    android:launchMode="singleTask">

    <intent-filter>
        <action android:name="android.intent.action.SEND" />

        <category android:name="android.intent.category.DEFAULT" />

        <data android:mimeType="text/plain" />
    </intent-filter>
</activity>
carsten-klaffke commented 4 years ago

This looks all good. Are you still not receiving anything? I'm afraid you have to do some debugging...

makinox commented 4 years ago

don't you have an example where this plugin works?

carsten-klaffke commented 4 years ago

I just added one under "/Example". I tested it on an emulator with Android 9 and shared a wikipedia link. If you do that, there show up three alerts displaying the intent data. I hope this helps!

makinox commented 4 years ago

Thanks I'm going to test

makinox commented 4 years ago

Ok i fixed, my problem was the time of execution. I have to install the plugin on the first file main.ts(For angular) / index.tsx (For react). Then call the plugin when you want to read the event.

carsten-klaffke commented 4 years ago

Nice! Glad to hear that.

paulisidore commented 11 months ago

Hello, I know it's quite far but I'll try my luck, I'm having the same problem as you and the React example doesn't help me much (I've never written code in this language). Can you explain to us how you installed the Plugin in the main.ts file? Also, could the repository manager find us an example with Angular? Thank you very much for helping us. I've been struggling for over a month to get the plugin to work correctly on ionic7/Capacitor 5. Sincerely,

carsten-klaffke commented 11 months ago

Hi, I just created an Ionic7 example project for Angular (Android only, so far). Have a look at tab1.page.ts and AndroidManifest.xml (additional activity for SendIntent)! These contain basically all configuration you need.

paulisidore commented 11 months ago

Ohh Thank you very much, Indeed I saw the example and as a result I just noticed a first error in adding the activity. I will correct my project and come back to you with the final solution to my problem.

paulisidore commented 11 months ago

Hi, I'm coming back to you because I have a problem building the example in Angular. In VS Code the project builds very well but once in Android Studio I get the following error: org.gradle.api.resources.MissingResourceException: Could not read script capacitor-cordova-android-plugins\cordova.variables.gradle' as it does not exist.

carsten-klaffke commented 11 months ago

Please try "ionic build" and then "ionic cap sync android"!

paulisidore commented 11 months ago

Thank you for the answer, I had done it before even posting but finally I restarted the Android Studio and it build, I will now install it on the Android phone and get back to you, thank you very much for the help

paulisidore commented 11 months ago

Thank you Very much, The example works correctly, I will adjust the ReadMe in a pull request so that someone else does not make the same mistake as me. Thank you for this PlugIn, I will send you something for a little coffee in Germany :)