package com.foo.bar; import android.util.Log; import android.content.Context; import android.provider.Settings; import java.lang.System; import android.app.Notification; import androidx.core.app.NotificationCompat; import android.app.NotificationManager; import android.app.NotificationChannel; import android.content.Intent; import android.app.PendingIntent; import com.facebook.react.bridge.NativeModule; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableMap; public class Notifications extends ReactContextBaseJavaModule { private static ReactApplicationContext reactContext; Notifications(ReactApplicationContext context) { super(context); reactContext = context; } @Override public String getName() { return "Notifications"; } @ReactMethod public void show(ReadableMap details) { Log.v("my-debug", "notifications show start"); Intent notificationIntent = new Intent( reactContext, MainActivity.class ); PendingIntent pendingIntent = PendingIntent.getActivity( reactContext, 0, notificationIntent, Intent.FLAG_ACTIVITY_NEW_TASK ); NotificationCompat.Builder b = new NotificationCompat.Builder(reactContext); b .setContentIntent(pendingIntent) .setContentText("Body text not working") .setSmallIcon(R.mipmap.ic_launcher) .setAutoCancel(true) .setChannelId("10000"); if (details.hasKey("body")) { b.setContentText(details.getString("body")); } NotificationManager notificationManager = (NotificationManager) reactContext.getSystemService(Context.NOTIFICATION_SERVICE); // It's safe to call this repeatedly because creating an existing notification // channel performs no operation. // https://developer.android.com/training/notify-user/build-notification NotificationChannel notificationChannel = new NotificationChannel( "10000", "NOTIFICATION_CHANNEL_NAME", NotificationManager.IMPORTANCE_HIGH ); notificationManager.createNotificationChannel(notificationChannel) ; notificationManager.notify(1, b.build()); Log.v("my-debug", "notifications show reached end"); } }