Skip to content

Commit

Permalink
fix: Fix the async function with permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
trentschnee committed Apr 14, 2020
1 parent e027fb0 commit 31282fc
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react'
import { View, Text, AsyncStorage } from 'react-native'
import { Notifications, Permissions } from 'expo'
import { Notifications } from 'expo'
import * as Permissions from 'expo-permissions'
const FLASHCARDS_NOTIFICATION_DB = 'flashcards:notification'
function createLocalNotification() {
// Return an object that says don't forget to study
Expand All @@ -12,8 +13,9 @@ function createLocalNotification() {

export function setLocalNotification() {
AsyncStorage.getItem(FLASHCARDS_NOTIFICATION_DB).then(JSON.parse).then((data) => {

if (data === null) {
Permissions.AsyncStorage(Permissions.NOTIFICATIONS).then(({ status }) => {
Permissions.getAsync(Permissions.NOTIFICATIONS).then(({ status }) => {
if (status === 'granted') {
Notifications.cancelAllScheduledNotificationsAsync()
// Create a new data
Expand Down

0 comments on commit 31282fc

Please sign in to comment.