expo-notifications
Version:
Provides an API to fetch push notification tokens and to present, schedule, receive, and respond to notifications.
27 lines (23 loc) • 987 B
text/typescript
import { UnavailabilityError } from 'expo-modules-core';
import NotificationChannelManager from './NotificationChannelManager';
import {
NotificationChannelInput,
NotificationChannel,
AndroidImportance,
} from './NotificationChannelManager.types';
export async function setNotificationChannelAsync(
channelId: string,
channel: NotificationChannelInput
): Promise<NotificationChannel | null> {
if (!NotificationChannelManager.setNotificationChannelAsync) {
throw new UnavailabilityError('Notifications', 'setNotificationChannelAsync');
}
if (channel?.importance === AndroidImportance.UNSPECIFIED) {
console.warn(
`Warning: You are setting the importance of the notification channel "${channelId}" to "UNSPECIFIED". ` +
`This may lead to errors on some Android versions. ` +
`It's recommended to instead use AndroidImportance.DEFAULT.`
);
}
return await NotificationChannelManager.setNotificationChannelAsync(channelId, channel);
}