Share a block to Slack app via Android intent

  Kiến thức lập trình

I would like to create a block to share from my app to Slack:

val sendIntent = Intent()
sendIntent.setAction(Intent.ACTION_SEND)
sendIntent.setType("text/plain")
sendIntent.putExtra(Intent.EXTRA_TEXT, blockJson)
sendIntent.setPackage("com.Slack")
startActivity(sendIntent)

Block example:

{
  "type": "section",
  "text": {
    "type": "mrkdwn",
    "text": "New Paid Time Off request from <example.com|Fred Enriquez>nn<https://example.com|View request>"
  }
}

When I try to share this via Slack it’s only rendering the Json, and not the block visually. Sharing to a channel or user also just pastes the json and doesn’t show the block itself.

Is there a functionality like this for sharing from an external app? How would I render a preview?

LEAVE A COMMENT