Social Share

Use the Native Social Share to allow Easy Link & Content Sharing

The Despia Social Share SDK enables your application to open native share sheets, allowing users to share content directly from your app to their preferred social platforms, messaging apps, and other sharing services. This provides a seamless sharing experience while leveraging the device's native UI.

Quick Start

1. Create a share message and URL

const message = "Check out this app!"
const url = "https://yourapp.com"

2. Trigger the native share sheet

window.despia = `shareapp://message?=${message}&url=${url}`

3. Handle the sharing process

The native sharing UI will appear, allowing users to select their preferred sharing method.

How It Works

The Social Share SDK uses a custom URL scheme to communicate with the native device capabilities. When the share command is triggered:

  • The SDK opens the native share sheet on the user's device

  • Users can select from available sharing options on their device

  • The message and URL are pre-populated in the share sheet

  • The native sharing process handles the rest of the interaction

Implementation Examples

Here are practical examples of how to implement the Social Share SDK in different scenarios:

// Basic implementation example
const message = "Love this app!"
const url = "https://yourapp.com"

// Simply run this line of JS using a custom JavaScript action, no callback needed!
window.despia = `shareapp://message?=${message}&url=${url}`

The Social Share SDK uses a simple URL scheme structure:

// Basic structure
`shareapp://message?=${message}&url=${url}`

// Where:
// message - The text content to be shared
// url - The URL to be included in the share

Best Practices

Content Optimization

  • Keep messages clear and concise

  • Always include valid URLs

  • Test on different devices

User Experience

  • Handle long messages gracefully

  • Consider different sharing apps

  • Provide clear sharing context to users

Complete Implementation Example

Here's a complete implementation example showing how to integrate the Social Share SDK in various scenarios:

// Share Simple Message
const shareSimpleMessage = () => {
  const message = "Love this app!"
  const url = "https://yourapp.com"
  
  window.despia = `shareapp://message?=${message}&url=${url}`
}

// Share Product
const shareProduct = (productName, productUrl) => {
  const message = `Just found this amazing product: ${productName}`
  const url = productUrl
  
  window.despia = `shareapp://message?=${message}&url=${url}`
}

// Share Achievement
const shareAchievement = (achievement) => {
  const message = `Just reached ${achievement} in the app!`
  const url = "https://yourapp.com/download"
  
  window.despia = `shareapp://message?=${message}&url=${url}`
}

// Usage examples
document.getElementById("shareSimple").addEventListener("click", shareSimpleMessage);
document.getElementById("shareProduct").addEventListener("click", () => {
  shareProduct("Eco-friendly Water Bottle", "https://yourapp.com/product/123");
});
document.getElementById("shareAchievement").addEventListener("click", () => {
  shareAchievement("level 100");
});

Troubleshooting

Common Issues

Share Sheet Not Opening

  • Verify the URL scheme syntax is correct

  • Check for special characters in your message that might need encoding

  • Ensure the device supports native sharing

Incorrect Content Shared

  • Check for proper URL encoding of message parameters

  • Verify URL validity

  • Test with simplified content first

Platform-Specific Issues

  • iOS and Android may handle sharing differently

  • Some platforms may have limitations on shared content

  • Test across multiple device types

Need Help?

For additional support or questions, please contact our support team at support@despia.com

Updated on