Bulk Send Message not working in MobileFirst Platform - push-notification

I am trying to use the Bulk Send Message API in IBM MobileFirst Platform Foundation 7.0. Unfortunately, the example JSON from the docs does not work and gets an error about the object structure being sent.
This is the JSON Object I'm sending:
{
"//ArrayOfMessageBody": [
{
"messages": {
"alert": "Test message"
},
"settings": {
"apns": {
"actionKey": "Ok"
}
},
"target": {
"consumerIds": [
"MyConsumerId1"
],
"deviceIds": [
"MyDeviceId1"
],
"platforms": [
"A"
]
}
}
]
}
And Here is the server's response error:
com.ibm.json.java.JSONObject cannot be cast to com.ibm.json.java.JSONArray
I am having success sending to devices via the single Send Message API, so I know messaging works. However, Bulk Send Message is failing.

It turns out that the documentation was what hung me up. If you send an array of messages to the bulk send message endpoint it will work.
[{message1}, {message2}, ...]
I'm still not sure what the whole //ArrayOfMessageBody thing is.

Related

When using fcm http v1, data messages do not arrive normally after about 20 times

I wrote google translator. Please understand this part.
hi.
There was a problem when upgrading the API version from FCM HTTP to FCM HTTP v1.
FCM HTTP v1 API request was made through POSTMAN.
Below is the sending message body.
{
"message": {
"topic": "this_is_test_topic",
"data": {
"body": "1234567890"
},
"android": {
"priority": "high"
}
}
}
When I made the above request, IOS client received it normally even though it was sent once or twice per second.
However, the ANDROID client did not receive a message from FCM for a certain period of time after receiving the first 20 times.
The message could be transmitted once more after a certain time.
This was the same as the limitations of compact messages in the FCM documentation.
Link: https://firebase.google.com/docs/cloud-messaging/concept-options?hl=en#collapsible_throttling
However, I didn't put any data related to the miniature in the message I sent.
If you make a request to the existing FCM HTTP with the same topic, data is received normally. Below is the corresponding code.
{
"to": "this_is_test_topic",
"data": {
"body": "1234567890"
}
}
If the FCM HTTP v1 API is requested using the same topic and token instead of topic, data is received normally. Below is the corresponding code.
{
"message": {
"token": "asdkjasldjalksdjlk*******************",
"data": {
"body": "1234567890"
},
"android": {
"priority": "high"
}
}
}
all request response status code is 200

First request to a webhook

To create a webhook, it has to pass the following validation:
Receive a GET request onto the webhook URL and read a specific "challenge" field from the query.
Send this field back to where the request comes.
Can this be implemented in an Integromat app?
Yes, you can use the verification directive for this purpose.
The code would look something like this:
{
"verification": {
"condition": "{{if(query.challenge, true, false)}}",
"respond": {
"status": 200,
"type": "json",
"body": {
"challenge": "{{query.challenge}}"
}
}
},
"response": {
"output": "{{body}}"
}
}
It's up to you to specify the verification condition so that the platform will be able to tell if the incoming message is a verification request or a regular webhook payload.

Firebase Cloud Messaging sound error

I'm trying to send a notification using firebase api and the notification is sent successfully if I only have "title" and "body" in the notification JSON object. However, if I add "sound":"default" to the notification object, as described in the documentation, I get the following error:
"Invalid JSON payload received. Unknown name \"sound\" at 'message.notification': Cannot find field."
My JSON object is as follows:
{"message":{"token": token, "notification":{"title":"Test", "body":"Test message from server", "sound":"default"}}}
The appearance of message in your JSON indicates you are using the HTTP v1 API. The documentation you linked is for the legacy API.
The HTTP v1 API JSON to send a notification with sound for Android and iOS devices should be:
{
"message": {
"token": "your-token-value",
"notification": {
"title": "Test",
"body": "Test message from server"
},
"android": {
"notification": {
"sound": "default"
}
},
"apns": {
"payload": {
"aps": {
"sound": "default"
}
}
}
}
}

Get Quotas Openstack API

I'm referring to use Openstack API to get quota usage from Openstack Cloud. I did exactly as document at https://developer.openstack.org/api-ref/compute/.
But It didn't work, with api:
<host>/v2/{tenant_id}/os-quota-sets/{tenant_id}/detail
or
<host>/v2/{tenant_id}/os-quota-sets/detail
It worked with api:
<host>/v2/{tenant_id}/os-quota-sets/{tenant_id}
But, I want to get details. Did I do anything wrong?
OpenStack client can be used... And you can use command line tools.... Below is the link which can help you.
https://docs.openstack.org/nova/pike/admin/quotas.html
You can install OpenStack SDK, you can go through API documentation section for networking.
Below is the link:
https://docs.openstack.org/openstacksdk/latest/user/proxies/network.html#openstack.network.v2._proxy.Proxy.update_quota
You may find methods like:
delete_quota(quota, ignore_missing=True)
get_quota(quota, details=False)
API for getting project quota can be called as,
requests.get('http://'+url+':8774/v2.1/os-quota-sets/'+projectid+'/detail',headers={'content-type': 'application/json', 'X-Auth-Token': token})
You will have to pass your project id in path and 'X-Auth-Token' parameter in headers which can be extracted as,
url = [Your Cloud Machine IP Goes here]
def gettokenForUser(username,password):
payload1 = {
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": username,
"domain": {
"name": "Default"
},
"password": password
}
}
}
}
}
response = requests.post('http://'+url+':5000/v3/auth/tokens',
headers={'content-type': 'application/json'},
data=json.dumps(payload1))
return response.headers['X-Subject-Token']

How to not use Firebase Topics Messaging and Device Group Messaging?

Wanted to ask in my special case about sending FCM. I read about the Firebase Topic messaging and Device group messaging but dont think it will work in my scenario.
I have a Firebase connected app that need help!
I want to create a place where the app user can send a chat message and there is nobody listening, or there could be a million+ people listening.
There are millions or even billions of chat rooms and there is no way to tell how many are listening on any chat, there could be miljons billions listening, there could be this many notifications to inform users that a new message is posted
When a user sends the chat a message, the notification must be sent to everyone who is listening.
how could I do this?
You can simply use Firebase database to create a chat app as you seek. There are tons of tutorials for that specific application actually.
Typically, the structure would look something like this:
{
"chats": {
"one": {
"title": "Historical Tech Pioneers",
"lastMessage": "ghopper: Relay malfunction found. Cause: moth.",
"timestamp": 1459361875666
},
"two": { ... },
"three": { ... }
},
"members": {
"one": {
"ghopper": true,
"alovelace": true,
"eclarke": true
},
"two": { ... },
"three": { ... }
},
"messages": {
"one": {
"m1": {
"name": "eclarke",
"message": "The relay seems to be malfunctioning.",
"timestamp": 1459361875337
},
"m2": { ... },
"m3": { ... }
},
"two": { ... },
"three": { ... }
}
}
(source)
So whenever a user sends a message through your app, you'd just create a new node under messages and update the appropriate entry under chats. I'd post more about the client-side process, but I'm not sure which platform you're using
EDIT
To clarify a bit further, you should listen to the chats node on your platform for any changes, once the timestamp of the last message changes from what you have stored on device, you check messages. That, or you can simply listen for childAdded in messages.
Regarding your comment, you don't really need FCM in this case unless you want to push notifications, in which case you'll need your own server for that to listen for the changes as well and dispatch the notifications appropriately.

Resources