导航菜单

页面标题

页面副标题

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

正在查看: Bedrock Radio v1.1.1 应用的 RNPushNotificationPublisher.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.os.Bundle;
import android.util.Log;
import androidx.media3.extractor.text.ttml.TtmlNode;
import java.security.SecureRandom;

public class RNPushNotificationPublisher extends BroadcastReceiver {
    static final String NOTIFICATION_ID = "notificationId";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.i(RNPushNotification.LOG_TAG, "NotificationPublisher: Prepare To Publish: " + intent.getIntExtra(NOTIFICATION_ID, 0) + ", Now Time: " + System.currentTimeMillis());
        Bundle extras = intent.getExtras();
        StringBuilder sb = new StringBuilder("onMessageReceived: ");
        sb.append(extras);
        Log.v(RNPushNotification.LOG_TAG, sb.toString());
        handleLocalNotification(context, extras);
    }

    private void handleLocalNotification(Context context, Bundle bundle) {
        if (bundle.getString(TtmlNode.ATTR_ID) == null) {
            bundle.putString(TtmlNode.ATTR_ID, String.valueOf(new SecureRandom().nextInt()));
        }
        RNPushNotificationHelper rNPushNotificationHelper = new RNPushNotificationHelper((Application) context.getApplicationContext());
        Log.v(RNPushNotification.LOG_TAG, "sendNotification: " + bundle);
        rNPushNotificationHelper.sendToNotificationCentre(bundle);
    }
}