android - expo app scheduled local notification getting triggered immediately, not getting scheduled - Stack Overflow

I have built an app with react js using expo. I am trying to schedule a local notification. The notific

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("

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745251935a4618728.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信