Set up Push Notifications for iOS

You need an Apple developer account, which costs 100$ a year, for this implementation. If you don’t have a developer account, don’t worry, you can skip to the Android implementation of push notifications.

Configuring APNs with FCM

We need an Apple developer certificate or key to allow Firebase to send a notification message to APNs (Apple push notification service). To acquire a certificate or key, go to the Apple developer dashboard.

Create the authentication key

This section describes how to generate an authentication key for an app ID enabled for push notifications. If you have an existing key, you can use that key instead of generating a new one.

To create an authentication key:

In your developer account, go to Certificates, Identifiers & Profiles, and under Keys, select All.

2. Click the Add button (+) in the upper-right corner.

3. Enter a description for the APNs Auth Key. Under Key Services, select the APNs checkbox, and click Continue.

4. Click Confirm and then Download. Save your key in a secure place. This is a one-time download, and the key cannot be retrieved later.

5. If you’d like to verify that your APNs authentication key is set up properly and is accepted by APNs, try sending a test push notification.

Add the Certificate to Firebase

Go to cloud messaging setting to add the certificate to Firebase.

Upload the certificate to the AirBnB clone app and add the Key ID as well as the Team ID.

Configure the Project in Xcode

Open our project with Xcode and select the +Capability option inside Signing & Capabilities. Search for the push notification option and select it. In the same way, search for background modes. Select the Remote Notifications option from the listed options.

If you have followed the steps correctly, you will be able to see the following window.

As the next step, include Firebase messaging in the Podfile

We’ll now return to Xcode and open the Appdelegate.m file. To activate messaging on Appdelegate.m, first import the Firebase Notification library.

#import "RNFirebaseNotifications.h"

We activate the lib by adding a code segment below the Firebase lib:

if ([FIRApp defaultApp] == nil) {

[FIRApp configure];

[RNFirebaseNotifications configure];

};

[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];

return YES;

}

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {

[[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];

}

We’ve now completed the push notification set up. Close the packager terminal and run Xcode build once again to add the new functionality to the app.