Closed emartynov closed 4 years ago
Use message index from the push payload to load message by index.
Fetching message by SID directly is in our plans, but requires finishing more prioritized work first.
It looks like there is message index in payload, but it is not trivial to extract it.
Am I right that I have to use toString(), parse it as json and then I can obtain message index?
Clarification: current SDK does not have getMessageIndex() in the NotificationPayload implementation, but it is already added and will be available with the next released version.
For now it's quite easy to implement manually:
public long getMessageIndex() {
return payload.getLong("message_index", INVALID_MESSAGE_INDEX);
}
edit: where payload
is of Bundle
type.
How to get bundle? NotificationPayload
doesn't have this api
You should be receiving a Bundle as remoteMessage from the push.
Ah, I deal with api that already feed Bundle to NotificationPayload. So I have to go level deeper.
If you received it as a Map then do this:
JSONObject obj = new JSONObject(remoteMessage);
return obj.optLong("message_index", INVALID_MESSAGE_INDEX);
Again, this new NotificationPayload API is going to be released real soon now, so hopefully this change is temporary for you.
Hopefully! Thank you! As for now I will go to this workarounds and implementation details :)
Should I keep it open until you release new version or close it?
I think you can close it - it's already merged and will come out with the next release for sure.
Closing!
Hi, we've released 6.0.0 with NotificationPayload.getMessageIndex()
Hi people.
I use Twilio Android SDK.
I'm getting push message with payload where I can get only message sid. I need message attributes that are not coming in the push (probably).
I use chatClient to load specific channel by sid. After I get messages object and it doesn't have method to load message by id. I can only load last x messages, or message with specific index.
What is your suggestion?