正在查看: Clash Legends v0.0.1 应用的 FirebaseNotificationService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Clash Legends v0.0.1 应用的 FirebaseNotificationService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.clash.legends.utils;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.clash.legends.ui.activities.FirstActivity;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Map;
public class FirebaseNotificationService extends FirebaseMessagingService {
private static final String TAG = "token";
public void onMessageReceived(RemoteMessage remoteMessage) {
if (!remoteMessage.getData().isEmpty()) {
Map<String, String> map = remoteMessage.getData();
remoteMessage.getData();
String title = map.get("title");
String message = map.get("message");
if (title != null) {
if (Build.VERSION.SDK_INT > 26) {
createOreoNotification(title, message);
} else {
createNotification(title, message);
}
} else if (remoteMessage.getNotification() != null) {
String titlee = remoteMessage.getNotification().getTitle();
String body = remoteMessage.getNotification().getBody();
Intent intent = new Intent((Context) this, (Class<?>) FirstActivity.class);
intent.addFlags(67108864);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 1140850688);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "Default").setSmallIcon(2131230869).setContentTitle(titlee).setContentText(body).setAutoCancel(true).setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService("notification");
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel channel = new NotificationChannel("Default", "Default channel", 3);
manager.createNotificationChannel(channel);
}
manager.notify(0, builder.build());
}
}
super.onMessageReceived(remoteMessage);
}
public void onNewToken(String s) {
updateToken(s);
super.onNewToken(s);
}
private void updateToken(String token) {
Log.i(TAG, "updateToken: " + token);
}
private void createNotification(String title, String message) {
Intent intent = new Intent((Context) this, (Class<?>) FirstActivity.class);
intent.addFlags(67108864);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 1140850688);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "Default").setSmallIcon(2131230869).setContentTitle(title).setContentText(message).setAutoCancel(true).setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService("notification");
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel channel = new NotificationChannel("Default", "Default channel", 3);
manager.createNotificationChannel(channel);
}
manager.notify(0, builder.build());
}
private void createOreoNotification(String title, String message) {
Intent intent = new Intent((Context) this, (Class<?>) FirstActivity.class);
intent.addFlags(67108864);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 1140850688);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "Default").setSmallIcon(2131230869).setContentTitle(title).setContentText(message).setAutoCancel(true).setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService("notification");
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel channel = new NotificationChannel("Default", "Default channel", 3);
manager.createNotificationChannel(channel);
}
manager.notify(0, builder.build());
}
}