cannot find symbol in push Notification error “not

2019-06-14 01:03发布

问题:

Below is my code,I am using cordova Push Notification,I am trying to merge multiple push notification but its give me error, for single notification its working, i am unable to find what went wrong, kindly suggest

package org.apache.cordova.firebase;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.text.TextUtils;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Map;
import java.util.Random;


private void sendNotification(String id, String title, String messageBody, Map<String, String> data, boolean showNotification) 
{
    Bundle bundle = new Bundle();
    int notifyID = 1;
    for (String key : data.keySet()) {
        bundle.putString(key, data.get(key));
    }
    if (showNotification) {
        Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
        intent.putExtras(bundle);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
         NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setContentTitle(title)
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri);
         int numMessages = 0;
    //This line gives me error:error: cannot find symbol

    notificationBuilder.setContentText(currentText).setNumber(++numMessages);
        notificationManager.notify(notifyID, notificationBuilder.build());
    } else {
        bundle.putBoolean("tap", false);
        FirebasePlugin.sendNotification(bundle);
    }
}

回答1:

It looks like currentText that is used in the setContextText method isn't instantiated anywhere in your code.