I am using firebase of google.
I could develop push notification by firebase SDK. but when I implemented silent-notification(in background state app), I found it is not easy. I googled many pages and I found solution finally.
For another firebase users, I am posting on my blog.
(example)
. It is not useless in firebase console.
I could develop push notification by firebase SDK. but when I implemented silent-notification(in background state app), I found it is not easy. I googled many pages and I found solution finally.
For another firebase users, I am posting on my blog.
* background notification payload spec.
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1(example)
{
"aps" : {
"content-available" : 1
},
"acme1" : "bar",
"acme2" : 42
}
* using API
I can success by using firebase api
curl -X POST --header "Authorization: key=<apiauthkey>" \
--Header "Content-Type: application/json" \
https://fcm.googleapis.com/fcm/send \
-d@
## payload.json file
{
"to" : "",
"priority": "normal",
"content_available": true,
"notification" : {
"body" : "this is message",
"title" : "notification Title",
"link": "http://localhost"
"link": "http://localhost"
}
}
you can find "content-available: key. firebase sever convert this key to 'content-available:1'
Below message is a converted ''payload" as "apns" style ( You can verify in xcode debugging)
{
"aps" : {
"alert": {
"title": ...
"body": ...
},
"content-available": 1
},
"gcm.message.link": ...
}
# remark , Other fields are not included in 'alert' or 'aps' fields except 'title' and 'body'.
you must work more to send to apns extra datas.
So, you make payload as below to send extra datas.
{
"aps" : {
"alert": {
"title": ...
"body": ...
},
"content-available": 1
},
"gcm.message.link": ...
}
# remark , Other fields are not included in 'alert' or 'aps' fields except 'title' and 'body'.
you must work more to send to apns extra datas.
So, you make payload as below to send extra datas.
{
"to" : "",
"priority": "normal",
"content_available": true,
"notification" : {
"body" : "this is message",
"title" : "notification Title"
},
"data": {
"link": ....
}
"data": {
"link": ....
}
}
you must implement code about notification processing code.
( That is not simple also.)
If you find something wrong or others, please comment ~
( That is not simple also.)
If you find something wrong or others, please comment ~