AWS : Play Custom Sound When Push Messages are received - ios

I have implemented Amazon Web Service(AWS) for notification messages in my app, I am able to send message from Amazon SNS Server successfully.
Now i want to implement default/custom sound, when any messages are received from AWS.
In Amazon SNS Server there are two options fro sending pus messages, those are Raw and JSON. I am using Raw Message Format.
{
"aps":{
"badge":0,
"alert":"APNS test",
"sound":"default"
},
}
by above format i m getting same format as push notification in my app.
If i use JSON Message Format
I m getting in Amazon SNS Page that -
Invalid parameter: Message Structure - JSON message body failed to
parse (Service: AmazonSNS; Status Code: 400; Error Code:
InvalidParameter; Request ID: b34a
Any One could tell tell how to send sound default/custom by using AWS Notification.

Try as bellow
Please make sure to change the JSON according to your need
{
"aps" : {
"category" : "NEW_MESSAGE_CATEGORY"
"alert" : {
"body" : "Acme message received from Johnny Appleseed",
"action-loc-key" : "VIEW"
},
"badge" : 3,
"sound" : "chime.aiff"
},
"acme-account" : "jane.appleseed#apple.com",
"acme-message" : "message123456"
}

Related

Firebase cloud messaging for iOS: don't receive notifications from POST request (only from composer tool)

I setup Firebase cloud messaging for iOS using their quick start tutorial and API docs: https://firebase.google.com/docs/cloud-messaging/ios/first-message
I sent message to my iPhone from Firebase composer tool and it was successful. But the next step I need is to receive a notification sent with regular POST request. I found that it's possible to do with legacy protocols: https://firebase.google.com/docs/cloud-messaging/auth-server#authorize_legacy_protocol_send_requests
I tried to send the following:
{ "data": {
"message": "This is a Firebase Cloud Messaging Topic Message!"
},
"to" : "myIphoneTokenHere"
}
via postman with authorization key for my Firebase project and received success in response:
{
"multicast_id": 5644065455367933439,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1513338642327024%5529b926f9fd7ecd"
}
]
}
But I there was no notification on my iPhone unlike with the composer tool.
Wondering what can I try to solve this problem, how can I debug what goes wrong?
Solved the issue by changing request body to:
{
"content_available": true,
"notification" : {
"body" : "This is a Firebase Cloud Messaging Topic Message!",
"title" : "FCM Message"}, "to" : "myIphoneTokenHere" }

Firebase not displaying rich push notification

I am using firebase notification in my application. I want to send rich notification but firebase console don't have UI for same. So I am trying to send the payload using postman.
I have created Notification Service Extension for handling content but it never gets called.
Deployment target in xCode is iOS 10.0 and iPad has iOS 11
Json payload(Not Working):
{
"to":"/topics/dev_news",
"mutable_content": true,
"data":
{
"attachment-url":"my image url",
"media_type":"image"
}
}
FYI:
I am able to receive push if I add "notification" key-value in payload.
Json payload(Working but without media):
{
"to":"/topics/dev_news",
"mutable_content": true,
"data":
{
"attachment-url":"my image url",
"media_type":"image"
},
"notification" : {
"title" : "demo push",
"body" : "this is push body"
}
}
Any idea about this??
Answering to my own question, I was searching for attachment-url in data dictionary (which I was passing in the payload) in service extension class. But attachment-url comes directly in the content.userInfo (It is not wrapped inside the data dictionary) in extension class.
Wondering how I can make such a silly mistake..!! :D

Push notifications are not working in background via FCM in iOS

Push notifications are working in foreground but not in the background.
Actually push receives but in the notification area it doesn't show.
Please let me know what could be the issue.
When I debug I found that format is not like APNS push notification.
This is apns format.
"aps" : {
"alert" : {
"title" : "Game Request",
"body" : "Bob wants to play poker",
"action-loc-key" : "PLAY"
},
"badge" : 5
},
And this is what I am getting from FCM
[from: 374675251923, collapse_key: do_not_collapse, payload: {"push_identifier":"share_credits","message":"gopaldevra share 1 credit with you "}]
PUSh PAYLOAD Background [from: 374675251923, collapse_key: do_not_collapse, payload: {"push_identifier":"share_credits","message":"gopaldevra share 1 credit with you "}]
Thanks

Can't send push notifications using the server API

Im using the new Firebase platform. Am trying to get a push notification sent by my app server and delivered to my iPhone.
I have the setup working where I manually send the message with the Firebase notifications area on the website, but when I try and send the message with a POST to https://fcm.googleapis.com/fcm/send I get no message being delivered to the device.
I'm sending the following (with auth headers)
{ "notification": {
"title": "Portugal vs. Denmark",
"text": "5 to 1"
},
"to" : "<registration token>"
}
I'm getting a 200 response from the POST with the following body:
{
"multicast_id": 5511974093763495964,
"success": 1,
"failure": 0,
"canonical_ids": 0,
"results": [
{
"message_id": "0:1463685441784359%3ad254b53ad254b5"
}
]
}
If I try and send to this device directly through the Firebase website it works, but the above form post doesn't. No idea where to go from here!
On iOS the priority field seems mandatory.
{
"to": "cHPpZ_s14EA:APA91bG56znW...",
"priority": "high",
"notification" : {
"body" : "hello!",
"title": "afruz",
"sound": "default"
}
}
If the API returns you a message_id it means that your message has been correctly accepted and it will eventually be delivered to the device.
On Android, messages are delivered as soon as possible (provided that the device is connected of course).
On Apple devices, IF the application is closed or in background, the notification is sent through Apple infrastructure and can be delayed accordingly with Apple documentation.
To reduce the delay of the prioritymessages sent to Apple device you can use the priority parameter.
More details: https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message
I found the message field to be required, as well as the priority field to deliver a message with a POST.
message is not required (and labeled as optional) in the Firebase Console.
I resolved adding the notification tag in request body without priority.
Here is a recap:

Is it possible to hide some part of message in iOS Notification?

I am sending "Push Notification" from Amazon SNS to iOS devices. While sending a notification, i want to hide the url and to show remaining string in notification to the user.
For Instance :
Notification is like this "Hi customers
https://www.google.co.in/?gfe_rd=cr&ei=zCyeVbuiMZK_-APxlYHoBA welcome"
Show the notification to the user as "Hi customers welcome"
And i want to store the entire notification message in database.
If user clicks on notification then i have to open that link in embedded browser. But that url will not be visible to the user
Is it possible to hide some part of message in notification ? Advance thanks for any help.
From Apple Push Notification Service:
Providers can specify custom payload values outside the Apple-reserved aps namespace. Custom values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean. You should not include customer information (or any sensitive data) as custom payload data. [...]
An example is provided in the documentation:
{
"aps" : { "alert" : "Message received from Bob" },
"acme2" : [ "bang", "whiz" ]
}
In your case I suggest a payload like this:
{
"aps" : { "alert" : "Welcome Customers!" },
"welcome-url" : "https://www.google.co.in/?gfe_rd=cr&ei=zCyeVbuiMZK_-APxlYHoBA"
}

Resources