Skip to content

Share Content

Sharing an activity

Create invite content from the activity

val activity: GetSocialActivity // activity to share

val inviteContent = InviteContent()
// set text
inviteContent.text = activity.text
// set image 
inviteContent.mediaAttachment = activity.attachments.first()
// set activity id
val activityData = HashMap<String, Any>();
activityData["ACTIVITY_ID"] = activity.id
inviteContent.linkParams = activityData
let activity: Activity //  activity to share

let inviteContent = InviteContent()
// set text
inviteContent.text = activity.text
// set image
inviteContent.mediaAttachment = activity?.mediaAttachments.first
// set activity id
inviteContent.linkParams = ["ACTIVITY_ID": (activity!.id as NSString)]

Send the invite

// send the invite via email
Invites.send(inviteContent, InviteChannelIds.EMAIL, {
    Log.d("Communities", "Invite sent")
}, {
    Log.d("Communities", "Sending invite cancelled")
}, { error ->
    Log.d("Communities", "Failed to send invite: $error")
})
// send the invite via email
Invites.send(inviteContent, onChannel: InviteChannelIds.email, success: {
    print("Invite sent")
}, cancel: {
    print("Sending invite cancelled")
}, failure: { error in
    print("Failed to send invite: \(error)")
})

Receive the invite

Invites.setReferralDataListener({ data ->
    // get activity data
    val activityId = data.linkParams["ACTIVITY_ID"]
})
Invites.setOnReferralDataReceivedListener({ data in
    let activityId = data.linkParams["ACTIVITY_ID"]
})

Give us your feedback! Was this article helpful?

😀 🙁