在推送中找不到符号通知错误" notificationBuilder.setContentText(currentText).setNumber(++ numMessages);"

时间:2017-05-08 16:13:46

标签: java android cordova push-notification

下面是我的代码,我正在使用cordova推送通知,我正在尝试合并多个推送通知但它给我错误,对于单一通知其工作,我无法找到出错的地方,请提示

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 个答案:

答案 0 :(得分:0)

看起来setContextText方法中使用的currentText未在代码中的任何位置实例化。