I would like to know how to send iOS push notifications throught AWS Pinpoint with the GCMMessage channel.
Can anyone provide a working json payload that gets sent through FCM to an iOS device ?
It seems that the same payload for Android is used with iOS, but for sending data messages I had to add the property "content_available": "1"
payload = {
"notification": {
"title": "title",
"body": "body",
"sound": "default",
"badge":"1"
},
"content_available": "1",
"data": {
"key_1": "some value",
"key_2": "some value"
}
}
Related
I've been developing a Teams Custom App with the TeamsFx SDK. I want to send a activity feed notification with a query.
I tried the HTTP request as below, however the app wasn't able to recieve a query(hoge=123).
POST https://graph.microsoft.com/v1.0/users/{user id}/teamwork/sendActivityNotification
Content-Type: application/json
{
"topic": {
"source": "entityUrl",
"value": "https://graph.microsoft.com/v1.0/users/{user id}/teamwork/installedApps/{installation id}?hoge=123"
},
"activityType": "taskCreated",
"previewText": {
"content": "New Task Created"
},
"templateParameters": [
{
"name": "taskId",
"value": "Task 12322"
}
]
}
Is there any wat to send a activity feed notification with a query?
Testing with Postman, I'm trying to send a message per the glitch example project from docs
I'm trying to write an API endpoint I can hit with a webhook when people send a message to my Org's whatsapp number. The API would send an automated response.
When I send the POST, with the following body to https://graph.facebook.com/v14.0/redacted/messages it comes back with the following response:
{
"error": {
"message": "(#131030) Recipient phone number not in allowed list",
"type": "OAuthException",
"code": 131030,
"error_data": {
"messaging_product": "whatsapp",
"details": "Recipient phone number not in allowed list: Add recipient phone number to recipient list and try again."
},
"error_subcode": 2655007,
"fbtrace_id": "A5YKQbpB0PEaaA-gIROEv-n"
}
}
The error code isn't list one the error codes page, nor can I find anything about adding a recipient phone number anyway (it doesn't make sense to require a pre-defined list of recipient phone numbers to which I can send messages).
Here's the message body:
{
"messaging_product": "whatsapp",
"to": "redacted",
"text": {
"body": "Ack: Hello world"
}
}
How do I get the message sent? I'm not able to proceed with development of my app until I can send a message.
Just Remove + from your mobile number and add you country code before your number.
Then its working fine.
Request Body:
{
"messaging_product": "whatsapp",
"to": "91xxxxxxxxxx",
"type": "template",
"template": {
"name": "hello_world",
"language": {
"code": "en_US"
}
}
}
Response Body:
{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "91xxxxxxxxxx",
"wa_id": "91xxxxxxxxxx"
}
],
"messages": [
{
"id": "wamid.HBgMOTE3NTM4OTE4MzIyFQIAERgSOERCM0ZDOTJFMDk1RjBFNURBAA=="
}
]
}
for Your Reference
I got the same error code and message here.
I was debugging it and see that the from number is a little different than the number I had registered when I will echo the message back.
You can put the number of phone hard coded that you have registered before to see it working.
Currently, I have different ways to handle notifications depending on if the system is Android or IOS, for Android, I send a data-only notification and create a local notification from it.
For IOS, since data-only notifications have no guarantee that they will be retrieved if the app is closed, I send a normal notification.
What I'm trying to do is having both notifications using the same FCM API call, here is my current json:
{
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"d": "my_data",
},
"apns": {
"headers": {
"apns-priority": "10"
},
"payload": {
"aps": {
"alert": {
"title": "my title",
"body": "my body"
}
}
}
},
"priority": "high",
"registration_ids": [...],
"time_to_live":86400
}
So, what I expected from this request is that for android it would create a data only notification using:
{
"data": {
"click_action": "FLUTTER_NOTIFICATION_CLICK",
"d": "my_data",
}
}
And for IOS, it would create a normal notification using:
{
"notification": {
"title": "my title",
"body": "my body",
}
}
This works for Android, but I don't receive this notification as a normal notification on IOS.. Shouldn't the apns payload be used for IOS in this case?
I am using react-native-firebase in react-native project for Firebase cloud messaging. It is working fine when app is running or in background/minimised. But notification not received when app is killed or not opened after mobile restart.
I am sending the following body to
https://fcm.googleapis.com/fcm/send
{
"to": "/topics/chatProperty_P00025_14",
"notification" : {
"body" : "great match!",
"content_available" : true,
"priority" : "high",
"title" : "Portugal vs. Denmark",
"sound":"default",
"vibrate":true
},
"data" : {
"body" : "14_P00025",
"content_available" : true,
"priority" : "high",
"title" : "Portugal vs. Denmark",
"type" : "propertyAdd",
"sound":"default",
"vibrate":true,
"propertyId":"1"
}
}
"to":"your token",
"apn": {
"content_available": "1"
},
"content_available": true,
"sound": "default",
"icon": "ic_launcher",
"priority": "high",
"notification": {
"title": "Reminder Appointment",
"body": "You have appointment today with Doctor ${detailData.doctor_name} on ${appTime}"
},
"data": {
"id_appointment": "${detailData.book_id}",
"id_doctor": "${detailData.doctor_email}",
"id_patient": "${detailData.patient_email}",
"speciality": "${detailData.speciality}",
"speciality_id": "${detailData.speciality_id}"
}
if you're using react native firebase , you can try using this format on postman or insomnia by hit this endpoint (https://fcm.googleapis.com/fcm/send), check the structure and don't forget include the firebase key (AlzaXXXXXX)
My system running at least two years. Most push notification requests got 200. But, recently, I found I got 500 frequently.
Nealy 10% push notifications got 500.
Please HELP!!!
I have resend the problem messages, every thing is fine.
Example:
Request is:
{
"request": {
"application": "3DXXX-59XXX",
"username": "MyXXXXX",
"password": "********",
"notifications": [
{
"send_date": "now",
"content": {
"en": "Subscriber ID. 9000 Close User 01"
},
"link": "",
"data": {
"userID": "12345"
},
"wp_type": "",
"wp_background": "",
"wp_count": "",
"ios_badges": 51,
"ios_sound": "short-tone.caf",
"devices": [
"APA91bHZHEhIMjVYwxyMk-4-YObazHfcxlQq7CmYto930nuIqHlQGCdzUQsnDcnHTB78wUcTlm-qhV3ipMqe9HO3kTqD9j_zgzSUUAdoGK0fbeRRGMNn69Z63BlQ9RqIdioZ4J2NFA0DLOUkroImk-it8p_3Glr5bRlnrl1_wT3ycXfsgvQZq4g"
],
"page_id": "0",
"android_sound": "five_sectoneone"
}
]
}
}
Response is:
{"status_code":500,"status_message":"Invalid devices list"}
==============================================================
========================= Update =============================
After I upgrade Pushwoosh API from V1.2 to V1.3, the problem is gone.
However, new problem comes.
My sample is:
request :
{
"request": {
"application": "3DXXX-59XXX",
"auth": "*********WqLiS5ZM2****************************************9eib******",
"notifications": [
{
"send_date": "now",
"content": {
"en": "Jones Residence Tue,17Jul 12:12 Test from Robbie......."
},
"link": "",
"data": {
"userID": "12345"
},
"wp_type": "",
"wp_background": "",
"wp_count": "",
"ios_badges": 39,
"ios_sound": "short-tone.caf",
"devices": [
"298eeXXXXa26849cc77da16adXXXXc1c801df12e79bad1e724829aXXXXcbe07d" //I hashed real ID here
],
"page_id": "0",
"android_sound": "five_sectoneone"
}
]
}
}
Response is:
{
"status_code": 200,
"status_message": "OK",
"response": {
"Messages": [
"D954-3C45B1AA-AA6293E5"
],
"UnknownDevices": {
"D954-3C45B1AA-AA6293E5": [
"298eeXXXXa26849cc77da16adXXXXc1c801df12e79bad1e724829aXXXXcbe07d" //I hashed real ID here
]
}
}
}
I see you already wrote the question in Pushwoosh community. I'll post the answer here as well.
The "UnknownDevice" warning indicates that the push token that you have put in the "devices" section of the createMessage request isn't in our databases.
There are several reasons for that:
1) The application was deleted from the device.
2) The push token was renewed. APNs/GCM/etc. tends to change push tokens from time to time, and we remove outdated push tokens from our servers. (This happens VERY rarely)
3) There is a misprint in your request. (I'm sure this is not the case)
Please note that in order to keep your userbase up-to-date you can use getUnregisteredDevices method, which would return a last thousand of removed push tokens. You will need to call this on a regular basis.
P.S. https://community.pushwoosh.com/questions/998/pushwoosh-create-message-get-200-but-says-unknowndevices
P.P.S. Do not use 1.2 API, it is very old and will be deprecated soon.
I think, you use wrong device token. Don't use device UUID. You can send device token to your database after put it deviceArray in the Java code.
Edit PushwooshiOS.js file;
pushNotification.registerDevice(
function(status)
{
var deviceToken = status['deviceToken'];
console.warn('registerDevice: ' + deviceToken);
$.ajax({
url : "http://ip:port/deviceid/"+deviceToken,
dataType : "json",
success : function(a, b, c) {
console.log("send tokens to server after call t in your json array");
},
error : function(a, b, c) {
console.log("err a ", a);
console.log("err b ", b);
console.log("err c ", c);
console.log("err c ", c);
}
});
onPushwooshiOSInitialized(deviceToken);
},
function(status)
{
console.warn('failed to register : ' + JSON.stringify(status));
//alert(JSON.stringify(['failed to register ', status]));
}
);
Java code
String method = "createMessage";
URL url = new URL(PUSHWOOSH_SERVICE_BASE_URL + method);
JSONArray deviceArray = new JSONArray();
// put your device tokens
deviceArray.put(deviceToken);
JSONArray notificationsArray = new JSONArray()
.put(new JSONObject().put("send_date", "now")
.put("content", "A test push")
.put("devices",deviceArray));
JSONObject requestObject = new JSONObject()
.put("application", APPLICATION_CODE)
.put("auth", AUTH_TOKEN)
.put("notifications", notificationsArray);
JSONObject mainRequest = new JSONObject().put("request", requestObject);
JSONObject response = SendServerRequest.sendJSONRequest(url, mainRequest.toString());