admin管理员组文章数量:1416661
I have built an app with react js using expo. I am trying to schedule a local notification. The notification ID is getting generated. But it is triggered immediately, not being scheduled. I logged all the scheduled notifications using const scheduled = await Notifications.getAllScheduledNotificationsAsync();but the scheduled array is returning []. I am calling this scheduleDailyNotification() function after successful signup. I have built my app in developer mode. And still having this problem. Can anyone help?
import * as Notifications from 'expo-notifications';
import { Alert, Platform } from 'react-native';
import Constants from "expo-constants";
import * as Device from 'expo-device';
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true, // ✅ Ensures the notification is displayed
shouldPlaySound: true, // ✅ Enables sound
shouldSetBadge: false, // ❌ No badge update
}),
});
async function createNotificationChannel() {
if (Platform.OS === 'android') {
await Notifications.setNotificationChannelAsync('default', {
name: 'Default Channel',
importance: Notifications.AndroidImportance.MAX,
vibrationPattern: [0, 250, 250, 250],
lightColor: '#FF231F7C',
});
}
}
// ✅ Request Notification Permission and return boolean status
async function requestNotificationPermission() {
const { status } = await Notifications.getPermissionsAsync();
Alert.alert("
本文标签:
版权声明:本文标题:android - expo app scheduled local notification getting triggered immediately, not getting scheduled - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1745251934a2649873.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论