Are there any plugins that would allow a user to share my app.
For example, I have a button that says “Share App.” The user clicks the button and
it opens a list of options such as whatsapp, facebook, twitter etc similar to that of
“navigator.share()”
ghenne
August 31, 2022, 12:28pm
2
If you go to npmjs.com , you can search using cordova share
.
One of the hits is cordova-plugin-x-socialsharing , which might do what you need. (There is a version for Android 12 called cordova-plugin-x-socialsharing-android12)
Thanks. I am using that but getting this error:
TypeError: Cannot read properties of undefined (reading 'socialsharing')
config.xml
<?xml version = '1.0' encoding = 'UTF-8' ?>
<widget
android-versionCode = '1'
id = 'com.test.testapp'
version = '1.0.0'
xmlns = 'https://www.w3.org/ns/widgets'>
<name>test</name>
<description>testing </description>
<author>More Testing</author>
<preference name = 'orientation' value = 'portrait'/>
<preference name="permissions" value="none" />
<preference name="AndroidXEnabled" value="true" />
<plugin name="cordova-plugin-whitelist" />
<plugin name="cordova-plugin-x-socialsharing-android12" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
</widget>
Javascript file
$(document).on('click', '.shareApp', function(){
var options = {
message: "test app sharing",
files: ['', ''],
url: "https://developer.mozilla.org",
chooserTitle: "Share app 1"
}
try {
window.plugins.socialsharing.shareWithOptions(options)
} catch(err) {
alert(err)
}
})
I am stumped.
ghenne
August 31, 2022, 5:35pm
4
First think I see is that you should specify engine spec 11 .
<?xml version = '1.0' encoding = 'UTF-8' ?>
<widget
android-versionCode = '1'
id = 'com.test.testapp'
version = '1.0.0'
xmlns = 'https://www.w3.org/ns/widgets'>
<name>test</name>
<description>testing </description>
<author>More Testing</author>
<engine name="android" spec="11.0.0" />
<preference name = 'orientation' value = 'portrait'/>
<preference name="permissions" value="none" />
<preference name="AndroidXEnabled" value="true" />
<plugin name="cordova-plugin-x-socialsharing-android12" />
<access origin="*" />
<allow-navigation href="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
</widget>
Getting the same error.
TypeError: Cannot read properties of undefined (reading 'socialsharing')
My bad i forgot to include “cordova.js” in my index.html.
oops. It is working now.