sorry for my english.
I'm trying to send notification from my server which runs spring boot to iOS device using FCM Admin SDK.
- Spring boot version 1.5.17
- firebase-admin version 9.0.0
- java 8
Here my message to FCM:
Message message = Message.builder()
.setNotification(Notification.builder()
.setTitle("title accross platform")
.setBody("body accross platform")
.setImage("imgUrl accross platform")
.build())
.setAndroidConfig(AndroidConfig.builder()
.setNotification(AndroidNotification.builder()
.setImage("image url for Android")
.build())
.build())
.setApnsConfig(ApnsConfig.builder()
.setFcmOptions(ApnsFcmOptions.builder()
setImage("image url for iOS")
.build())
.setAps(Aps.builder()
.setAlert("notification body for iOS")
.setMutableContent(true)
.build())
.build())
.setToken("token string")
.build();
and FCM returns:
Caused by: com.google.api.client.http.HttpResponseException: 400 Bad Request
POST https://fcm.googleapis.com/v1/projects/{project-id}/messages:send
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
},
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "message.token",
"description": "Invalid registration token"
}
]
}
]
}
}
at com.google.api.client.http.HttpResponseException$Builder.build(HttpResponseException.java:293)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1118)
at com.google.firebase.internal.ErrorHandlingHttpClient.send(ErrorHandlingHttpClient.java:96)
... 25 common frames omitted
but when i change my message to:
.setAps(Aps.builder()
.setAlert(ApsAlert.builder()
.setBody("notification body for iOS")
.build())
.setMutableContent(true)
.build())
FCM returns success for the same token. I need Alert to be a String for older version iOS devices. Any help would be greatly appreciated!