导航菜单

页面标题

页面副标题

Bedrock Radio v1.1.1 - RNPushNotificationBootEventReceiver.java 源代码

正在查看: Bedrock Radio v1.1.1 应用的 RNPushNotificationBootEventReceiver.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.dieam.reactnativepushnotification.modules;

import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.util.Log;
import java.util.Set;

public class RNPushNotificationBootEventReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(RNPushNotification.LOG_TAG, "RNPushNotificationBootEventReceiver loading scheduled notifications");
        SharedPreferences sharedPreferences = context.getSharedPreferences(RNPushNotificationHelper.PREFERENCES_KEY, 0);
        Set<String> keySet = sharedPreferences.getAll().keySet();
        RNPushNotificationHelper rNPushNotificationHelper = new RNPushNotificationHelper((Application) context.getApplicationContext());
        for (String str : keySet) {
            try {
                String string = sharedPreferences.getString(str, null);
                if (string != null) {
                    RNPushNotificationAttributes fromJson = RNPushNotificationAttributes.fromJson(string);
                    if (fromJson.getFireDate() < System.currentTimeMillis()) {
                        Log.i(RNPushNotification.LOG_TAG, "RNPushNotificationBootEventReceiver: Showing notification for " + fromJson.getId());
                        rNPushNotificationHelper.sendToNotificationCentre(fromJson.toBundle());
                    } else {
                        Log.i(RNPushNotification.LOG_TAG, "RNPushNotificationBootEventReceiver: Scheduling notification for " + fromJson.getId());
                        rNPushNotificationHelper.sendNotificationScheduledCore(fromJson.toBundle());
                    }
                }
            } catch (Exception e) {
                Log.e(RNPushNotification.LOG_TAG, "Problem with boot receiver loading notification " + str, e);
            }
        }
    }
}