How to do it...

  1. Let's start with building the App. We'll start that by adding the dependencies we need to App.js:
import React from 'react';import {  StyleSheet,  Text,  View,  TextInput,  TouchableOpacity} from 'react-native';import { Permissions, Notifications } from 'expo';
  1. We're going to declare two constants for the API endpoints on our server, but the url will be generated by ngrok when we run the server later in the recipe, so we'll update the value of these constants at that point:
const PUSH_REGISTRATION_ENDPOINT = 'http://generated-ngrok-url/token';const MESSAGE_ENPOINT = 'http://generated-ngrok-url/message';
  1. Let's create the App component and initialize the state object. We'll need a notification property to hold notifications ...

Get React Native Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.