package SuMoC.backend.firebase; import SuMoC.backend.notification.models.Notification; import com.google.firebase.messaging.ApnsConfig; import com.google.firebase.messaging.Aps; import com.google.firebase.messaging.ApsAlert; import com.google.firebase.messaging.Message; import org.springframework.stereotype.Service; @Service public class FirebaseMessageBuilder { public Message generateMessage(Notification notification, String token) { var builder = Message.builder().setToken(token); builder.putData("type", notification.getType().toString()); builder.putData("data", notification.getData()); //Setup, so iOS can receive and intercept Push Notifications builder.setNotification(com.google.firebase.messaging.Notification.builder() .setTitle("Sumoc Update") .setBody("Deine Nachricht ist da!") .build()) .setApnsConfig(ApnsConfig.builder() .setAps(Aps.builder() .setMutableContent(true) .setSound("default") // WICHTIG: Ohne Sound oft keine Anzeige .setBadge(1) .build()) .build()); return builder.build(); } }