Skip Navigation

METHOD_NotifyBackground

This method informs 
BEMS
 that the 
BlackBerry Connect
 app is in the background or the foreground.
The following table describes the parameters that you can include in this method.
Parameter
Type
Required
Description
isBackgroundMode
Boolean
This parameter specifies that the 
BlackBerry Connect
 app is in the background or exited from the background.
  • If this value is true, 
    BEMS
     is notified that the 
    BlackBerry Connect
     app is in the background.
  • If this value is false, 
    BEMS
     is notified that the 
    BlackBerry Connect
     app is in the foreground.
timeout
Integer
This parameter specifies the duration to wait before going to the background or foreground. The default timeout value is in seconds. 
unreadMessageCount
Integer
This parameter specifies the number of unread instant messages. 
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.
pushType
String
This parameter specifies one of the five push types.
  • Unknown = 0
  • None = 1
  • Default = 2
  • Sender = 3
  • SenderandMessage = 4 
pushMaxLength
Integer
This parameter specifies the maxPayLoadSize for the notification (for example, the FCM or APNS notifications). 
The notification message for this request might include the prior value because 
BEMS
 can send a response before processing the request.

BEMS
 response and notification

The following table describes the parameters that 
BEMS
 returns and the notification that is sent to the 
BlackBerry Connect
 app when the app is in the background.
Parameter
Type
Description
state
String
This parameter specifies the state of the request to 
BEMS
 (for example, Processing or Complete). 
method
String
This parameter specifies the method invocation name (for example, NotifyBackground).

Example code 

The following example sends a request to 
BEMS
 to notify it that the 
BlackBerry Connect
 app is in the background.
{ "params": { "isBackgroundMode":"true", "unreadMessageCount":"50", "pushMaxLength":"0", "pushType":"4", "timeout":"5" }, "id":"c3", "method":"NotifyBackground", "jsonrpc":"2.0" }
If the request is successful, 
BEMS
 sends the following response to the 
BlackBerry Connect
 app and processes the request.
{ "id":"C3", "error":null, "result": { "data": { "method":"NotifyBackground", "state":"PROCESSING" } }, "jsonrpc": "2.0", "background": true }
If there are no errors, 
BEMS
 sends the following notification to the 
BlackBerry Connect
 app when the app goes to the background.
{ "id":"C3", "sequence":1018536800000019, "result": { "data": { "method":"NotifyBackground", "state":"COMPLETE" } }, "jsonrpc":"2.0" }