Overview
To receive push notifications in your iOS app, you need to configure the necessary permissions, register for remote notifications, and handle incoming notifications.Prerequisites
Before you can receive push notifications:- Complete the iOS SDK Installation
- Complete the iOS SDK Configuration
- Configure your iOS APNs credentials in the AppPanel dashboard (see below)
Configure APNs Credentials
Before your app can receive push notifications, you need to upload your Apple Push Notification service (APNs) credentials to AppPanel.Step 1: Create an APNs Key in Apple Developer Portal
- Go to Apple Developer Portal
- Click the + button to create a new key
- Enter a name for your key (e.g., “AppPanel Push Notifications”)
- Check Apple Push Notifications service (APNs)
- Click Continue, then Register
- Download the
.p8file - you can only download this once, so keep it safe - Note your Key ID (10-character string) and Team ID (found in top right of the page)
Step 2: Upload to AppPanel Console
- Log in to your AppPanel Console
- Navigate to your project
- Go to Settings ▸ Project ▸ Push Notifications
- Upload your
.p8file - Enter your Key ID (from Step 1)
- Enter your Team ID (from Step 1)
- Click Upload Credentials
- If you haven’t already, navigate to general and set your apps iOS Bundle Identifier (e.g.,
com.yourcompany.yourapp)
You can use the same
.p8 key for both development and production environments. AppPanel will automatically route notifications to the appropriate APNs environment based on your build configuration.iOS Setup
Step 1: Enable Push Notifications Capability
In Xcode, select your app target and go to Signing & Capabilities, then click + Capability and add Push Notifications.Step 2: Register for Remote Notifications
In yourdidFinishLaunchingWithOptions, register for remote notifications. You don’t need permission to get the device token:
Step 3: Handle Device Token Registration
Add these methods to yourAppDelegate to handle device token registration:
These methods go in the same
AppDelegate class shown in Step 2. They work identically for both UIKit and SwiftUI apps.Step 4: Request Permission to Display Notifications
To actually display notifications to the user, you need to request authorization. Call this method when appropriate (e.g., during onboarding or when the user opts in):You can register for remote notifications and receive a device token without requesting permission from the user. However, you must call
requestNotificationPermission() and get user permission before notifications will be displayed to the user.Step 5: Implement UNUserNotificationCenterDelegate
For more control over notification presentation, add theUNUserNotificationCenterDelegate to your AppDelegate and implement these methods:
First, update your AppDelegate declaration to conform to UNUserNotificationCenterDelegate:
didFinishLaunchingWithOptions (right after configuring AppPanel):
Troubleshooting
Notifications Not Appearing
- Check that notification permissions are granted in Settings
- Ensure APNs certificates are properly configured in AppPanel dashboard
- Verify the device token is being registered successfully
- Check that your app is using the correct bundle identifier
Device Token Not Registered
- Ensure you’re calling
registerForRemoteNotifications()on the main thread - Check for errors in
didFailToRegisterForRemoteNotificationsWithError - Verify your app has the Push Notifications capability enabled