Integrating Social Media Content Sharing in a Mobile Application
A "Share" button can work two ways: via system share sheet or direct API integration with each network. System sheet (iOS UIActivityViewController, Android Intent.ACTION_SEND) is faster, requires zero code for new platforms. Direct API integration gives content control: prefilled text, specific format, platform analytics.
System Sharing
Fastest option. User selects platform from installed apps.
iOS:
func shareContent(text: String, imageURL: URL?, deeplink: URL) {
var activityItems: [Any] = [text, deeplink]
if let imageURL, let imageData = try? Data(contentsOf: imageURL),
let image = UIImage(data: imageData) {
activityItems.append(image)
}
let vc = UIActivityViewController(activityItems: activityItems, applicationActivities: nil)
// Exclude unneeded activity types
vc.excludedActivityTypes = [.addToReadingList, .assignToContact]
present(vc, animated: true)
}
iPad requires popoverPresentationController—missing this crashes on iPad.
Android:
val shareIntent = Intent(Intent.ACTION_SEND).apply {
type = if (imagePath != null) "image/*" else "text/plain"
putExtra(Intent.EXTRA_TEXT, "$text\n$deeplinkUrl")
imagePath?.let { path ->
val imageUri = FileProvider.getUriForFile(context, "${context.packageName}.provider", File(path))
putExtra(Intent.EXTRA_STREAM, imageUri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
}
startActivity(Intent.createChooser(shareIntent, "Share"))
Flutter: share_plus package:
await Share.shareXFiles(
imagePath != null ? [XFile(imagePath)] : [],
text: '$text\n$deeplinkUrl',
subject: postTitle, // for email clients
);
Direct Integration: Telegram
Simplest direct sharing—via Telegram URL scheme without API:
tg://msg?text=Post%20text%20https%3A%2F%2Fapp.example.com%2Fpost%2F123
If Telegram installed—opens chat selection with prefilled text. No OAuth, no SDK.
For web preview in Telegram, important Open Graph markup on deeplink URL: og:title, og:description, og:image. Telegram Bot API for bot sharing—separate scenario.
Direct Integration: VKontakte
SDK and OAuth described separately. For sharing without full auth—VK Share Dialog via URL scheme:
vkcom://share?url=https://app.example.com/post/123&title=Title
Or web fallback:
https://vk.com/share.php?url=https://app.example.com/post/123&title=Title
Web version opens in SFSafariViewController / Custom Chrome Tab—works without installed VKontakte.
Native Deep Links for Sharing
Sharing value multiplies if link opens app (not browser) on recipient. Implementation:
- iOS: Universal Links (
apple-app-site-associationon domain) + handle inapplication(_:continue:restorationHandler:). - Android: App Links (
assetlinks.json+intent-filterwithandroid:autoVerify="true"). - Fallback: app not installed—open web with smart banner "Open in App."
Firebase Dynamic Links simplified this, but Google discontinued service. Alternatives: Branch.io, Adjust Smart Links, custom implementation.
Sharing Analytics
Track: when creating share link, add UTM params utm_source=app_share&utm_medium=social&utm_content={post_id}. Log to analytics (Firebase, Amplitude) content_shared event with platform, content_type, content_id. From UTM clicks in web analytics, see traffic return.
Timeline
System share sheet with deeplink: 1 day. Adding direct Telegram and VK sharing: +1 day. Full system with analytics and universal links: 2–3 working days. Pricing calculated individually.







