0
我已經firebase消息服務代碼中檢查通知標題,如果它包含某些文本&是在webview中的某個頁面上,它顯示一個吐司&刷新頁面。刪除過濾器收到通知
現在的事情是我想刪除下面的線,我稱之爲文本過濾器:
if (title.contains("Added")) {
誰能告訴怎麼下面的代碼修改?
public class FcmMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
String title = remoteMessage.getNotification().getTitle();
final String message = remoteMessage.getNotification().getBody();
if (title.contains("Added")) {
Handler handler = new Handler(Looper.getMainLooper());
handler.post(
new Runnable() {
@Override
public void run() {
Log.d("webUrl",""+MainActivity.mWebview.getUrl());
if(MainActivity.mWebview.getUrl().contains("http://example.com")) {
Toast.makeText(FcmMessagingService.this, message, Toast.LENGTH_SHORT).show();
MainActivity.reLoad();
}
}
}
);
}else{
Intent intent = new Intent(this, MainActivity.class);
intent.putExtra("value", "kh");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT);
Uri sounduri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle(title);
notificationBuilder.setContentText(message);
notificationBuilder.setSmallIcon(R.mipmap.ic_icon);
notificationBuilder.setSound(sounduri);
notificationBuilder.setAutoCancel(true);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(0);
notificationManager.notify(0, notificationBuilder.build());
}
}
}
你是什麼意思的 「僅保留網頁過濾器。」?你的頁面過濾器在哪裏? – FAT
@FerdousAhamed更新了問題。我想刪除「if(title.contains(」Added「)) 」 – Observer
實際上你的要求是什麼?你想要什麼標題和消息的價值? – FAT