Skip to content

Check if notifications are enabled from app settings (Only for android)

Notifications You must be signed in to change notification settings

alienslab02/react-native-permission-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-permission-settings

Get to know if user has turned off notifications of your app from app settings. Only for Android.

Installation

Run this command in terminal inside your projects root folder.

npm install react-native-permission-settings

Android

Step 1:

In android/settings.gradle file add following lines

include ':react-native-permission-settings'
project(':react-native-permission-settings').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-permission-settings/android')

Step 2: In your android/app/build.gradle file add following line in dependencies.

dependencies: {
	...
	compile project(':react-native-permission-settings')
}

Step 3:

In your MainApplication.java located in android/app/src/main/java/com/<your_app>/ folder, add following lines in

import com.alienslab.permissionsettings.PermissionSettingsPackage; // <---

...

protected List<ReactPackage> getPackages() {
  return Arrays.asList(
      new MainReactPackage(),
      new PermissionSettingsPackage(), // <---
  );
}

Usage

import NotificationSettings from 'react-native-permission-settings';

...

NotificationSettings.areNotificationsEnabled((isEnabled: boolean) => {
  console.log(`Notifications are enabled: ${isEnabled}`);
});

About

Check if notifications are enabled from app settings (Only for android)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published