Skip to content

Instantly share code, notes, and snippets.

import React from "react";
import { Linking, Text, View } from "react-native";
class LinkingDemoModal extends React.Component {
handleOpenUrl = url => {
Linking.openURL(url);
}
render() {
return (
import React from "react";
import { Text, View } from "react-native";
import { WebBrowser } from "expo";
class LinkingDemoModal extends React.Component {
handleOpenUrl = url => {
WebBrowser.openBrowserAsync(url);
}
render() {
import React from "react";
import { Linking, Text, View } from "react-native";
class LinkingDemo extends React.Component {
handleOpenUrl = url => {
Linking.openURL(url);
}
render() {
return (
loadAppResources = async () => {
SplashScreen.hide();
const fonts = [
require("./assets/fonts/Roboto.ttf"),
require("./assets/fonts/Roboto_bold.ttf"),
require("./assets/fonts/Roboto_medium.ttf")
];
const cachedFonts = fonts.map(font => {
loadSplashResourcesAsync = async () => {
const splash = require("./assets/images/splash.png");
return Asset.loadAsync(splash);
};
render() {
if (!this.state.isSplashReady) {
return (
<AppLoading
startAsync={this.loadSplashResources}
onFinish={() => this.setState({ isSplashReady: true })}
autoHideSplash={false}
/>
);
}
class App extends React.Component {
state = {
notification: ""
};
registerForPushNotificationsAsync = async () => {
// Same as earlier
}
handleNotification = notification => {
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: {
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();
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.