Files
sumoc-backend/src/main/java/SuMoC/backend/firebase/FirebaseMessageBuilder.java
T
neuhauss 80abd0f34f
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
test fix: correct notification building for ios
2026-02-09 10:27:07 +01:00

31 lines
1.1 KiB
Java

package SuMoC.backend.firebase;
import SuMoC.backend.notification.models.Notification;
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());
return builder.build();
}
public Message generateMessageIos(Notification notification, String token) {
var builder = Message.builder().setToken(token);
builder.putData("type", notification.getType().toString());
builder.putData("data", notification.getData());
var apnConfig = com.google.firebase.messaging.ApnsConfig.builder()
.setAps(com.google.firebase.messaging.Aps.builder()
.setContentAvailable(true)
.build())
.build();
builder.setApnsConfig(apnConfig);
return builder.build();
}
}