Closed makinox closed 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".
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>
This looks all good. Are you still not receiving anything? I'm afraid you have to do some debugging...
don't you have an example where this plugin works?
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!
Thanks I'm going to test
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.
Nice! Glad to hear that.
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,
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.
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.
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.
Please try "ionic build" and then "ionic cap sync android"!
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
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 :)
When I try to share something, instead of getting the share string, I get this error.
On capacitor:
On android studio:
My code looks like this:
app.component.ts
I´m using: