I'm using flutter firebase messaging to receive push notifications, also I'm using flutter callkit incoming to delegate the notifications to Calls.
When the app is in foreground or background mode, things work fine. But when app is killed, push notifications are received but calls are not received.
It is working fine in Android but it doesnt work in iOS.
For the foreground, and background state, we are using firebase notification and for the killed state we are using APNs.
I'm looking for some help on iOS side.
Below is my notification
{
"message": {
"android": {
"notification": {
"click_action": "Video"
},
"priority": "high"
},
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"content-available": 1,
"mutable-content": 1
}
}
},
"data": {
"callerAccessToken": "006030916dbd1494d74add49838cacb570fIAA9j48nGcIUT3PXdYvxqXmg0Civ0pdD+Ra852bM3qJkPPLSuz4AafalIgCyMj7BPvKIYwQAAQDevIdjAgDevIdjAwDevIdjBADevIdj",
"calleeSflUserId": "24",
"videoSessionId": "211",
"title": "Incoming video call",
"message": "There is a new video call from Ashish Physician.",
"type": "NEW_VIDEO_CALL_REQUEST",
"roomName": "local_11_49_24",
"callerName": "Ashish Physician",
"calleeAccessToken": "006030916dbd1494d74add49838cacb570fIADY7iNdg5hFW1P58+6OAiN2LjpQz7VVGX9JN32uF79C/fLSuz47sh2NIgCDs/0oPvKIYwQAAQDevIdjAgDevIdjAwDevIdjBADevIdj",
"appointmentId": "11",
"callerSflUserId": "49",
"callerImageUrl": "https://tercardia-develop.s3.us-east-2.amazonaws.com/49/49_profileImage.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20221130T182814Z&X-Amz-SignedHeaders=host&X-Amz-Expires=86400&X-Amz-Credential=AKIAV6UT3MGE2DMFHIFS%2F20221130%2Fus-east-2%2Fs3%2Faws4_request&X-Amz-Signature=b0eea1f62f02041c62e60f1ed93c3d7bade1becd465feaf35519103e8b72c75f",
"callStatus": "INITIATED"
},
"notification": {
"body": "There is a new video call from Ashish Physician.",
"title": "Incoming video call"
},
"token": "eB4PSWrDAkg1oyIk-q-dKc:APA91bH7XN2YlRIdUJSlcVAv6pKj8v_-Rd-cXqy0z_8ap__6v2XH05iTWfWNt_ZYtcX_iHu--YyiAW8SW1bET8lXDnpBSVjz2uv69RO54fTpo-5gdv66c_rZSKuRW8alfCTy6mPpts1S"
}
}
I'm stuck on this since so long. Any help would be appreciated
Related
I've implemented Silent push notification, but it has a sound like the normal ones. Help me to correctly implement this.
Here's the payload that we're sending from Backend to FCM:
{
"notification": {
"messageId": "24d0f68a24d"
},
"content_available": true,
"data": {
"requestId": "231DDD",
"messageId": "f68a24d",
"event": "REMOVE_NOTIFICATION",
"message": ""
},
"apns": {
"headers": {
"apns-push-type": "background",
"apns-priority": 5
}
},
"to": "FCM_Token",
"priority": "high"
}
To make this silent, you have to remove following part.
"notification": {
"messageId": "24d0f68a24d"
},
I have an in house application where I have the criticalAlert option setup within my application. I have confirmed that when I send the following with the pushy application, I am able to get the Critical Alert to work on the iOS application.
The issue is our internal server currently only sends the notifications to the Firebase Cloud Messaging, and I'm not able to configure the raw push payload to play the critical alert on the device.
Here is the example that Apple gave on how the push should look to APNS:
Here is what I send using the pushy app that works on the application:
{
"aps" : {
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
}
Here is the current payload that we send to FCM and it works with the custom sound, but we really want the critical alert to be working since the push is for an on-call engagement:
{
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"isCritical": "true",
"notification": {
"title": "Title in notification",
"body": "Body in notification",
"sound": "alert.wav",
"badge": "1",
"subtitle": "subtitle in notification"
},
"data": {
"volume": 7,
"time_to_live": 900,
"id": 3618,
"type": "engagement",
"overrideMessage": "Testing oncall for iOS",
"case": "Test Case",
"repeatNumber": 3,
"customer": "Google"
}
}
I have tried a large number of combinations on what to send to FCM but with no luck:
{
"to": "firebaseToken",
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps" : {
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
and
{
"aps" : {
"to": "firebaseToken",
"content_available": true,
"priority": "high",
"alert" : "Your message Here",
"badge" : 1,
"sound": {
"critical": 1,
"name": "alert.wav",
"volume": 0.5
},
and
{
"to": "firebaseToken",
"aps" : {
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
}
},
"notification": {
"badge": "1",
and
{
"to": "firebaseToken",
"isCritical": "true",
"content_available": true,
"notification": {
"badge": "1",
"sound" : {
"critical": 1,
"name": "alert.wav",
"volume": 1.0
},
None of them have allowed the sound dictionary to be passed on to FCM.
I have also the the answer here but it doesn't solve my problem. as I require iOS to know that this push notification is critical and have the OS handle it and not my application.
Before I give the answer to your specific question, I'd like to recommend that you consider using the Admin SDK instead of the REST API if possible. The SDK is available in Node.js, Java, python, go, and C#. If your server code is written in any of those languages, this is a much simpler way to handle sending messages with FCM. The SDK handles retries and other scenarios you would otherwise have to implement into your code.
As for your question, it's noted in the guides that platform-specific fields only work with the FCM v1 endpoint. To use FCM, your endpoint will look like this:
https://fcm.googleapis.com/v1/projects/[your-project-id]/messages:send
You can see an example of this in the guides. Select REST from the snippet tab to see the example.
Note that the way you authorize sends is different with V1. You can find out more in the guide. If you have trouble with the auth part, I also wrote a blog post about it since it comes up pretty regularly.
I am construing below payload. If i send required data object inside aps object then i am able to recieve the data even when application is quit and user taps on tray,
{
"aps": {
"content-available":1,
"alert": {
"title": "Game Request",
"body": "Bob wants to play poker"
},
"sound": "default",
"data": {
"alertType": "ALERT",
"eventTime": "121346666545454",
"deviceId": "657585685858",
"user":"Arun"
}
},
}
As per the standard format we have to place data outside the aps object which i saw in APNS documentation like.
{
"aps": {
"content-available":1,
"alert": {
"title": "Game Request",
"body": "Bob wants to play poker"
},
"sound": "default"
},
"data": {
"alertType": "ALERT",
"eventTime": "121346666545454",
"deviceId": "657585685858",
"user":"Arun"
}
}
Can anyone please suggest me which is IOS APNS standard format. since i am new to IOS.
As per below URL https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1.
we have to send the app-specific data outside the aps. if we send we are not getting in app when user comes from notification tray click.
Thanks in advance
With Firebase I send this JSON:
{
"data": {
},
"priority": "high",
"to": "xxxxx",
"content-available": "true",
"notification": {
"body": "HI!",
"title": "FCM Message",
"badge": 1,
"sound": "Default"
}
}
But didReceiveRemoteNotification:fetchCompletionHandler is not called when app is in background.
I enable background Modes - Remote notifications from capabilities.
Any suggestions?
Your key/value for content-available is incorrect. The key is content_available (underscore, not dash) and the value is a boolean, not string:
{
"data": {
},
"priority": "high",
"to": "xxxxx",
"content_available": true, // <= CHANGED
"notification": {
"body": "HI!",
"title": "FCM Message",
"badge": 1,
"sound": "Default"
}
}
See Table 1 of the HTTP Server Protocol document:
On iOS, use this field to represent content-available in the APNs
payload. When a notification or message is sent and this is set to
true, an inactive client app is awoken. On Android, data messages wake
the app by default. On Chrome, currently not supported.
Make sure you turn on the background modes for remote notifications, If not then click on workspace and go in capabilities and turn on background modes
As shown in image last option for remote notification check this option
I am trying to send a notification through GCM to my app and it works perfectly as long as the app is open. If the app is in background or killed I don't receive anything until I open the app.
This problem happens only on iOS, on Android it's working as expected.
This is the JSON that is sent to GCM:
{
"to": "xxxxxxxxxxxxxx",
"priority": "high",
"content_available": true,
"notification": {
"sound": "default",
"body": "asldsfsadfsadfs",
"title": "asdfasdfasdfasdf"
},
"data": {
"message": "some message"
}
}
Thanks!