Capacitor: Social Share dont work with capacitor

Created on 31 Oct 2019  ·  7Comments  ·  Source: ionic-team/capacitor

Hi guys, in my project I try to use "share api" of the condenser but in this api I can't share images, so I tried to use social sharing of cordova but when I run the server the following error shows me:
Uncaught TypeError: Object(...) is not a function
at eval (index.js?01a3:413)
at eval (index.js?01a3:590)
at Module../node_modules/@ionic-native/social-sharing/index.js (app.js:1318)
at __webpack_require__ (app.js:724)
at fn (app.js:101)
at eval (cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/footer_menu_var/Pagar.vue?vue&type=script&lang=js&:2)
at Module../node_modules/vuetify-loader/lib/loader.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/footer_menu_var/Pagar.vue?vue&type=script&lang=js& (app.js:6242)
at __webpack_require__ (app.js:724)
at fn (app.js:101)
at eval (Pagar.vue?db58:1)

Any solution let me know, thanks.

Most helpful comment

Also am curious about whether there is a way to attach a file or embed an image with Share.

All 7 comments

doesn't look related to Capacitor. Can you provide a sample app?

Tanks for write, ok let me show the code:
let share = Share.share({
title: 'QR',
text: this.imagenQrbase64,
dialogTitle: 'Guardar en.....'
});
the code is simple, I only use the structure that is in the documentation, but when trying to share the image by whatsapp, only the text in base 64 passes, or how should I pass the image?, thanks for the help

Also am curious about whether there is a way to attach a file or embed an image with Share.

@kevinclarkadstech There is not currently. I need that feature as well for a conversion from cordova to capacitor.

Share plugin has an url param, use that to share a file url.
It's working fine on iOS, was broken on Android, just sent a PR adding support. Note that you can't use url+text to share a file on Android, will only work if no text is present (title can be present).

Base 64 urls are not supported.

Pardon the new comment on a "closed" item, but I want to tack on another note.
If we use the Capacitor Filesystem API to save a file to something that is not FilesystemDirectory.External (or the like) then we need to make sure that we update the file_paths.xml file to tell the Android app where to look.
E.g. when using the application cache, we need to add <cache-path name="cache" path="/" /> to the file paths xml file.
The final piece is to make sure we have all of the right permissions, but for now this worked for me.

Still doesnt work... Cannot use socialsharing from ionic-native with capacitor, i have everything updated (latest version)

Was this page helpful?
0 / 5 - 0 ratings