简体   繁体   中英

How to enabled floating notification by default with react-native-firebase?

Halo, I have push notification in react-native using react-native-firebase, it's running well on emulator but on some devices the floating notification, lockscreen notification and sound disabled by default.

默认设置

how to force enable those setting with app installation?

I didnt try but first you can check if notifications are disabled by using NotificationManagerCompat.areNotificationsEnabled() , from support library. The versions below API 19 will return true (notifications are enabled).

Then if notifications disabled, you can warn your user and start notification settings like this answer :

Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");

//for Android 5-7
intent.putExtra("app_package", getPackageName());
intent.putExtra("app_uid", getApplicationInfo().uid);

// for Android 8 and above
intent.putExtra("android.provider.extra.APP_PACKAGE", getPackageName());

startActivity(intent);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM