1.1.0 • Published 7 years ago

react-native-os-settings-manager v1.1.0

Weekly downloads
7
License
MIT
Repository
github
Last release
7 years ago

React Native OS Settings Manager

This is a native module to interact with Android/IOS settings.

Installation

npm install --save react-native-os-settings-manager

react-native link

Features

ANDROID

Method nameReturn value
areNotificationsEnabledBoolean
openAppSettings    Void      

IOS

Method nameReturn value
areNotificationsEnabled{badge:1, alert:1, sound:1} or {} if notifications disabled
openAppSettings    Void       

Usage

import RNOsSettingsManager from 'react-native-os-settings-manager';

/**
* This will open the os settings of your application.
*/
RNOsSettingsManager.accessAppSettings();

/**
* This will tell you if notifications are enabled or not in Android/IOS settings
*/
let notifications_enabled = await RNOsSettingsManager.areNotificationsEnabled();

if ( Platform.OS == 'android' ) {
	// ANDROID device
	console.assert(notifications_enabled == true,
		'It means that the notifications for your application are enabled');

	console.assert(notifications_enabled == false,
		'It means that the notifications for your application are disabled');

} else if ( Platform.OS == 'ios' ) {
	// IOS device
	console.assert(notifications_enabled.badge !== undefined,
		"It means that notification's badge for your application is enabled");

	console.assert(notifications_enabled.alert !== undefined,
		"It means that notification's alert for your application is enabled");

	console.assert(notifications_enabled.sound !== undefined,
		"It means that notification's sound for your application is enabled");

	console.assert(isNotificationEnabled === {},
		"It means that the notifications for your application are disabled");
}