Skip to content

Instantly share code, notes, and snippets.

Alex Loukissas aloukissas

  • Los Angeles, CA
Block or report user

Report or block aloukissas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View push-permissions.js
import { Permissions } from "expo";
async function registerForPushNotificationsAsync() {
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
View remove-item.js
deleteUserCity = async () => {
try {
await AsyncStorage.removeItem("userCity");
} catch (error) {
console.log(`While removing userCity: ${error.message}`);
}
}
View get-item.js
getUserCity = async () => {
try {
return await AsyncStorage.getItem("userCity");
catch (error) {
console.log(`While getting userCity: ${error.message}`);
return null;
}
}
View set-item.js
setUserCity = async (city) => {
try {
await AsyncStorage.setItem("userCity", city);
} catch (error) {
console.log(`While storing userCity: ${error.message}`);
}
}
View Location.js
import React from "react";
import { View, Text, Platform } from "react-native";
import { Constants, Location, Permissions } from "expo";
class PermissionsExample extends React.Component {
state = {
message: null,
location: null
};
View Pemissions.js
import React from "react";
import { View, Text } from "react-native";
import { Permissions } from "expo";
class PermissionsExample extends React.Component {
state = {
message: ""
};
async componentWillMount() {
View Home.js
import React from "react";
import { View, Text, StyleSheet, Button } from "react-native";
import { Auth } from "aws-amplify";
import { withAuthContext } from "../context";
class Home extends React.Component {
handleLogout = async () => {
await Auth.signOut();
this.props.auth.setAuthenticated(false);
};
View Login.js
import { withAuthContext } from "../context";
[...]
export default withAuthContext(Login);
View Login.js
handleSubmit = async () => {
try {
await Auth.signIn(this.state.email, this.state.password);
this.props.auth.setAuthenticated(true);
} catch (error) {
Alert.alert("Error logging in", error, { text: "OK" });
}
};
View App-render.js
render() {
const RootNavigator = createRootNavigator(this.state.isAuthenticated);
const AppContainer = createAppContainer(RootNavigator);
return (
<AuthContext.Provider
value={{
isAuthenticated: this.state.isAuthenticated,
setAuthenticated: this.setAuthenticated
}}
You can’t perform that action at this time.