carsten-klaffke / send-intent Goto Github PK
View Code? Open in Web Editor NEWRepository for send-intent Capacitor plugin
License: MIT License
Repository for send-intent Capacitor plugin
License: MIT License
I was trying to send an intent of video, but has an error occurring:
E/Capacitor/Console: File: capacitor-runtime.js - Line 229 - Msg: Uncaught (in promise) Error: No processing needed
I imagine that has no implementation for this type of data. It would be nice an improvement like that.
Describe the bug
Sharing from iOS Safari gives the actual (HTTP/S) URL in the result object of SendIntent.checkSendIntentReceived
But sharing from Android Chrome gives a url that is a file:// string, and the contents of that file are not clear - they are random characters. (Base64 decoding results in binary)
On Android, the result object is :
{"title":"There's an Urgent New Warning for Walmart and Amazon Shoppers","type":"text/plain","url":"file:///data/user/0/<>/files/.com.google.Chrome.rKLucE"}
To Reproduce
Steps to reproduce the behavior:
Follow instructions from https://github.com/carsten-klaffke/send-intent
Expected behavior
url property of result has the actual URL of the page being shared from Chrome
Screenshots
Desktop (please complete the following information):
Android
Smartphone (please complete the following information):
Android simulator
Additional context
Add any other context about the problem here.
Is your feature request related to a problem? Please describe.
I've been using v2 so far. Now I noticed v3 is out. What changed? There's no info available.
Describe the solution you'd like
Provide a changelog.
I have set the plist for the shareintent ext to (ios/App/ShareIntent/Info.plist)
...
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
</dict>
</dict>
...
Within the app I can catch URLs and text just fine.
As soon as I try to share a photo to the app it fails:
Each time nothing gets passed to the app in the image object. The plugin logs:
⚡️ To Native -> SendIntent checkSendIntentReceived 9529930
⚡️ TO JS {"file":"","url":"","text":"","image":""}
In the js code, for completeness, i log the object:
SendIntent.checkSendIntentReceived().then((result) => {
console.log('result from send intent: ', result);
And the output is:
⚡️ [log] - result from send intent: {"file":"","url":"","text":"","image":""}
The thing is the app is registered correctly in the plist as the app is available to share photos to. Additionally, i checked to ensure this was not a "live photo" but still the same.
I noticed this warning today in the web console of our angular application.
Capacitor WebPlugin "SendIntent" config object was deprecated in v3 and will be removed in v4.
We are using angular 11
, capacitor ^3.4.0
and send-intent 3.0.10
It's just a warning and doesn't currently affect our application - but I just wanted to let you know about it :)
I successfully integrated your awesome plugin into my app. Sharing files and images from other apps to my app works on both Android and iOS. Great! So far. Now I'm trying to distribute my updated iOS app to the Apple App store through Xcode. This process comes back with the following error:
Invalid Info.plist value. The value for the key 'NSExtensionActivationRule' in bundle App.app/PlugIns/Send intent extension.appex is invalid. Please refer to the App Extension Programming Guide on https://developer.apple.com
I've tried many different values for NSExtensionActivationRule but have finally returned to the default value from the readme:
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>5</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>5</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>5</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationUsesStrictMatching</key>
<false/>
</dict>
All values I tried come back with this same error. Which leads me to think it's not really about the value of NSExtensionActivationRule.
After searching through some SO threads I've checked the following things:
@carsten-klaffke I'm kind of at the end of my rope here. Do you maybe have any suggestions?
I got the android app up and running without too much effort but the iOS is not so easy (plus i am no ios expert).
There are actually 2 issues, firstly:
https://github.com/carsten-klaffke/send-intent/blob/master/ios/Plugin/Plugin.swift#L33: xcode errors:
"Value of optional type 'CAPBridgeProtocol?' must be unwrapped to refer to member 'eval' of wrapped base type 'CAPBridgeProtocol'"
Secondly, "vue2/ios/App/App/AppDelegate.swift:1:8: Could not build Objective-C module 'SendIntent':"
The error here is on the import of SendIntent on the 1st line.
Do you have a working example like the Android version?
There isn't a software license in this repo, can you add one?
Describe the bug
Sharing works correctly when I select multiple photos from image gallery and share them to app. But when I receive photos in message using WhatsApp app, I select them in WhatsApp and share them to my app. I receive the intent with first photo multiple times.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Receive intent with multiple photos
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Additional context
Data received from plugin:
[log] - intent {"type":"application%2Fjpg","url":"file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2FAF4D217D-A918-4245-9C60-ACDF619D2EBC%2F%2FPHOTO-2023-03-24-09-49-39.jpg","additionalItems":[{"url":"file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2FAF4D217D-A918-4245-9C60-ACDF619D2EBC%2F%2FPHOTO-2023-03-24-09-49-39.jpg","type":"application%2Fjpg","description":"","title":"PHOTO-2023-03-24-09-49-39.jpg"},{"url":"file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2FAF4D217D-A918-4245-9C60-ACDF619D2EBC%2F%2FPHOTO-2023-03-24-09-49-39.jpg","type":"application%2Fjpg","description":"","title":"PHOTO-2023-03-24-09-49-39.jpg"},{"title":"PHOTO-2023-03-24-09-49-39.jpg","description":"","url":"file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2FAF4D217D-A918-4245-9C60-ACDF619D2EBC%2F%2FPHOTO-2023-03-24-09-49-39.jpg","type":"application%2Fjpg"},{"title":"PHOTO-2023-03-24-09-49-39.jpg","description":"","url":"file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2FAF4D217D-A918-4245-9C60-ACDF619D2EBC%2F%2FPHOTO-2023-03-24-09-49-39.jpg","type":"application%2Fjpg"}],"description":"","title":"PHOTO-2023-03-24-09-49-39.jpg"}
How to install it on Capacitor?
Installation Instructions should be added in Documentations.
Describe the bug
Hello, on ionic/android I'm implementing this plugin but when I execute the recommended 'SendIntent.finish()' after intent and routing to the desired page are executed successfully, the app crashes closing itself. What could this be due to?
Describe the bug
2 issues are happening
Receiving multiple intent data after sharing one content.
However, in iOS, iOS receive only one intent event per shared content which works as expected.
File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.666 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.677 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970433, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.680 27118-27118 Capacitor gg.republik.app.dev V callback: 13970433, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.702 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.702 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.704 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970434, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.704 27118-27118 Capacitor gg.republik.app.dev V callback: 13970434, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.705 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.706 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.707 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970435, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.707 27118-27118 Capacitor gg.republik.app.dev V callback: 13970435, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.711 27118-28139 Capacitor/Plugin gg.republik.app.dev W getObject calls without a default value will return null in Capacitor 5 instead of an empty object to match iOS behavior
2023-08-25 11:30:03.711 27118-28139 Capacitor/Plugin gg.republik.app.dev W getObject calls without a default value will return null in Capacitor 5 instead of an empty object to match iOS behavior
2023-08-25 11:30:03.713 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.714 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.715 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970436, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.715 27118-27118 Capacitor gg.republik.app.dev V callback: 13970436, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.716 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.716 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.716 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970437, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.716 27118-27118 Capacitor gg.republik.app.dev V callback: 13970437, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.717 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.717 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
2023-08-25 11:30:03.718 27118-27118 Capacitor/Plugin gg.republik.app.dev V To native (Capacitor plugin): callbackId: 13970438, pluginId: CapacitorHttp, methodName: get
2023-08-25 11:30:03.718 27118-27118 Capacitor gg.republik.app.dev V callback: 13970438, pluginId: CapacitorHttp, methodName: get, methodData: {"url":"https:\/\/vt.tiktok.com\/ZSLGgUADH\/"}
2023-08-25 11:30:03.718 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: SendIntent.checkSendIntentReceived result {"type":"text/plain","url":"https://vt.tiktok.com/ZSLGgUADH/"}
2023-08-25 11:30:03.719 27118-27118 Capacitor/Console gg.republik.app.dev I File: http://localhost/static/js/main.cb0c1331.js - Line 2 - Msg: is empty? false
App crash after calling SendIntent.finish()
// AndroidManifest.xml
<application>
...
<activity
android:name="de.mindlib.sendIntent.SendIntentActivity"
android:label="RepubliK"
android:exported="true"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
</intent-filter>
</activity>
...
</application>
const checkIntent = async () => {
console.log('checkIntent')
return SendIntent.checkSendIntentReceived()
.then(async (result?: ShareReceiverIntentResult) => {
console.info(
'SendIntent.checkSendIntentReceived result',
JSON.stringify(result)
)
// Other logic
// ....
SendIntent.finish()
})
.catch((err) => console.error(err))
}
Smartphone (please complete the following information):
Hi Carsten,
I tried to check out your plugin but Android Studio throws me this error:
/Users/perelin/code/projx/docma-app/src-capacitor/android/app/src/main/java/org/cordova/MAYAPP/app/MainActivity.java:20: error: cannot find symbol
add(SendIntent.class);
^
symbol: class SendIntent
This is my current MainActivity.java
package org.cordova.docma.app;
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.getcapacitor.Plugin;
import java.util.ArrayList;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Initializes the Bridge
this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {
{
// Additional plugins you've installed go here
// Ex: add(TotallyAwesomePlugin.class);
add(SendIntent.class);
}
});
}
}
I tried to import the package with import de.mindlib.sendIntent.sendintent;
but then
/Users/perelin/code/projx/docma-app/src-capacitor/android/app/src/main/java/org/cordova/MYAPP/app/MainActivity.java:8: error: cannot find symbol
import de.mindlib.sendIntent.sendintent;
^
symbol: class sendintent
location: package de.mindlib.sendIntent
Any ideas how to proceed?
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
My app use only universal links (HTTPS) , but I replace URL_SCHEME by my universal link , safari open the app
var urlComps = URLComponents(string: "YOUR_APP_URL_SCHEME://")! urlComps.queryItems = queryItems openURL(urlComps.url!)
the code must be changed to be sure to open the application with a universal link ?
Best Regards
Is your feature request related to a problem? Please describe.
A Capacitor 5 project with this plugin won't build on android because the package namespace/id is being moved from AndroidManifest.xml to build.gradle. See https://capacitorjs.com/docs/next/updating/plugins/5-0
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
Hi,
I'm using this plugin on my Capacitor v4 + Nuxt v2.15.8 app and I'm getting the following error:
Error: "SendIntent" plugin is not implemented on android
using the following code in my index.vue
page:
import { SendIntent } from 'send-intent';
mounted() {
if (this.$device.isNative) {
SendIntent.checkSendIntentReceived()
.then((result) => {
// ...
SendIntent.finish();
})
.catch(err => alert(err));
}
},
what am I doing wrong? Is that an issue with new Capacitor versions or I need to register the plugin somehow?
Thanks
Describe the bug
From Safari on any webpage if I click on Share and share the page with my app, everything goes per plan, however after sharing the SENDING app has a greyed out appearance if I go back to it, and the app is not responding to anything, needs to be restarted.
Same with the Notes app when sharing selected text. But the Photos app seems to be fine.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Sharing app released and responsive.
Screenshots
n/a
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
It is to be noted that it goes without an intermediate window straight to the app.
Hi Carsten,
I have been working in my fork (https://github.com/mcprol/send-intent/tree/metricool) with the support to multi file in IOS.
Also I have added support to video, and critical for me, write a new ViewController without the default dialog box, so the shared items are sent directly to my application.
But now I have seen that also you are working in multifile for IOS. Have you finished your work? I'd like to give it a try before send a PR
Regards
Marcos
Describe the bug
The send - intent plugin is successfully working while the application is closed or not in the background . The response is coming while the share process is applied but while the application is working in the background / minimised the share process is failing continuously.
Hello
My final goal is to execute a certain function in JS depending on how the app was launched, so no sharing from another app or arguments. Sorry, i know it's not very clear, feel free to ask precision.
My first try was with android's device control, but didn't find anyway simple way with capacitor.
I don't know if this plugin is the right way to do it, but android's intent seems to be a way to do it.
**Smartphone
whatever the app.vue it crash, even without importing the plugin.
i tried a lot of configuration my last one was like this
<activity
android:name="mirsella.test.power"
android:label="@string/app_name"
android:exported="true"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<!-- <category android:name="android.intent.category.DEFAULT" /> -->
</intent-filter>
</activity>
I never really touched the android apps, so I don't know what I'm doing, I'm probably missing something obvious.
I'm launching the activity mirsella.test.power with this app https://play.google.com/store/apps/details?id=de.szalkowski.activitylauncher but after I'll launch the activity from termux
Please enlight me, I'm stuck.
Thanks a lot for any time you put in helping me, have a good day
Hello.
As title say, upon changing the device orientation, my app crashes
This behavior is also observed in the sample application.
im on android 13.
I currently do not have a solution, but it would be fantastic if we could address this issue in some way.
Thank you for your work and attention!
Thanks for This Great Plugin for Capacitor. I am able to receive data from Instagram Share To
option in android but in IOS its not working.
I tried with both via addListener()
and normally but nothing is working in IOS. My Application shows in Share Sheet but not receiving data.
Hey Carsten,
i just stumbled across a dependency inside my package-lock.json file.
"dependencies": {
"-": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/-/-/--0.0.1.tgz",
"integrity": "sha512-3Hfne...
In the dependencies tab from npmjs -
is listed as one of your dependencies.
https://www.npmjs.com/package/send-intent
I just wanted to let you know ;)
I was trying to get multiple data from another app
The only thing I am receiving is {"type": "text/plain"}
also, the plugin does not work if the app is open am I missing something I have to close the app to get data
The app works as expected after setup according to the instructions but the lib is sending lots of unnecessary error messages "No processing needed".
The intents that are not beeing handled by the lib are of the following type:
Intent { act=intent handled cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=app.name/.MainActivity }
Since in our company we are using "appcenter" for building and distributing the app we can not use the "Automatically manage signing" capability of XCode and we need to generate and use a "Provisioning Profile" (aka the .mobileprovision file).
I was able to make the sharing feature work on the XCode's simulator but not on a real device. I think it's because the signing is ignored on the simulators.
This is what I tried:
group.it.mycompany.stp.sharing
it.mycompany.stp
and extension's App Id is it.mycompany.stp.share-extension
group.it.mycompany.stp.sharing
where requiredAt this point the share functionality was working on the simulator, but when download from test flight the app do not show up in the share window
Have you considered getting this awesome plugin listed here?
https://capacitorjs.com/docs/plugins/community
https://github.com/capacitor-community/welcome
I just built an app in capacitor v4 - sharing links, web-urls and photos works flawlessly in Android.
In iOS text and web-urls work fine, but sharing a photo I cannot get to work in v4.
The shareintent plugin info.plist has been updated to:
<key>NSExtensionAttributes</key>
<dict>
<key>NSExtensionActivationRule</key>
<dict>
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>5</integer>
<key>NSExtensionActivationSupportsText</key>
<true/>
<key>NSExtensionActivationSupportsWebPageWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<key>NSExtensionActivationUsesStrictMatching</key>
<false/>
</dict>
</dict>
Sharing links and text to the ios app works perfectly.
Sharing a photo (not a even a live photo) does not work.
The capacitor app does not load, instead the photos app being share from sort of animates up about 4mm on the screen, then sort of "gives up". In xcode there are no error messages that are consistent... but sometimes (I think it is related) I get this error in xcode:
"2022-12-16 10:06:29.618067+0000 App[15668:493451] [Snapshotting] Snapshotting a view (0x10a00d600, UIKeyboardImpl) that has not been rendered at least once requires afterScreenUpdates:YES."
I installed capacitor with sveltekit and was able to build my android app successfully. However, the build step (npm run build) fails when I try to use "send-intent"
I put the following code in my sveltekit application as instructed:
<script lang="ts">
import "../app.postcss";
import Navbar from "./navbar.svelte";
import {SendIntent} from "send-intent";
import { Filesystem } from '@capacitor/filesystem';
SendIntent.checkSendIntentReceived().then((result: any) => {
if (result) {
console.log('SendIntent received');
console.log(JSON.stringify(result));
}
if (result.url) {
let resultUrl = decodeURIComponent(result.url);
Filesystem.readFile({path: resultUrl})
.then((content) => {
console.log(content.data);
})
.catch((err) => console.error(err));
}
}).catch(err => console.error(err));
</script>
when I run
npm run build
I get the follwwing error:
file:///E:/Startup/Svelte/TSSKFE/.svelte-kit/output/server/entries/pages/_layout.svelte.js:6
import { SendIntent } from "send-intent";
^^^^^^^^^^
SyntaxError: Named export 'SendIntent' not found. The requested module 'send-intent' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'send-intent';
const { SendIntent } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:122:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:188:5)
node:internal/event_target:1037
process.nextTick(() => { throw err; });
^
Error: 500 /
To suppress or handle this error, implement `handleHttpError` in https://kit.svelte.dev/docs/configuration#prerender
at file:///E:/Startup/Svelte/TSSKFE/node_modules/@sveltejs/kit/src/core/config/options.js:212:13
at file:///E:/Startup/Svelte/TSSKFE/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:64:25
at save (file:///E:/Startup/Svelte/TSSKFE/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:403:4)
at visit (file:///E:/Startup/Svelte/TSSKFE/node_modules/@sveltejs/kit/src/core/postbuild/prerender.js:236:3)
Emitted 'error' event on Worker instance at:
at [kOnErrorMessage] (node:internal/worker:323:10)
at [kOnMessage] (node:internal/worker:334:37)
at MessagePort.<anonymous> (node:internal/worker:229:57)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:762:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
Node.js v20.1.0
If I try the suggestion mentioned in the error above, the error changes to:
error during build:
RollupError: "default" is not exported by "node_modules/send-intent/dist/esm/index.js", imported by "src/routes/+layout.svelte".
at error (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:2245:30)
at Module.error (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:13572:16)
at Module.traceVariable (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:13997:29)
at ModuleScope.findVariable (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:12515:39)
at FunctionScope.findVariable (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:7073:38)
at ChildScope.findVariable (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:7073:38)
at Identifier.bind (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:8235:40)
at VariableDeclarator.bind (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:5841:23)
at VariableDeclaration.bind (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:5837:28)
at BlockStatement.bind (file:///E:/Startup/Svelte/TSSKFE/node_modules/rollup/dist/es/shared/node-entry.js:5837:28)
I tried googling and trying every solution offered on stackoverflow and on other websites but nothing worked for me. I am aware this might not be an issue bug with module but my mistake. Please help.
Hi, firstly thank you for your plugin - it's a lifesaver for a side project I'm working on. I bought you a few coffees 🙂
I may be missing something, but I have things working fine when the app is already open in the background, but from a cold start I'm not catching the sendIntentReceived event.
I'm using Nuxt3 and have put my event listener in app.vue which I believe is one of, if not the first page to load and it's not catching the event.
Is there something I'm missing perhaps?
Many thanks 🙏
I managed to register my app as the default handler for a file type (mime type) and I think the plugin could be modified/extended to do this as well.
Note that in my tests I did not register a separate activity, I used MainActivity. it seems to work fine, although I'll have to do more tests.
In AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="[MY MIME TYPE]" />
</intent-filter>
I then modified SendIntent.java:
In checkSendIntentReceived
:
...
if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_VIEW.equals(action)) && type != null) {
...
In readItemAt
:
from
Uri uri = null;
if (intent.getClipData() != null && intent.getClipData().getItemAt(index) != null)
uri = intent.getClipData().getItemAt(index).getUri();
String url = null;
to
Uri uri = null;
String url = null;
if (intent.getClipData() != null && intent.getClipData().getItemAt(index) != null)
uri = intent.getClipData().getItemAt(index).getUri();
else if (intent.getData() != null) {
Uri copyfileUri = copyfile(intent.getData());
url = (copyfileUri != null) ? copyfileUri.toString() : null;
}
I also modified readFileName()
to avoid some possible errors:
public String readFileName(Uri uri) {
try (Cursor returnCursor = getContext().getContentResolver().query(uri, null, null, null, null)) {
if (returnCursor != null && returnCursor.moveToFirst()) {
int displayNameIndex = returnCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
if (displayNameIndex != -1) {
return returnCursor.getString(displayNameIndex);
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Finally, I also have this in MainActivity.java:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
String action = intent.getAction();
String type = intent.getType();
if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_VIEW.equals(action)) && type != null) {
bridge.getActivity().setIntent(intent);
bridge.eval("window.dispatchEvent(new Event('sendIntentReceived'))", new ValueCallback<String>() {
@Override
public void onReceiveValue(String s) {
}
});
}
}
I am pretty new at Android so I'm not entirely sure the code is correct and doesn't introduce other unwanted behavior.
Hi, I found your plugin and I'm hoping its what I need for my use-case. I want to use this as a listener for text data that is being set in an intent from a specific app (in Android). I have followed the set up but I'm getting the error "no processing needed".
What should I look for to resolve this issue? I have added the intent filters as in the example, and the code in the main-activity as well as the listener code in my app.tsx. I have also removed all existing listeners for deeplinks in my app as well as rebuilt the project.
Hoping you can help.
Hello, first of all thanks for this package, I was close to giving up when I found it. i'm using Ionic 6.2, Capacitor 4.
I added two activities, each having it's intent-filter in my app on Android side for now.
Indeed, I would like to have 2 buttons in the Android ShareSheet triggering two different scenarios for the files I share.
I thought about using putExtra for each intent and set a 'verb' so that when my app lauches I can check the value of this 'verb' and determine what to do accordingly (scenario 1 or 2).
However even with the intent having a putExtra to it the structure of the intent when calling checkSendIntentReceived() stays the following (thanks to an JSON.stringify of the result) :
And that's it, I thought I could retrieve the 'verb' into the additionalItems of the Intent's interface but it ain't there.
Or maybe could I use the description field and how ?
For now I'm going to have only one button in the ShareSheet, so only one activity and intent.
I will add a page in my app asking the user which scenario he wants to be done with the file but for a future update it would be awesome to be able to have both ! :)
Describe the bug
If the app is open (even opened manually or successfully after a share intent action) and you use the share option by minimizing the app and sending a photo from the device to the app, then send intent event is not triggered again.
So if the user adds a photo, for example, then minimizes the app and tries to share again another photo to append or replace what was added before, is not working. There is no error but the intent event is not triggering again.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Send intent should be triggered again
I am encountering a critical issue with the send intent functionality in my Ionic project. The problem is specific to Android devices. Although the functionality operates seamlessly on iOS, on Android, after sharing data and swiping up to access files or images, the app redirects to the previous URL or reloads the current page
Here is my AndroidManifest.xml activity code for intent
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:name="de.mindlib.sendIntent.SendIntentActivity"
android:label="@string/app_name"
android:exported="true"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="application/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
</intent-filter>
Describe the bug
Hi, I updated my sveltekit to work with https://github.com/CodetrixStudio/CapacitorGoogleAuth which had a dependency of "vite": "^3.0.0"
Now the send-intent module module fails to import with the following error. Any pointers would be much appreciated.
Many thanks,
Joe
(node:11444) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use node --trace-warnings ...
to show where the warning was created)
Cannot use import statement outside a module
C:\Users\joe\Documents\web\my-app2\node_modules\send-intent\dist\esm\index.js:1
import { registerPlugin } from "@capacitor/core";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap. (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
However, It works with "vite": "^2.9.13"
To Reproduce
npm create svelte my-app
cd my-app
yarn install
yarn add @capacitor/core @capacitor/cli send-intent
update index file to import send-intent
// .\src\routes\index.svelte
<script lang="ts">
import { SendIntent } from "send-intent";
</script>
Expected behavior
The compiling error prevents the page from loading
Desktop (please complete the following information):
Hello,
is it possible to receive several files like images? , when testing with Android, the application disappears from the sharing choice.
I also saw that there was an open ticket also for IOS.
Best Regards
Hi,
i'm using capacitor 3.0 and having same issue discribed/solved here:
capacitor-community/firebase-analytics#55 (comment)
maybe also necessary to backport here?
Describe the bug
Following instructions in the README, I added the activity on AndroidManifest.xml
The app now appears in the share dialog, but when clicked it seems to open and crash immediately.
appreciate any help
Screenshots
If applicable, add screenshots to help explain your problem.
Smartphone (please complete the following information):
Additional context
On ios everything works as expected
Is it possible with this plugin to be able to share directly to the app without having to 1st go through the ios middle ground popup?
For example, like in the gmail app the shared content just gets passed straight through to the app.
ios 14.7.1
xcode 12.5.1
latest capacitorjs with the recent and latest updated code to this plugin
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:
Actually the issue is configuration provided in the plugin documentation for ios is not working. i have added the configuration in info.plist but still my app is not appearing in mobile sharelist.
Describe the bug
If i share a file, e.g. an image, the function createSharedFileUrl
of the ShareViewController passes to many /
file%3A%2F%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2F1C0BA5F1-DE70-123D-8435-1F125779A3CE%2F%2FIMG_0029.PNG
file:///private/var/mobile/Containers/Shared/AppGroup/1C0BA5F1-DE70-123D-8435-1F125779A3CE//IMG_0029.PNG
So, i get file:///
and //filename.PNG
I can remove the + "/" +
from inside the createSharedFileUrl
which helps with the //
in front of the filename, but i cant figure out how to remove one of the ///
without manipulating the file url itself.
To Reproduce
Steps to reproduce the behavior:
/
Expected behavior
The shared file url should look like that:
file%3A%2F%2Fprivate%2Fvar%2Fmobile%2FContainers%2FShared%2FAppGroup%2F1C0BA5F1-DE70-123D-8435-1F125779A3CE%2FIMG_0029.PNG
file://private/var/mobile/Containers/Shared/AppGroup/1C0BA5F1-DE70-123D-8435-1F125779A3CE/IMG_0029.PNG
Additional context
Currently working with "send-intent": "^3.0.12"
Inside of my Capacitor/Angular App i have added some sort of Workaround for that. Its definitely not pretty, but it works. But i also want to get rid of it.
try {
intent.url = intent.url.replaceAll('%2F%2F', '%2F'); // '//' -> '/'
if (!intent.url.includes('%3A%2F%2F') && intent.url.includes('%3A%2F')) {
intent.url = intent.url.replace('%3A%2F', '%3A%2F%2F'); // ':/' -> '://';
}
const resultUrl = decodeURIComponent(intent.url);
...
Describe the bug
I created a basic Capacitor app and added the "de.mindlib.sendIntent.SendIntentActivity" Activity:
<activity
android:name="de.mindlib.sendIntent.SendIntentActivity"
android:label="My Uploader"
android:exported="true"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
</activity>
I can select this app as share target in many apps such as YouTube and Google Photo's, but the app is not listed in the "Open With" list if I click on an attachment in Gmail. This is exacly my use case, so I really need that.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
My app should show up in the "Open With" list of GMail when clicking on an attachment.
Smartphone (please complete the following information):
I make test with android . If my app is already started , and do image share , the app reload , why ? Share works ok , but I would like to avoid the reload
Describe the bug
When registering the new activity in android manifest, I get an error saying that the SendIntentActivity class cannot be found.
To Reproduce
Steps to reproduce the behavior:
1: Install plugin with npm and run npx cap sync
2: Edit the AndroidManifest.xml to add the new activity directly under the main activity.
3: AndroidStudio highlights the line "android:name="de.mindlib.sendIntent.SendIntentActivity" saying class not found
4: Edit the above line to the correct namespace (in my case com.rewind.app) so "com.rewind.app.SendIntentActivity"
5: AndroidStudio still says class not found, I have tried several variations e.g. com.rewind.sendIntent.SendIntentActivity etc but with no success. If I search my whole project it says there is no class called SendIntentActivity
Expected behavior
I would expect the class to be found
Additional info
I can still build the prject, but if I then try to share to the app it crashes and I get a similar error about the class not existing.
Is this a bug or am I just missing something? If I am missing something is there an opportunity to update the docs to clarify.
p.s. Thank you for this plugin
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.