Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29612

null is not an object (evaluating '_ExponentNotifications.default.cancelAllScheduledNotificationsAsync') React Native

$
0
0

I am getting this error when evaluating Notifications.cancelAllScheduledNotificationsAsync() in React Native application and android emulator.

Error Stack

 TypeError: null is not an object (evaluating '_ExponentNotifications.default.cancelAllScheduledNotificationsAsync')cancelAllScheduledNotificationsAsync@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:110086:44_callee$tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26262:23invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26438:32tryCatch@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26262:23invoke@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26338:30http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26368:19tryCallTwo@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27627:9doResolve@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27791:25Promise@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27650:14callInvokeWithMethodAndArg@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26367:33enqueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26372:157async@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:26389:69tryCallOne@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27618:16http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:27719:27_callTimer@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31173:17_callImmediatesPass@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31209:19callImmediates@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:31428:33callImmediates@[native code]__callImmediates@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3238:35http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3015:34__guard@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3221:15flushedQueue@http://10.0.2.2:8081/index.bundle?platform=android&dev=true&minify=false:3014:21flushedQueue@[native code]invokeCallbackAndReturnFlushedQueue@[native code]

Notifications.js

import {Notifications} from 'expo'import * as Permissions from 'expo-permissions';import {AsyncStorage} from "react-native";const notificationsKey = "@questions-flash-cards-key:notifications";export function clearLocalNotifications() {    return AsyncStorage.removeItem(notificationsKey).then(() => Notifications.cancelAllScheduledNotificationsAsync())}const notification = {    title: "You forgot solving quiz today.",    body: "Answer quiz per day to improve yourself.",    ios: {        sound: true    },    android: {        sound: true,        vibrate: true,    },};export async function setLocalNotification() {    const {status} = await Permissions.getAsync(Permissions.NOTIFICATIONS);    if (status !== 'granted') {        await Permissions.askAsync(Permissions.NOTIFICATIONS);    }    AsyncStorage.getItem(notificationsKey).then(JSON.parse).then(async (data) => {        if (data === null) {            Notifications.cancelAllScheduledNotificationsAsync().then(() => {                let tomorrow = new Date(Date.now());                tomorrow.setDate(tomorrow.getDate() + 1);                tomorrow.setHours(12);                tomorrow.setMinutes(0);                Notifications.scheduleLocalNotificationAsync(notification, {                    time: tomorrow, repeat: "day"                })            })        }    })}

Viewing all articles
Browse latest Browse all 29612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>