~avalos/trackermap-server

c48b0f67d93bbc8aa7e94a7ee06082386d08a101 — Iván Ávalos 25 days ago 8f9d6ef fix-fcm-exception
Fixed exception when a FCM token is empty
1 files changed, 7 insertions(+), 1 deletions(-)

M src/main/java/org/traccar/notificators/NotificatorFirebase.java
M src/main/java/org/traccar/notificators/NotificatorFirebase.java => src/main/java/org/traccar/notificators/NotificatorFirebase.java +7 -1
@@ 25,6 25,7 @@ import com.google.firebase.messaging.FirebaseMessaging;
import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.MulticastMessage;
import com.google.firebase.messaging.Notification;

import org.traccar.config.Config;
import org.traccar.config.Keys;
import org.traccar.model.Event;


@@ 40,6 41,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;

@Singleton
public class NotificatorFirebase implements Notificator {


@@ 67,7 70,10 @@ public class NotificatorFirebase implements Notificator {

            var shortMessage = notificationFormatter.formatMessage(user, event, position, "short");

            List<String> registrationTokens = Arrays.asList(user.getString("notificationTokens").split("[, ]"));
            List<String> registrationTokens = Arrays.asList(user.getString("notificationTokens").split("[, ]"))
                    .stream()
                    .filter(t -> !t.isEmpty())
                    .collect(Collectors.toList());

            MulticastMessage message = MulticastMessage.builder()
                    .setNotification(Notification.builder()