我在firebase例程中有以下代码.收到通知时,如何将通知消息或数据显示为警报?我的服务器上的PHP代码成功地通过id将消息推送到Android设备,并且在收到消息时听到声音,但我想显示警报或转移到片段(我更喜欢警报).
public class MyFirebaseMessagingService extends FirebaseMessagingService
{
private static final String TAG = "MyFirebaseMessService";
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
{
commonfunc.myprint("#####_____MyFirebaseMessService_from 1 : " + remoteMessage.getFrom());
if(remoteMessage.getData().size() > 0)
{
commonfunc.myprint("MyFirebaseMessService_getdata 2 : " + remoteMessage.getData());
Map<String, String> data = remoteMessage.getData();
String value1 = data.get("dtitle");
String value2 = data.get("dbody");
commonfunc.myprint("MyFirebaseMessService_getdata 2 : " + value1 + " " + value2);
sendNotification(remoteMessage.getData().toString());
}
if (remoteMessage.getNotification() != null)
{
commonfunc.myprint("MyFirebaseMessService_getNot 3 body: " + remoteMessage.getNotification().getBody());
commonfunc.myprint("MyFirebaseMessService_getNot 3 title: " + remoteMessage.getNotification().getTitle());
sendNotification(remoteMessage.getNotification().getBody()); …Run Code Online (Sandbox Code Playgroud)