Subscribe to topics
ArrayList<MBTopic> topics = new ArrayList<MBTopic>()
topics.add(new MBTopic(
TOPIC_CODE, //The main topic String to which subscribe (eg. sport)
TOPIC_NAME, //A familiar name to give your topic (eg. Sport Club)
false //If it's a topic where only one user should subscribe
))
MBurgerPushTasks.registerTopics(context,
getDeviceId(context), topics)@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map<String, String> map = remoteMessage.getData();
//The standard message is inside the "body" field
String msg = map.get("body");
if(map.containsKey("custom")) {
String custom = map.get("custom");
if(custom != null){
try {
JSONObject jCustom = new JSONObject(custom);
//Take out the data you inserted inside the notification and create your notification with Android SDK.
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}Push topics management
Last updated