What is the payload of a richLinkData in Apple Business Chat

272 views Asked by At

I am trying to send a richLink with the Apple Business Chat Sandbox. However I am not able to find out what the correct payload is. The sandbox does not provide a predefined payload for a richLink. Therefore I am using the RAW JSON tab in order to send a richLink.

The example from the apple documentation is not working and I think there are certain parts missing. Does anyone know what information is missing?

{
   "richLinkData": {
     "url": "https://www.apple.com/ipad-pro",
     "title": "iPad Pro",
     "assets": {
        "image": {
           "data": "/9j/4AAQSkZJRgABAQA…………<snipped>…………AAQAB/Z",
           "mimeType": "image/jpeg"
        }
     }
   }
}
1

There are 1 answers

0
Rachel On

The example Apple provides is only part of the solution. You must include the additional parameters that are required in an iMessage. The other required parameters are:

id

sourceId

destinationId

v

type

The different types can be found here, but for richLinkData we set it to richLink.

Here is an example with all the necessary parameters minus the data parameter.

    {
"v": "<populated on send>",
"id": "<populated on send>",
"sourceId": "<populated on send>",
"destinationId": "<populated on send>",
"richLinkData": {
    "url": "https://www.apple.com/ipad-pro",
    "title": "iPad Pro",
    "assets": {
        "image": {
            "data": "",
            "mimeType": "image/jpeg"
        }
    }
},
"type": "richLink"}

Copying and pasting this exactly won't work on it's own. You'll need to fill in the data parameter. The data field they provide won't work, because it has been truncated. To use an image of your choice, you will need to fill the data field with the base64 encoding of your image. You can go here to encode your image, but any base64 image encoder will work. You'll want to cut out data:image/jpeg;base64, because that portion is written for <img> elements. If you don't care about having an image, you can just delete the entire assets parameter.