正在查看: AdaModal v1.4.0 应用的 FireBaseMsgService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: AdaModal v1.4.0 应用的 FireBaseMsgService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.common.fine.service;
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.appsflyer.AppsFlyerLib;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.Utils;
import com.common.fine.R;
import com.common.fine.activity.SplashActivity;
import com.common.fine.constant.ParamConstant;
import com.common.fine.constant.SPConstant;
import com.common.fine.instance.LoginInstance;
import com.common.fine.instance.ParamsInstance;
import com.common.fine.utils.BitmapUtil;
import com.common.fine.utils.ExpUtils;
import com.common.fine.utils.preference.ESPUtils;
import com.facebook.appevents.AppEventsConstants;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
public class FireBaseMsgService extends FirebaseMessagingService {
private static final String TAG = "FireBaseTokenService";
public void onMessageReceived(RemoteMessage remoteMessage) {
LogUtils.d("From: " + remoteMessage.getFrom());
LogUtils.d("Message Id: " + remoteMessage.getMessageId());
try {
handleRemoteMessage(remoteMessage);
} catch (Exception e) {
ExpUtils.show(e);
}
}
public void onNewToken(String str) {
ParamsInstance.getInstance().updateParam(ParamConstant.INSTANCE_TOKEN, str);
AppsFlyerLib.getInstance().updateServerUninstallToken(getApplicationContext(), str);
ESPUtils.getInstance(LoginInstance.PREF_USER_INFO).put(SPConstant.NOTIFICATION_TOKEN, str);
}
private void handleRemoteMessage(RemoteMessage remoteMessage) {
Bitmap returnBitMap;
RemoteMessage.Notification notification = remoteMessage.getNotification();
String str = (String) remoteMessage.getData().get("pop_up_type");
if (notification != null) {
Intent intent = new Intent(Utils.getApp().getApplicationContext(), (Class<?>) SplashActivity.class);
intent.putExtra("fromNotification", true);
intent.putExtra("pop_up_type", str);
NotificationCompat.Builder autoCancel = new NotificationCompat.Builder(Utils.getApp().getApplicationContext(), notification.getChannelId() == null ? AppEventsConstants.EVENT_PARAM_VALUE_YES : notification.getChannelId()).setContentTitle(notification.getTitle()).setContentText(notification.getBody()).setSmallIcon(R.mipmap.ic_launcher).setContentIntent(PendingIntent.getActivity(Utils.getApp().getApplicationContext(), 1, intent, 134217728)).setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)).setPriority(1).setAutoCancel(true);
if (notification.getImageUrl() != null && (returnBitMap = BitmapUtil.returnBitMap(notification.getImageUrl().toString())) != null) {
autoCancel.setLargeIcon(returnBitMap);
}
NotificationManagerCompat.from(Utils.getApp().getApplicationContext()).notify(100, autoCancel.build());
}
}
}