导航菜单

页面标题

页面副标题

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

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

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


package com.dieam.reactnativepushnotification.modules;

import android.app.Application;
import android.app.NotificationManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.core.app.RemoteInput;
import androidx.media3.extractor.text.ttml.TtmlNode;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;

public class RNPushNotificationActions extends BroadcastReceiver {
    @Override
    public void onReceive(final Context context, Intent intent) {
        String str = context.getPackageName() + ".ACTION_";
        Log.i(RNPushNotification.LOG_TAG, "RNPushNotificationBootEventReceiver loading scheduled notifications");
        if (intent.getAction() == null || !intent.getAction().startsWith(str)) {
            return;
        }
        final Bundle bundleExtra = intent.getBundleExtra("notification");
        Bundle resultsFromIntent = RemoteInput.getResultsFromIntent(intent);
        if (resultsFromIntent != null) {
            bundleExtra.putCharSequence("reply_text", resultsFromIntent.getCharSequence(RNPushNotification.KEY_TEXT_REPLY));
        }
        NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
        int parseInt = Integer.parseInt(bundleExtra.getString(TtmlNode.ATTR_ID));
        if (bundleExtra.getBoolean("autoCancel", true)) {
            if (bundleExtra.containsKey("tag")) {
                notificationManager.cancel(bundleExtra.getString("tag"), parseInt);
            } else {
                notificationManager.cancel(parseInt);
            }
        }
        if (bundleExtra.getBoolean("invokeApp", true)) {
            new RNPushNotificationHelper((Application) context.getApplicationContext()).invokeApp(bundleExtra);
            context.sendBroadcast(new Intent("android.intent.action.CLOSE_SYSTEM_DIALOGS"));
        } else {
            new Handler(Looper.getMainLooper()).post(new Runnable() {
                @Override
                public void run() {
                    final ReactInstanceManager reactInstanceManager = context.getApplicationContext().getReactNativeHost().getReactInstanceManager();
                    ReactContext currentReactContext = reactInstanceManager.getCurrentReactContext();
                    if (currentReactContext != null) {
                        new RNPushNotificationJsDelivery(currentReactContext).notifyNotificationAction(bundleExtra);
                        return;
                    }
                    reactInstanceManager.addReactInstanceEventListener(new ReactInstanceManager.ReactInstanceEventListener() {
                        public void onReactContextInitialized(ReactContext reactContext) {
                            new RNPushNotificationJsDelivery(reactContext).notifyNotificationAction(bundleExtra);
                            reactInstanceManager.removeReactInstanceEventListener(this);
                        }
                    });
                    if (reactInstanceManager.hasStartedCreatingInitialContext()) {
                        return;
                    }
                    reactInstanceManager.createReactContextInBackground();
                }
            });
        }
    }
}