This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Linking, Text, View } from "react-native"; | |
class LinkingDemoModal extends React.Component { | |
handleOpenUrl = url => { | |
Linking.openURL(url); | |
} | |
render() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Linking, Text, View } from "react-native"; | |
class LinkingDemo extends React.Component { | |
handleOpenUrl = url => { | |
Linking.openURL(url); | |
} | |
render() { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loadSplashResourcesAsync = async () => { | |
const splash = require("./assets/images/splash.png"); | |
return Asset.loadAsync(splash); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render() { | |
if (!this.state.isSplashReady) { | |
return ( | |
<AppLoading | |
startAsync={this.loadSplashResources} | |
onFinish={() => this.setState({ isSplashReady: true })} | |
autoHideSplash={false} | |
/> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App extends React.Component { | |
state = { | |
notification: "" | |
}; | |
registerForPushNotificationsAsync = async () => { | |
// Same as earlier | |
} | |
handleNotification = notification => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |