gpt4 book ai didi

android - 收到通知后更改通知内容

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:29:11 24 4
gpt4 key购买 nike

有没有办法在设备上显示之前更改通知内容?例如:我有一个名为 John 的用户订阅了一个名为 food 的主题,我向该主题发送了一个标题为“早安用户名”的推送通知,但设备会显示“早安 John”

我想知道这在 Android 或 iOS 上是否可行以及如何实现

最佳答案

对于Android,是的,可以通过覆盖 FirebaseMessagingService

onMessageReceived
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// Check your notification is not null and subcribed to `food` topic.
if(remoteMessage.getFrom() == "food" &&
remoteMessage.getNotification() != null){
String title = remoteMessage.getNotification().getTitle(); // Title from the notification. E.g `Good morning`

// Get the `username` of the user stored in the device. Use SharedPreference.

String message = title + " " + username; // "Good morning username"
// Call your notification here.
}
}

关于android - 收到通知后更改通知内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51269046/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com