如果应用程序不在前台,我需要向用户显示通知。这是我的公共类MyFirebaseMessagingService:
FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(applicationInForeground()) {
Map<String, String> data = remoteMessage.getData();
sendNotification(data.get("title"), data.get("detail"));
}
}
需要实现applicationInForeground()
方法