AirBnB Clone with React Native Part 12: Request Push Notification UI
Tags: ui, reactnative, heartbeat, mobiledevelopment
Published: 2020-01-28 18:25:10

---
title: AirBnB Clone with React Native Part 12: Request Push Notification UI
published: true
date: 2020-01-28 17:25:57 UTC
tags: ui,react-native,heartbeat,mobile-development
canonical_url: https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-12-request-push-notification-ui-cd7a4ca3ab3c
cover_image: https://cdn-images-1.medium.com/max/1024/1*iIEhgq6z5aE3Ipn7Ejz8GQ.jpeg
---


This is the twelfth chapter of our implementation of an [AirBnB clone in React Native](https://www.instamobile.io/). In the previous chapters, we successfully implemented a splash screen on [iOS](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-10-implementing-a-splash-screen-ios-f391aee742d3) and [Android](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-11-implement-a-splash-screen-android-98d21f1a7caa) versions of our app.

If you missed any of the previous tutorials, we recommend that you follow them first by going through the following links:

- [AirBnB Clone with React Native Part 1: Home Screen UI](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-1-home-screen-ui-b5ed1c9278ae)
- [AirBnB Clone with React Native Part 2: Login Screen UI](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-2-login-screen-ui-999773e860e4)
- [AirBnB Clone with React Native Part 3: Email Authentication with Firebase](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-3-email-authentication-with-firebase-2153a00175ab)
- [AirBnB Clone with React Native Part 4: Login error notifications](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-4-login-error-notifications-580beb4fc03c)
- [AirBnB Clone with React Native Part 5: Loading Modal Implementation](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-5-loading-modal-implementation-8a399154ac02)
- [AirBnB Clone with React Native Part 6: Animated Checkmarks](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-6-animated-checkmarks-5917e4972702)
- [AirBnB Clone with React Native Part 7: “Forgot Password?” with Firebase](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-7-forgot-password-with-firebase-14ccbf6afa21)
- [AirBnB Clone with React Native Part 8: Firebase Facebook Login (iOS)](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-8-firebase-facebook-login-ios-f2cd4b73fe7d)
- [AirBnB Clone with React Native Part 9: Persistent login, drawer navigation, and logout](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-9-persistent-login-drawer-navigation-and-logout-7a6f08a8ec56)
- [AirBnB Clone with React Native Part 10: Implementing a splash screen [iOS]](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-10-implementing-a-splash-screen-ios-f391aee742d3)
- [AirBnB Clone with React Native Part 11: Implement a splash screen [Android]](https://heartbeat.fritz.ai/airbnb-clone-with-react-native-part-11-implement-a-splash-screen-android-98d21f1a7caa)

In this chapter, we’re going to implement a turn-on-notification screen. In a turn-on-notification screen, if you have not yet turned on notifications, a permission request to turn on notifications appears once you log in. How the turn-on screen works can be seen in the following video.

Before we set up push notifications and handle request tokens in the next chapter, we’ll create a simple UI for the request to permit notifications. Let’s get started!

![](https://cdn-images-1.medium.com/max/466/1*IVau-P-OrpKcZ8dcgA-ZNQ.gif)

First, create a new screen named RequestSendNotification.js

{% gist https://gist.github.com/krissnawat/07e9fdba722a690bafbe2f07e8fef2a1 %}

Inside the file, set the initialRouteName to RequestSendNotification.

![](https://cdn-images-1.medium.com/max/529/1*Gz2ZPYLImSQDhxGqGYvlRg.png)

![](https://cdn-images-1.medium.com/max/394/1*sYVWGQQsP1IG6c2367ezVQ.png)

As we found out in the previous chapter, we don’t have to show the logout button until the user is logged in and authenticated. So we’ll remove the header from this screen to solve this problem.

We can hide the header by simply wrapping the logout menu inside the onAuthStateChanged option.

{% gist https://gist.github.com/krissnawat/39c44150eba325fc04a3a197a24ff511 %}

Then, we set the header to null for this screen.

{% gist https://gist.github.com/krissnawat/a307253fbe4addd3bd8d2d6bc9cce4d3 %}

Now when we reopen the screen, the header is not shown.

![](https://cdn-images-1.medium.com/max/529/1*X5yZfl7KfryYx-6i0R3EFQ.png)

![](https://cdn-images-1.medium.com/max/394/1*jAB8Qk3boKz33BuF1aPpFQ.png)

Now we can bootstrap the new screen.

> Did you know: It’s possible for mobile apps to easily see, hear, sense, and think — all in real-time. [Learn how and start building for free with Fritz AI.](https://www.fritz.ai/product/standard.html?utm_campaign=buildapps8&utm_source=heartbeat)

### Find an Icon

Since this is only a simple app, we can use a screenshot of the original AirBnB icon as our icon. In a real-world application, you’ll have to use Photoshop to create a new icon.

![](https://cdn-images-1.medium.com/max/127/1*JFXj-nqdz06vpkaNrQoVZA.png)

### Bootstrap the Screen

Now let’s start adding styles to the screen. We need to import the StyleSheet component from React and the color configuration file to the RequestSendNotification.js file. The color config file contains the configured colors for our app.

{% gist https://gist.github.com/krissnawat/98bb7fe5d6bde48a5c5080fb6bc3624d %}

Then, create two wrappers as displayed in the following code snippet:

{% gist https://gist.github.com/krissnawat/53d3f084b39e33de5fea17d4d6429ec2 %}

And add a suitable style to the wrappers:

{% gist https://gist.github.com/krissnawat/6fa941ccdf5323644d913245d1122034 %}

We can see the text ‘notification’ has moved down the screen now:

![](https://cdn-images-1.medium.com/max/529/1*1VwRMtpUSOvdq_SNVhyAdQ.png)

![](https://cdn-images-1.medium.com/max/394/1*_lGiX2WmLPj-WOJZ9FnYng.png)

#### Add a Logo

We need to add a logo to the screen. As aforementioned, we can take a screenshot of this logo/icon from the AirBnB app itself. And as a reminder, you’d likely need to work with Photoshop or another image editor in a real-world application.

{% gist https://gist.github.com/krissnawat/ee4abf1395c62a2d63ef8446b80500c7 %}

Style the logo using relevant styling options:

{% gist https://gist.github.com/krissnawat/9900439f631b6b99d589a0cf9e5a2b14 %}

Now, the image will appear on the screen as follows.

![](https://cdn-images-1.medium.com/max/529/1*qljEoBtcyyIsHsLvD_X1SA.png)

![](https://cdn-images-1.medium.com/max/427/1*gpgjA8DyNrCS34-ePkDXOg.png)

> Personalization, instant expertise, game changing user experiences — these are just a few of the values machine learning can add to mobile apps. [Subscribe to the Fritz AI Newsletter to discover more.](https://www.fritz.ai/newsletter?utm_campaign=fritzai-newsletter-values2&utm_source=heartbeat)

### Add a Title

We need to add a title for this request to turn on the notifications.

{% gist https://gist.github.com/krissnawat/16dba1dfccc3a28923a7e66ef7329a9e %}

Style the title for a better look.

{% gist https://gist.github.com/krissnawat/84b9fdc9a51218b12cb7c99a0c00db11 %}

The resulting screen has a better look now:

![](https://cdn-images-1.medium.com/max/1024/1*zO7q4nQLIAQ8dQOibMHQTQ.png)

#### Add Description Text

We can add a detailed description of why we want to send notifications.

{% gist https://gist.github.com/krissnawat/587e87d64e527b27d258fdaac5607d5d %}

Add some styling to the description.

{% gist https://gist.github.com/krissnawat/0c0b94df400acb45eaf46c1e6254e3f2 %}

Does it look closer to our final screen?

![](https://cdn-images-1.medium.com/max/1024/1*VxHTqzahmud5ikKWhDC26Q.png)

#### Add a Notify Button

Add a button to trigger the native request notification popup.

{% gist https://gist.github.com/krissnawat/0e04a67f8627c730bcffe194dc5a12ba %}

We can style the button as well.

{% gist https://gist.github.com/krissnawat/d7c182b41ca6d89c7f432c1f0f05eb98 %}

Our screen now looks like this.

![](https://cdn-images-1.medium.com/max/1024/1*1LVv9YVQQZiCC0gF7iP7cw.png)

#### Add a Skip Button

Finally, we should add a skip button.

{% gist https://gist.github.com/krissnawat/d8211f9de1e7f4225e96815766c59112 %}

This button will share the style of the previous button, but we need to add a custom text color for this.

{% gist https://gist.github.com/krissnawat/15fb1b5d917bee6ad5d3a9b333544d25 %}

The screen now looks like this.

![](https://cdn-images-1.medium.com/max/1024/1*9c4zjglJOu8BiAWJzZTxOw.png)

We have now completed the layout section.

### Handle Underlay Color

Now we have to add a function to handle TouchableHighlight color when the button is pressed and released.

If we do not handle this, the default color looks like this:

![](https://cdn-images-1.medium.com/max/417/1*NSsaOddiTV1f3EOKvr4Iwg.gif)

We can change the color to a custom color to make it look better.

First, create a state and a function to toggle the show and hide states of the overlay.

{% gist https://gist.github.com/krissnawat/24dd9dd25818784cafc1f130e204c30b %}

Then add a function to TouchableOpacity.

{% gist https://gist.github.com/krissnawat/c52e62e66a08b24cddf7589f43f3f477 %}

Now, when the button is pressed, the color will not be changed.

![](https://cdn-images-1.medium.com/max/767/1*VT4Iin3SaJVrQGiceTHesw.gif)

### Redirect to Request Notification Screen

We need to modify the LoggedOut screen to navigate to the request notification screen after the log in.

```
return this.props.navigation.navigate("RequestSendNotification");
```

The final result of our turn-on screen should look like this.

![](https://cdn-images-1.medium.com/max/315/1*I0qVtsx-bu-fR82o-3KbiQ.gif)

### Summary

In this chapter, we learned how to build a request-to-send-notification screen and use different styles for Android and iOS with platform components. In the next chapter, we’ll work on setting up push notifications for iOS and Android.

_Editor’s Note:_[**_Heartbeat_**](http://heartbeat.fritz.ai/) _is a contributor-driven online publication and community dedicated to exploring the emerging intersection of mobile app development and machine learning. We’re committed to supporting and inspiring developers and engineers from all walks of life._

_Editorially independent, Heartbeat is sponsored and published by_[**_Fritz AI_**](http://fritz.ai/)_, the machine learning platform that helps developers teach devices to see, hear, sense, and think. We pay our contributors, and we don’t sell ads._

_If you’d like to contribute, head on over to our_[**_call for contributors_**](https://heartbeat.fritz.ai/call-for-contributors-october-2018-update-fee7f5b80f3e)_. You can also sign up to receive our weekly newsletters (_[**_Deep Learning Weekly_**](https://www.deeplearningweekly.com/) _and_ [**_The Fritz AI Newsletter_**](https://www.fritz.ai/newsletter)_), join us on_[](https://join.slack.com/t/fritz-ai-community/shared_invite/enQtNTY5NDM2MTQwMTgwLWU4ZDEwNTAxYWE2YjIxZDllMTcxMWE4MGFhNDk5Y2QwNTcxYzEyNWZmZWEwMzE4NTFkOWY2NTM0OGQwYjM5Y2U)[**_Slack_**](http://fritz.ai/slack)_, and follow Fritz AI on_[**_Twitter_**](https://twitter.com/fritzlabs) _for all the latest in mobile machine learning._

* * *