无法在推送通知中找到符号通知错误“"notificationBuilder.setContentText(currentText).setNumber(++ numMessages);" [英] cannot find symbol in push Notification error "notificationBuilder.setContentText(currentText).setNumber(++numMessages);"

查看:89
本文介绍了无法在推送通知中找到符号通知错误“"notificationBuilder.setContentText(currentText).setNumber(++ numMessages);"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的代码,我正在使用cordova推送通知,我正在尝试合并多个推送通知,但是它给了我错误,对于单个通知来说,我无法找到问题所在,请提出建议

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);
    }
}

推荐答案

setContextText方法中使用的currentText似乎没有在代码中的任何地方实例化.

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

这篇关于无法在推送通知中找到符号通知错误“"notificationBuilder.setContentText(currentText).setNumber(++ numMessages);"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆