1.0.0 • Published 3 years ago
@phamhuuan/react-native-notification-settings v1.0.0
@phamhuuan/react-native-app-notification-settings
Getting started
$ npm install @phamhuuan/react-native-app-notification-settings --save
Mostly automatic installation
$ react-native link @phamhuuan/react-native-app-notification-settings
Usage
Import
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
Open notification setting
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
ReactNativeAppNotificationSettings.openNotificationSetting();
// or
import {openNotificationSetting} from '@phamhuuan/react-native-app-notification-settings';
openNotificationSetting();
Open notification channel settings
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
ReactNativeAppNotificationSettings.openNotificationChannelSetting();
// or
import {openNotificationChannelSetting} from '@phamhuuan/react-native-app-notification-settings';
openNotificationChannelSetting();
Get notification enabled status
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
const status = await ReactNativeAppNotificationSettings.isNotificationEnabled();
// or
import {isNotificationEnabled} from '@phamhuuan/react-native-app-notification-settings';
const status = await isNotificationEnabled();
Hook
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
const status = ReactNativeAppNotificationSettings.useNotificationEnabled();
// or
import {useNotificationEnabled} from '@phamhuuan/react-native-app-notification-settings';
const status = useNotificationEnabled();
Create notification channel
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
ReactNativeAppNotificationSettings.createNotificationChannel(channelId, name, description);
// or
import {createNotificationChannel} from '@phamhuuan/react-native-app-notification-settings';
createNotificationChannel(channelId, name, description);
Delete notification channel
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
ReactNativeAppNotificationSettings.deleteNotificationChannel(channelId);
// or
import {deleteNotificationChannel} from '@phamhuuan/react-native-app-notification-settings';
deleteNotificationChannel(channelId);
Get notification channel
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
const {
channelId,
name,
description,
importance,
lightColor,
lockscreenVisibility,
sound
} = await ReactNativeAppNotificationSettings.getNotificationChannelSetting(channelId);
// or
import {getNotificationChannelSetting} from '@phamhuuan/react-native-app-notification-settings';
const {
channelId,
name,
description,
importance,
lightColor,
lockscreenVisibility,
sound
} = await getNotificationChannelSetting(channelId);
Get all notification channels
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
const channels = await ReactNativeAppNotificationSettings.getNotificationChannelsSetting(channelId);
// or
import {getNotificationChannelsSetting} from '@phamhuuan/react-native-app-notification-settings';
const channels = await getNotificationChannelsSetting(channelId);
Rename notification channel
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
ReactNativeAppNotificationSettings.renameNotificationChannel(channelId, name, description);
// or
import {renameNotificationChannel} from '@phamhuuan/react-native-app-notification-settings';
renameNotificationChannel(channelId, name, description);
Rename multiple notification channels
import ReactNativeAppNotificationSettings from '@phamhuuan/react-native-app-notification-settings';
const channels = [
{
channelId: 'channelId1',
name: 'name1',
description: 'description1'
},
{
channelId: 'channelId2',
name: 'name2',
description: 'description2'
},
// ...
];
ReactNativeAppNotificationSettings.renameNotificationChannels(channels);
// or
import {renameNotificationChannels} from '@phamhuuan/react-native-app-notification-settings';
const channels = [
{
channelId: 'channelId1',
name: 'name1',
description: 'description1'
},
{
channelId: 'channelId2',
name: 'name2',
description: 'description2'
},
// ...
];
renameNotificationChannels(channels);
1.0.0
3 years ago