package com.quickblox.q_municate_core.utils.helpers;

import android.text.TextUtils;

import com.quickblox.core.helper.StringifyArrayList;
import com.quickblox.messages.model.QBEnvironment;
import com.quickblox.messages.model.QBEvent;
import com.quickblox.messages.model.QBNotificationType;
import com.quickblox.messages.model.QBPushType;

import java.util.HashMap;
import java.util.List;

public class CoreNotificationHelper {

    public static QBEvent createPushEvent(List<Integer> userIdsList, String message, String messageType) {
        StringifyArrayList<Integer> userIds = new StringifyArrayList<Integer>();
        userIds.addAll(userIdsList);
        QBEvent event = new QBEvent();
        event.setUserIds(userIds);
        event.setEnvironment(QBEnvironment.PRODUCTION);
        event.setNotificationType(QBNotificationType.PUSH);
        event.setPushType(QBPushType.GCM);
        setMessage(event, message, messageType);
        return event;
    }

    private static void setMessage(QBEvent event, String message, String messageType) {
        if (!setMessageWithTypeIfNeed(event, message, messageType)) {
            event.setMessage(message);
        }
    }

    private static boolean setMessageWithTypeIfNeed(QBEvent event, String message, String messageType) {
        if (!TextUtils.isEmpty(messageType)) {
            HashMap<String, Object> data = new HashMap<>();
            data.put("data.message", message);
            data.put("data.type", messageType);
            event.setMessage(data);
            return true;
        }
        return false;
    }
}
@@ -331,16 +331,100 @@
 ushType;
+%0Aimport com.quickblox.q_municate_core.utils.ConstsCore;%0A%0Aimport org.json.JSONObject;
 %0A%0Aimport
@@ -925,51 +925,8 @@
 H);%0A
-        event.setPushType(QBPushType.GCM);%0A
     
@@ -1381,83 +1381,473 @@
     
-HashMap%3CString, Object%3E data = new HashMap%3C%3E();%0A            data
+String eventMsg = customMessage(message, messageType);%0A            event.setMessage(eventMsg);%0A            return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A    private static boolean isCallType(String messageType) %7B%0A        return TextUtils.equals(messageType, ConstsCore.PUSH_MESSAGE_TYPE_CALL);%0A    %7D%0A%0A    private static String customMessage(String message, String messageType) %7B%0A        JSONObject json = new JSONObject();%0A        try %7B%0A            json
 .put(%22
-data.
 mess
@@ -1878,23 +1878,51 @@
     
-data
+// custom parameters%0A            json
 .put(%22
-data.
 type
@@ -1954,55 +1954,203 @@
     
-event.setMessage(data);%0A            return true
+if (isCallType(messageType)) %7B%0A                json.put(%22ios_voip%22, %221%22);%0A                json.put(%22VOIPCall%22, %221%22);%0A            %7D%0A%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace()
 ;%0A  
@@ -2164,30 +2164,40 @@
 %0A        return 
-false
+json.toString()
 ;%0A    %7D%0A%7D

add support Ios Voip