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 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 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 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 set-item.js
setUserCity = async (city) => {
try {
await AsyncStorage.setItem("userCity", city);
} catch (error) {
console.log(`While storing 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 remove-item.js
deleteUserCity = async () => {
try {
await AsyncStorage.removeItem("userCity");
} catch (error) {
console.log(`While removing userCity: ${error.message}`);
}
}
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 push-token.js
import { Notifications, Permissions } from "expo";
const PUSH_ENDPOINT = "https://your-push-server/push-token"
async function registerForPushNotificationsAsync() {
// Request permissions -- same as earlier
[...]
// Get the token that uniquely identifies this device
const token = await Notifications.getExpoPushTokenAsync();
View send-notification.js
const EXPO_HOST = "https://exp.host/--/api/v2/push/send";
function sendNotification(token, title, body) {
return fetch(EXPO_HOST, {
body: JSON.stringify({
to: token,
title: title,
body: body
}),
headers: {
View register-listener.js
class App extends React.Component {
state = {
notification: ""
};
registerForPushNotificationsAsync = async () => {
// Same as earlier
}
handleNotification = notification => {
You can’t perform that action at this time.