正在查看: WeatherSense v1.8.9 应用的 MyFirebaseMessagingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: WeatherSense v1.8.9 应用的 MyFirebaseMessagingService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.emax.weather.service;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.emax.weahter.R;
import com.emax.weather.bean.AlarmEventType;
import com.emax.weather.bean.EventData;
import com.emax.weather.utils.HomeUtil;
import com.emax.weather.utils.NotificationUtil;
import com.ezon.health.utils_lib.SharedPre;
import com.ezon.health.utils_lib.SharedPreUtils;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.StringCompanionObject;
@Metadata(d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0002J\b\u0010\u0007\u001a\u00020\u0004H\u0016J\u0010\u0010\b\u001a\u00020\u00042\u0006\u0010\t\u001a\u00020\nH\u0016J\u0010\u0010\u000b\u001a\u00020\u00042\u0006\u0010\t\u001a\u00020\u0006H\u0016¨\u0006\f"}, d2 = {"Lcom/emax/weather/service/MyFirebaseMessagingService;", "Lcom/google/firebase/messaging/FirebaseMessagingService;", "()V", "dealData", "", "str", "", "onDeletedMessages", "onMessageReceived", "p0", "Lcom/google/firebase/messaging/RemoteMessage;", "onNewToken", "app_release"}, k = 1, mv = {1, 5, 1}, xi = 48)
public final class MyFirebaseMessagingService extends FirebaseMessagingService {
public void onNewToken(String p0) {
Intrinsics.checkNotNullParameter(p0, "p0");
super.onNewToken(p0);
}
public void onMessageReceived(RemoteMessage p0) {
Intrinsics.checkNotNullParameter(p0, "p0");
super.onMessageReceived(p0);
String from = p0.getFrom();
Map data = p0.getData();
Objects.requireNonNull(data, "null cannot be cast to non-null type kotlin.collections.Map<kotlin.String, kotlin.String>");
RemoteMessage.Notification notification = p0.getNotification();
String title = notification == null ? null : notification.getTitle();
RemoteMessage.Notification notification2 = p0.getNotification();
String body = notification2 != null ? notification2.getBody() : null;
Log.d("MyFirebaseMessaging", "onMessageReceived from: " + ((Object) from) + ",title :" + ((Object) title) + ", body :" + ((Object) body) + ", data :" + data);
Map data2 = p0.getData();
Intrinsics.checkNotNullExpressionValue(data2, "p0.data");
if (data2.containsKey("weather_content")) {
String str = (String) data2.get("weather_content");
Log.d("MyFirebaseMessaging", Intrinsics.stringPlus("onMessageReceived content:", str));
if (str != null) {
dealData(str);
}
try {
EventData eventData = ((AlarmEventType) new Gson().fromJson(str, AlarmEventType.class)).getEventData();
String string = getResources().getString(R.string.alarm_msg);
Intrinsics.checkNotNullExpressionValue(string, "resources.getString(R.string.alarm_msg)");
String deviceName = HomeUtil.getDeviceName(eventData.getChannel(), (Context) this);
String alarmMode = HomeUtil.getAlarmMode(eventData.getType(), (Context) this);
StringCompanionObject stringCompanionObject = StringCompanionObject.INSTANCE;
String format = String.format(string, Arrays.copyOf(new Object[]{deviceName, alarmMode}, 2));
Intrinsics.checkNotNullExpressionValue(format, "java.lang.String.format(format, *args)");
NotificationUtil.showNotification((Context) this, R.drawable.app_logo, title, format);
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
}
Context context = (Context) this;
if (TextUtils.isEmpty(body)) {
body = "You have an alarm message";
}
NotificationUtil.showNotification(context, R.drawable.app_logo, title, body);
}
public void onDeletedMessages() {
super.onDeletedMessages();
}
private final void dealData(String str) {
ArrayList arrayList;
try {
System.out.println((Object) Intrinsics.stringPlus("lyq 非离线 str:", str));
AlarmEventType alarmEventType = (AlarmEventType) new Gson().fromJson(str, AlarmEventType.class);
String string = SharedPreUtils.getString((Context) this, SharedPre.Alarm.ALARM_INFO);
if (!TextUtils.isEmpty(string)) {
arrayList = (List) new Gson().fromJson(string, new TypeToken<ArrayList<AlarmEventType>>() {
}.getType());
if (arrayList == null) {
arrayList = new ArrayList();
}
} else {
arrayList = new ArrayList();
}
arrayList.add(alarmEventType);
String json = new Gson().toJson(arrayList);
System.out.println((Object) Intrinsics.stringPlus("lyq 非离线 设置字符串:", json));
SharedPreUtils.putString((Context) this, SharedPre.Alarm.ALARM_INFO, json);
} catch (Exception e) {
e.printStackTrace();
}
}
}