[FIX] Wrong username on push notifications (#2825)
This commit is contained in:
parent
b10c5db5b5
commit
cf59644a56
|
@ -257,7 +257,6 @@ public class CustomPushNotification extends PushNotification {
|
||||||
Notification.MessagingStyle messageStyle;
|
Notification.MessagingStyle messageStyle;
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
Ejson ejson = gson.fromJson(bundle.getString("ejson", "{}"), Ejson.class);
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||||
messageStyle = new Notification.MessagingStyle("");
|
messageStyle = new Notification.MessagingStyle("");
|
||||||
|
@ -278,25 +277,19 @@ public class CustomPushNotification extends PushNotification {
|
||||||
|
|
||||||
long timestamp = data.getLong("time");
|
long timestamp = data.getLong("time");
|
||||||
String message = data.getString("message");
|
String message = data.getString("message");
|
||||||
String username = data.getString("username");
|
|
||||||
String senderId = data.getString("senderId");
|
String senderId = data.getString("senderId");
|
||||||
String avatarUri = data.getString("avatarUri");
|
String avatarUri = data.getString("avatarUri");
|
||||||
|
Ejson ejson = gson.fromJson(data.getString("ejson", "{}"), Ejson.class);
|
||||||
String m = extractMessage(message, ejson);
|
String m = extractMessage(message, ejson);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
|
||||||
messageStyle.addMessage(m, timestamp, username);
|
messageStyle.addMessage(m, timestamp, ejson.senderName);
|
||||||
} else {
|
} else {
|
||||||
Bitmap avatar = getAvatar(avatarUri);
|
Bitmap avatar = getAvatar(avatarUri);
|
||||||
|
|
||||||
String name = username;
|
|
||||||
if (ejson.senderName != null) {
|
|
||||||
name = ejson.senderName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Person.Builder sender = new Person.Builder()
|
Person.Builder sender = new Person.Builder()
|
||||||
.setKey(senderId)
|
.setKey(senderId)
|
||||||
.setName(name);
|
.setName(ejson.senderName);
|
||||||
|
|
||||||
if (avatar != null) {
|
if (avatar != null) {
|
||||||
sender.setIcon(Icon.createWithBitmap(avatar));
|
sender.setIcon(Icon.createWithBitmap(avatar));
|
||||||
|
|
Loading…
Reference in New Issue