Setting Up iOS Push Notifications
Setting Up iOS Push Notifications with Firebase Cloud Messaging (FCM)
Overview
This guide provides step-by-step instructions to set up iOS Push Notifications using Firebase Cloud Messaging (FCM). By following these steps, users can enable push notifications in their iOS app and integrate FCM for seamless message delivery.
Prerequisites
Before proceeding, ensure you have:
An active Apple Developer Account.
Xcode installed on your system.
A Firebase project set up in the Firebase Console.
A registered iOS app in Firebase.
Step 1: Create a Firebase Project
Go to Firebase Console.
Click Add Project.
Enter your project name and click Continue.
(Optional) Enable Google Analytics for your project.
Click Create Project and wait for the setup to complete.
Step 2: Register Your iOS App in Firebase
In Firebase Console, open your project.
Click the Settings (⚙️) > Project Settings.
Under the General tab, scroll to Your Apps.
Click Add App > iOS.
Enter your iOS bundle ID (from Info.plist).
(Optional) Add an App Nickname.
Click Register App.
Step 3: Download and Add GoogleService-Info.plist
After registering the app, click Download GoogleService-Info.plist.
Move this file to your iOS project: Place it in the root directory of your Xcode project.
Open Xcode and ensure the file is added to the correct targets.
Step 4: Enable Push Notifications in Xcode
Open Xcode and navigate to Signing & Capabilities.
Click + Capability and select Push Notifications.
Add the Background Modes capability and check Remote Notifications.
Step 5: Configure APNs Authentication Key in Firebase
Sign in to the Apple Developer Console.
Navigate to Certificates, Identifiers & Profiles.
Select Keys and create a new key.
Enable Apple Push Notifications service (APNs) and click Continue.
Download the .plist key file and note the Key ID.
In Firebase Console, go to Project Settings > Cloud Messaging.
Upload the .plist file and enter:
Key ID (from Apple Developer Console).
Team ID (from Apple Developer Account).
Bundle ID (from Xcode project).
Save the settings.
Step 6: Add Firebase Messaging SDK to Your iOS App
Open your Podfile and add: pod 'Firebase/Messaging'
pod 'Firebase/Messaging'
Run pod install in the terminal.
Open AppDelegate.swift and import Firebase:
import Firebase
import FirebaseMessaging
Configure Firebase in application (_:didFinishLaunchingWithOptions:):
FirebaseApp.configure()
Register for remote notifications:
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
print("Permission granted: \(granted)")
}
UIApplication.shared.registerForRemoteNotifications()
Implement MessagingDelegate to handle the FCM token:
extension AppDelegate: MessagingDelegate {
func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
print("FCM Token: \(fcmToken ?? "")")
}
}
Step 7: Test Push Notifications
Obtain Firebase Cloud Messaging Token
Run your app on a real iOS device (not a simulator).
Check the Xcode console for the FCM token.
Copy the token for testing.
Send a Test Notification from Firebase Console
Go to Firebase Console > Cloud Messaging.
Click Send your first message.
Enter a notification title and message.
Select Send to a test device.
Paste the copied FCM token.
Click Send Message and check if the notification appears on the device.
Step 8: Configure Firebase in Organon
To send notifications from Organon, users must upload their APNs credentials.
Open Organon and navigate to Push Notification Settings.
Select the iOS tab.
Enter the following details:
Team ID (from Apple Developer Portal) Navigate to Cloud Messaging of firebase -> Your app-> Team ID
Key ID (from Apple Developer Portal)Navigate to Cloud Messaging of firebase -> Your app->Key ID
Bundle ID (from Xcode project settings)Navigate to General settings of firebase -> Your app-> Bundle ID
Upload the .plist file.
Click Enable iOS Push Configuration.
Save the configuration.
Step 9: Deploy and Monitor Push Notifications
Once testing is successful:
Use Organon’s campaign feature to send push notifications.
Monitor delivery rates and engagement using Organon’s analytics dashboard.
Optimize message content for better user interaction.
Troubleshooting
Ensure GoogleService-Info.plist is correctly placed in Organon’s settings.
Verify the Firebase project is set to allow push notifications.
Check Organon’s notification logs for errors.
Ensure the device has internet connectivity.
Following these steps will enable push notifications via Firebase Cloud Messaging and allow sending notifications directly from Organon.
Last updated