Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions App.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { StatusBar } from "expo-status-bar";
import React, { useEffect } from "react";
import { Button, StyleSheet, Text, View } from "react-native";
import AsyncStorage from "@react-native-async-storage/async-storage";
import * as SecureStore from "expo-secure-store";
import Constants from "expo-constants";
import * as Notifications from "expo-notifications";
import * as TaskManager from "expo-task-manager";
import * as Location from "expo-location";

const TEST_KEY = "some-async-storage-key";
const TEST_KEY = "some-secure-store-key";
const TEST_VALUE = "Hello, world!";

/**
* Background task that executes when location changes.
*
* We expect to be able to access values stored in AsyncStorage,
* We expect to be able to access values stored in SecureStore,
* regardless of whether app is headless or not.
*
*/
TaskManager.defineTask("LOCATION_TASK", async ({ executionInfo }) => {
const val = await AsyncStorage.getItem(TEST_KEY);
const val = await SecureStore.getItemAsync(TEST_KEY);
presentLocalNotification(
"Location updated!",
JSON.stringify({
appState: executionInfo.appState,
headless: Constants.isHeadless,
asyncStorageVal: val,
secureStoreVal: val,
})
);
});
Expand Down Expand Up @@ -67,9 +67,9 @@ export default function App() {
<Button
title="Start watching location"
onPress={async () => {
await AsyncStorage.setItem(TEST_KEY, TEST_VALUE);
await SecureStore.setItemAsync(TEST_KEY, TEST_VALUE);
await presentLocalNotification(
"Value saved to AsyncStorage!",
"Value saved to SecureStore!",
TEST_VALUE
);

Expand Down
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"expo": {
"name": "task-manager-async-storage",
"slug": "task-manager-async-storage",
"name": "task-manager-secure-store",
"slug": "task-manager-secure-store",
"owner": "rivet",
"version": "1.0.0",
"orientation": "portrait",
Expand All @@ -17,7 +17,7 @@
"assetBundlePatterns": ["**/*"],
"ios": {
"supportsTablet": true,
"bundleIdentifier": "com.quicksoinc.task-manager-async-storage",
"bundleIdentifier": "com.quicksoinc.task-manager-secure-store",
"infoPlist": {
"UIBackgroundModes": ["location", "fetch"],
"NSLocationWhenInUseUsageDescription": "We'll use this to make your experience better.",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"expo-constants": "~10.1.3",
"expo-location": "~12.0.4",
"expo-notifications": "~0.11.6",
"expo-secure-store": "~10.1.0",
"expo-status-bar": "~1.0.4",
"expo-task-manager": "~9.1.0",
"react": "16.13.1",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3127,6 +3127,11 @@ expo-notifications@~0.11.6:
unimodules-permissions-interface "~6.1.0"
uuid "^3.4.0"

expo-secure-store@~10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/expo-secure-store/-/expo-secure-store-10.1.0.tgz#a223b3323526b152cd29c6e13058d8c8c2711eab"
integrity sha512-mH53aCptDMiLGopsq0uSpeRLtVpFi+IgwqLGNvIKn0CnSxBUbzE9bq5TSKCBm4JxN4/viohpV3R7L6Qj8MQT+g==

expo-status-bar@~1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/expo-status-bar/-/expo-status-bar-1.0.4.tgz#d8a4c4418b5868c1606969b12bdee85b6fa7d8a4"
Expand Down