我正在尝试更改插件cordova-plugin-firebase
的文件,我特别试图通过在onMessageReceived();
中添加以下代码来更改文件FirebasePluginMessagingService.java
Context context = this.cordova.getActivity().getApplicationContext();
ShortcutBadger.applyCount(context, 13);
然而,每次我运行这个代码时,我都会得到:
error: cannot find symbol variable cordova
我想我已经进口了必要的东西:
package org.apache.cordova.firebase;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.app.Notification;
import android.text.TextUtils;
import android.content.ContentResolver;
import android.graphics.Color;
import me.leolin.shortcutbadger.ShortcutBadger;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaInterface;
import org.apache.cordova.PluginResult;
import org.apache.cordova.CordovaWebView;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Map;
import java.util.Random;
你试过吗
this.getApplicationContext()
这就是至少在FirebasePluginMessagingService.java
文件中获取上下文的方式。