Overview
Notification Service Extensions let you intercept and modify push notifications before it’s displayed to the user. This enables:- Background data handling
- Custom styles (colors, icons, vibration)
- Rich media attachments (images, videos)
- Confirmed delivery/analytics
- Action button options
You can access the data in your push notifications sent from OneSignal via the OSNotification class
Android Notification Service Extension
Allows you to process the notification before it is shown to the user. Common use cases include:- Receive data in the background with or without displaying a notification.
- Override specific notification settings depending on client side app logic such as custom accent color, vibration pattern, or other any other
NotificationCompat
options available.
1. Create a class for the Service Extension
Create a class that extendsINotificationServiceExtension
and implement the onNotificationReceived
method.
The method onNotificationReceived
parameter is event
of type INotificationReceivedEvent .
2. Example use cases
The following are common examples you can implement in the template Notification Service Extension class above.3. Add the Service Extension to your AndroidManifest.xml
Add the class name and value as meta-data
within the AndroidManifest.xml
file in the application tag. Ignore any “unused” warnings.
XML
iOS Notification Service Extension
The UNNotificationServiceExtension allows you to modify the content of push notifications before they are displayed to the user and is required for other important features like:- Images & Rich Media.
- Confirmed Delivery
- Badges
- Action Buttons
- Influenced Opens with Firebase Analytics
Getting the iOS push payload
When following the Mobile SDK setup you will get to the section on adding the code to the OneSignalNotificationServiceExtension. In that code, there is the methodOneSignalExtension.didReceiveNotificationExtensionRequest
. This is where we pass the bestAttemptContent
of the notification to the app before it is displayed to the user. Before this method is called, you can get the notification payload and (if desired) update it before it is displayed to the user.
In this example, we send a notification with the following data:
JSON
data
within the OneSignalNotificationServiceExtension via the custom
object using the a
parameter.
Troubleshooting the iOS Notification Service Extension
This guide is for debugging issues with Images, Action Buttons, or Confirmed Deliveries not showing on iOS mobile apps. Check your Xcode Settings In General > Targets make sure your main app target and OneSignalNotificationServiceExtension target have the same and correct “Supported Destinations” and your “Minimum Deployment” is set to iOS 14.5 or higher. If you are using Cocoapods make sure these match with your main target in the Podfile to avoid build errors.
Notification Service Extension configuration in Xcode

Example shows the OneSignalNotificationServiceExtension target with the same Minimum Deployments as iOS 14.
NSExtension
key. Ensure you see:

Example viewing the Info tab and not the XML.
XML
If using Objective-C, instead of
$(PRODUCT_MODULE_NAME).NotificationService
use NotificationService
.
Embed App Extensions build phase settings
How to debug the Notification Service Extension not running
1. Update the OneSignalNotificationServiceExtension code
Open theNotificationService.m
or NotificationService.swift
and replace the whole file contents with the below code. (The code is the same as our original setup code, just adding some additional logging.
Make sure to replace YOUR_BUNDLE_ID
with your actual Bundle ID.
2. Change your Active Scheme
Set your Active Scheme to theOneSignalNotificationServiceExtension
.

Xcode active scheme selection
3. Build and run the project
Build and run the project in Xcode on a real device.4. Open the Console
In Xcode, select Window > Devices and Simulators.
Xcode Devices and Simulators window

Device console access button
5. Check the Console
In the Console:- Select Action > Include Debug Messages
- Search for
OneSignalNotificationServiceExtension
as the CATEGORY - Select Start

Console debugging configuration
contents
property if sending from the Create message API). In this example, the payload is:
cURL

Console debug output example