Push-notifications IOS: Standard payload format - ios

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

Related

Flutter Firebase Notification not working in killed state

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

Unable to send category in aps object

I am trying to send push notification to ios device via firebase and also I need to send category object with the aps payload so that I can create notification with action buttons. I am using the below payload specified in firebase documentation, but I am unable to receive the category object in the aps payload object in the front end. Any help would be appreciable. Thanks in advance.
{
"message": {
"token": "f8vYHFfogAA:APA91bG7cZlo7Iimv1UtD0atqTlBRKYsGTU2pdWQmfELpdG61E4_TstS8MNHvHgNJW_dECi8YxD0REiDjxbkBVK4Ey9MNJ4MTxBVJpa48sirKb2a93QyfrpRwDMB9_j8UaNexP5rQ7Ci",
"notification": {
"title": "Match update",
"body": "Arsenal goal in added time, score is now 3-0"
},
"android": {
"ttl": "86400s",
"notification": {
"click_action": "OPEN_ACTIVITY_1"
}
},
"apns": {
"headers": {
"apns-priority": "100"
},
"payload": {
"aps": {
"category": "NEW_MESSAGE_CATEGORY"
}
}
},
"webpush": {
"headers": {
"TTL": "86400"
}
}
}
}

When app is in background didReceiveRemoteNotification not called with Firebase

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

FCM rich push notification payload for iOS

I am using FCM for my project. It's have rich push notification for a type. I tried to modified most of possible ways to get push from FCM. I got obly ordinary push from FCM, not with image.
I am also check with APNS same coding using push try. I got what expected design for push notification.
Here my APNS payload
{
"aps": {
"alert": "Enter your message",
"badge": 1,
"sound": "default",
"content-available": 1,
"mutable-content": 1
},
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
}
Here FCM payload
{
"to": "dWB537Nz1GA:APA91bHIjJ5....",
"data":
{
"message": "Offer!",
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
},
"notification":
{
"body": "Enter your message",
"sound": "default",
"content-available": 1,
"mutable-content": 1
}
}
Also I am need category more details about payload in FCM
Am I missing any setting in fire-base console or is that from payload.
The mutable-content and content-available in your FCM payload is incorrect. It should be formatted as mutable_content and content_available. Both are boolean and must also be outside the notification parameter. Like so:
{
"to": "dWB537Nz1GA:APA91bHIjJ5....",
"content_available": true,
"mutable_content": true,
"data":
{
"message": "Offer!",
"mediaUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/FloorGoban.JPG/1024px-FloorGoban.JPG"
},
"notification":
{
"body": "Enter your message",
"sound": "default"
}
}
For the counterpart of category in FCM, you should use click_action:
The action associated with a user click on the notification.
Corresponds to category in the APNs payload.
This worked for me. The accepted answer seems to have some unnecessary information.
{
"to" : "devicekey OR /topics/sometopic",
"mutable_content": true,
"data": {
"mymediavideo": "https://myserver.com/myvideo.mp4"
},
"notification": {
"title": "my title",
"subtitle": "my subtitle",
"body": "some body"
}
}

GCM push notifications don't send to iOS

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!

Resources