Пример #1
0
  public void pushBadge(String appId, String userId, String chatRoomId) {
    try {
      Application app = appModel.getApplication(appId);
      Boolean flagNotification = chatModel.hasNotification(appId, chatRoomId);
      List<Certificate> certList = new ArrayList<Certificate>();

      if (flagNotification) {
        List<String> clientsList = app.getClients();
        Iterator<String> it2 = clientsList.iterator();
        while (it2.hasNext()) {
          String clientId = it2.next();
          certList.add(noteModel.getCertificate(appId, clientId));
        }
        Iterator<Certificate> it3 = certList.iterator();
        while (it3.hasNext()) {
          Certificate certi = it3.next();
          List<Device> devices = noteModel.getDeviceIdList(appId, userId, certi.getClientId());
          if (devices != null && devices.size() > 0) {
            int numberBadge = chatModel.getTotalUnreadMsg(appId, userId).size();
            ApplePushNotifications.pushBadgeService(
                numberBadge,
                certi.getCertificatePath(),
                certi.getAPNSPassword(),
                Const.getAPNS_PROD(),
                devices);
          }
        }
      }
    } catch (Exception e) {
      Log.error("", this, "pushBadge", "Error pushing the badge.", e);
    }
  }
Пример #2
0
  public void pushNotificationCombine(
      String appId,
      String sender,
      String chatRoomId,
      String fileText,
      String videoText,
      String imageText,
      String audioText,
      String messageText) {

    List<String> participants = new ArrayList<String>();
    participants = chatModel.getListParticipants(appId, chatRoomId);
    try {
      if (participants.size() > 0 && participants != null) {
        Boolean flagNotification = chatModel.hasNotification(appId, chatRoomId);
        Application app = appModel.getApplication(appId);
        List<String> clientsList = app.getClients();
        List<Certificate> certList = new ArrayList<Certificate>();
        if (flagNotification) {
          Iterator<String> it2 = clientsList.iterator();
          while (it2.hasNext()) {
            String clientId = it2.next();
            certList.add(noteModel.getCertificate(appId, clientId));
          }
        }
        List<String> unReadUsers = new ArrayList<String>();
        Iterator<String> it = participants.iterator();
        while (it.hasNext()) {
          String curr = it.next();
          if (!curr.equals(sender)) {
            unReadUsers.add(curr);
            if (flagNotification) {
              if (app != null) {
                if (clientsList != null && clientsList.size() > 0) {
                  if (certList.size() > 0) {
                    Iterator<Certificate> it3 = certList.iterator();
                    while (it3.hasNext()) {
                      Certificate certi = it3.next();
                      List<Device> devices =
                          noteModel.getDeviceIdList(appId, curr, certi.getClientId());
                      if (devices != null && devices.size() > 0) {
                        int badge = chatModel.getTotalUnreadMsg(appId, curr).size();
                        ApplePushNotifications.pushCombineNotification(
                            "Recebeu uma mensagem nova",
                            badge,
                            certi.getCertificatePath(),
                            certi.getAPNSPassword(),
                            Const.getAPNS_PROD(),
                            devices);
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    } catch (Exception e) {
      Log.error("", this, "pushNotificationCombine", "Error in pushNotificationCombine.", e);
    }
  }