METHOD_GetContactPhotos

This method sends a request to BEMS to retrieve the photos or avatars associated with a user's contacts in the BlackBerry Connect app contact list.

The following table describes the parameters that you can include in this method.

Parameter

Type

Required

Description

contactIds

JsonArray

√

This parameter specifies an array of contact IDs to retrieve the photo data for.

dependencies String — This parameter specifies the other methods that this method is dependent on. It specifies the comma delimited dependent request ids.
reconnect String — This parameter specifies that the BlackBerry Connect app re-establish the existing session. For example, if BlackBerry Connect goes to the background, when it comes to the foreground the same session is continued.

BEMS response and notification

The following table describes the parameters that BEMS returns and the notifications to send to the BlackBerry Connect app when the contacts' photos or avatars are retrieved.

Parameter

Type

Description

method

String

This parameter specifies the method invoked (for example, GetContactPhotos).

state String This parameter specifies the state of the request to BEMS (for example, Processing or complete).
contacts JsonArray This parameter specifies a list of the contacts' photos or avatars.

Example code

The following example sends a request to BEMS to return the contacts' photo or avatar for the contacts in the contact list.

{
 "id":"c12",
 "method":"GetContactPhotos",
 "params":
   {
     "contactIds":{["user1@example.com", "user2@example.com", "user3@example.com"]}
   },
 "jsonrpc":"2.0"
}

If the request is successful, BEMS sends the following response to the BlackBerry Connect app and processes the request.

{
  "id":"c12",
  "error":null,
  "result":
   {
     "data":
     {
       "method":"GetContactPhotos",
       "state":"PROCESSING"
     }
   },
 "jsonrpc":"2.0",
 "background": true
}

If there are no errors, BEMS sends the following notification to the BlackBerry Connect app and the contact's photos or avatars are displayed.

Note: If contacts do not have photo or avatar, or are invalid contacts, the notification returns an empty value.
{
  "id":"c12",
  "sequence":1018557800000049,
  "result":
   {
    "data":
     {
       "contacts":
       {
         "user1@example.com":
           {
             "photoHash":"0123456789abcdef...",       // hex encoded md5 hash of photo data(32 bytes hex)
             "photoData":"<base64 encoded image data>"
           },
         "user2@example.com":
           {
             "photoHash":"0123456789abcdef...",
             "photoData":"<base64 encoded image data>"
           },
         "user3@example.com":
           {
            "photoHash":"",
            "photoData":""
           }
      }
    "method":"GetContactPhotos",
    "state":"COMPLETE"
  },
 "jsonrpc":"2.0"
}