Quickstart Guide: Share Component
Share Component
Get started
Using Ionic or Cordova? Get the Share component working in your app in four easy steps.
- Download the component
- Add it to your environment
- Using Share
- Troubleshoot
1. Download the Onymos Share component
Sign up! We’ll send you a link to your component, set up your Onymos Cloud Account, and generate your Onymos license credentials. In the meantime, you can get familiar with our API Documentation and developer resources, or join a whole community of developers building apps with Onymos on Reddit!
2. Add it to your environment
Add your components to a folder in your app’s root (e.g., onymos_components).
Add the Onymos Initialize component to your environment.
$ cordova plugin add onymos_components/onymos-component-initialize
Then we can add the Onymos Share component.
$ cordova plugin add onymos_components/onymos-component-share
Then update the widget inside your config.xml with the Onymos Widget ID you receive after you create an Onymos Cloud Account.
3. Using Share
Nobody uses just one app, even if it’s a really good one—like yours! You can use the Onymos Share component to send messages from your app to Gmail, Bluetooth, Google Drive, and more.
Before we use Share, let’s make sure we have everything we need to configure your onymosConnectObject. The onymosConnectObject requires the appropriate Onymos license credentials: your Customer ID (also called an Onymos ID) and your Onymos Auth Token. You’ll need these credentials to use this (or any) component in your app.
Next, let’s go inside your Cordova app’s index.js file and initialize Share.
var OnymosInitalize
var OnymosShare
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady() {
const OnymosConnectObject={
customerId : 'Your customerId goes here',
onymosAuthToken : 'Your onymosAuthToken goes here',
envType: 'PRD'
}
OnymosInitialize.initialize(
OnymosConnectObject,
function onymosInitializeSuccess(status){
console.log("Onymos initialized Successfully.", status)
},
function onymosInitializeFailure(error){
console.log("Onymos failed to initialize.", error)
})
}
Great! If we configured your onymosConnectObject correctly, onymosInitializeSuccess() should print its message to the console. Now we’re ready to use Share.
Share is one of the simplest Onymos components for developers to use. Its only method, showSocial(), does everything you need. Let’s create a function called share() in the index.js file. We’ll use it to invoke showSocial().
function share(message){
OnymosShare.showSocial(
message
function showSocialSuccess(status) {
console.log(status)
},
function showSocialFailure(error) {
console.log(error)
})
}
The share() function accepts a string—the message—and passes it to the showSocial() method and, from there, to another app!
Think you’re saving time now? Wait until you’ve added even more Onymos components. See how they work by checking out the API documentation.
4. Troubleshooting
How do I squash this bug? Is Ionic supposed to do that? Why is this iOS build failing?
Let’s figure it out—join the Onymos community on Reddit! More of a loner? You can email us directly at customersuccess@onymos.com.
Dig into our API documentation
Developer support
Got questions? Our support team is here to help.
Think differently about app development
Download our free white paper today to learn how Onymos Features can maximize the value of your developer resources — and shave days or weeks off your development timeline.