Silent push

Overview


Silent push is a hidden notification that is delivered to the app. It does not cause any interaction with the user like a typical push. Silent notifications quietly deliver a certain set of data to the app so you may use it to notify that new content is available or inform about changes in the content. This kind of campaign does not affect your UI.

Within the silent push campaign, the SDK provides features such as remote sign out or acquiring location by using a silent push command. Read more in the SDK Commands section.

Configuration


Silent push campaign is served by push notifications. See:

Additionally, check possible available configuration options in the Settings.

Checking custom notification payloads


The silent push campaign is designed to send notifications with your own payload and in this case should not be passed to the SDK. However, the campaign allows sending any data in payload including SDK commands. Then, the notification must be handled correctly. You may use the samples below.

@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
  super.onMessageReceived(remoteMessage);

  Map<String, String> data = remoteMessage.getData();
  if (Injector.isSynerisePush(data)) {
    if (Injector.isSilentCommand(data)) {
      try {
        SilentCommand silentCommand = Injector.getSilentCommand(data);
        <<your logic here>>
      } catch (ValidationException e) {
        e.printStackTrace(); 
      }
    }
  } else {
    <<notification is not from Synerise>>
  }
}
extension NotificationService: UNUserNotificationCenterDelegate {
  func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
    let userInfo = notification.userInfo

    let isSyneriseNotification: Bool = Synerise.isSyneriseNotification(userInfo)
    if (isSyneriseNotification == true) {
      let isSyneriseSilentCommand: Bool = Synerise.isSyneriseSilentCommand(userInfo)
      if isSyneriseSilentCommand {
        <<your logic here>>
      }
    } else {
      <<notification is not from Synerise>>
    }

    completionHandler(.alert)
  }
}
Synerise.onReady(function() {
  onNotification: function(payload, actionIdentifier) {
    let isSyneriseNotification = Synerise.Notifications.isSyneriseNotification(payload);
    if (isSyneriseNotification == true) {
      let isSyneriseSilentCommand = Synerise.Notifications.isSilentCommand(payload);
      if (isSyneriseSilentCommand == true) {
        <<your logic here>>
      } else {
        <<notification is not from Synerise>>
      }
    }
  }
});

Payload



{
  "data": {
    <<campaign content>>
  }
}
{
  "aps": {
    "content-available": 1
  },
  <<campaign content>>
}

SDK Commands


SIGN_OUT

{
  "data": {
    "issuer": "Synerise",
    "message-type": "dynamic-content",
    "content-type": "silent-sdk-command",
    "content": {
      "class_name": "com.synerise.sdk.injector.Injector",
      "method_name": "SIGN_OUT",
      "method_parameters": []
    }
  }
}
{
  "aps": {
    "content-available": 1
  },
  "issuer": "Synerise",
  "message-type": "dynamic-content",
  "content-type": "silent-sdk-command",
  "content": {
    "class_name": "com.synerise.sdk.injector.Injector",
    "method_name": "SIGN_OUT",
    "method_parameters": []
  }
}

GET_LOCATION

{
  "data": {
    "issuer": "Synerise",
    "message-type": "dynamic-content",
    "content-type": "silent-sdk-command",
    "content": {
      "class_name": "com.synerise.sdk.injector.Injector",
      "method_name": "GET_LOCATION",
      "method_parameters": []
    }
  }
}
{
  "aps": {
    "content-available": 1
  },
  "issuer": "Synerise",
  "message-type": "dynamic-content",
  "content-type": "silent-sdk-command",
  "content": {
    "class_name": "com.synerise.sdk.injector.Injector",
    "method_name": "GET_LOCATION",
    "method_parameters": []
  }
}

Canonical URL: https://hub.synerise.com/developers/mobile-sdk/campaigns/silent-push