SDK Integration
This SDK is developed in Swift and supports integration with Swift Package Manager (SPM). For new projects, we recommend integrating the Netmera Swift SDK to optimize functionality and streamline development.
Onboarding Checklist: Swift
Below is the Onboarding Checklist for Swift and Flutter. Follow each item in the list to ensure all essential steps in your Netmera onboarding process are completed successfully.
How to Integrate Netmera Swift SDK: A Complete Video Guide
Step 1: Create an Apple Push Notification Certificate
To enable push notifications, Netmera uses APNS (Apple Push Notification Service). Follow these steps to create and upload the required certificate:
Log in to developer.apple.com with your Apple Developer account.
Generate an Apple Push Notification Certificate for your app.
Export the certificate using Keychain Access on your Mac.
Upload the exported certificate to the Netmera panel by navigating to Developer > Push Backends > iOS in the left menu.
Push Notification Certificate Types
p8 Certificate
For P8 certificates, select both Sandbox & Production environments since a single P8 certificate works for both. If only one environment (e.g., Production) is selected, a BadEnvironmentKeyInToken error occurs when testing in the sandbox.
p12 Certificate
Create separate certificates for each environment.
Apps Built from Xcode
When building apps from Xcode, set the certificate type to dev.
Production & Test
Sandbox & Production
p8
This single certificate type works for both environments when using the p8 format.
Production
Production
p12
Separate certificates should be created for different environments when using the p12 format.
Test
Sandbox
p12
Separate certificates should be created for different environments when using the p12 format.
App Built Directly from Xcode
Development (dev)
p8/p12
Must be set to dev.
Creating an APNS .p8 Certificate (Recommended)
Using the APNS .p8 certificate is highly recommended for the following reasons:
The .p8 certificate is mandatory for enabling features such as Live Activities.
Unlike .p12 certificates, a single .p8 certificate can manage push notifications for multiple applications.
The .p8 certificate does not require yearly renewal.
The .p8 certificate is easier to generate via the Apple Developer Portal and only needs to be downloaded once.
Creating an APNS .p12 Certificate
Step 2: Integrate SDK into Your Project
You can integrate the Netmera SDK into your project using either Swift Package Manager (SPM) or Cocoapods. Follow the instructions for your chosen method.
Swift SDK Modules – Select the modules you need
Netmera Swift SDK is modular. Include only the modules your app needs in the appropriate targets.
NetmeraNotification
Manages push permission flow, token registration, delegate methods, and deep link handling.
App
NetmeraAnalytic
Allows sending analytics events to Netmera.
App
NetmeraAnalyticsAutotracking
Tracks screen transitions and user actions automatically.
App
NetmeraNotificationInbox
Enables the push inbox feature.
App
NetmeraLocation
Provides location–based functionalities.
App
NetmeraGeofence
Enables geofence monitoring.
App
NetmeraAdvertisingId
Provides access to IDFA/IDFV (AdTracking).
App
NetmeraLiveActivity
Enables ActivityKit-based Live Activities (iOS 16.1+).
App
NetmeraNotificationServiceExtension
Required for Media / Rich Push rendering.
Notification Service Extension
NetmeraNotificationContentExtension
Enables custom push UIs such as Carousel & Slider Push.
Notification Content Extension
Option 1: Integrating with Swift Package Manager (SPM)
Open Project Settings and navigate to Package Dependencies. Click the "+" button to add a new dependency.

Enter the following repository URL in the search bar. The package details will load automatically.
Click "Add Package" to complete the integration.

Option 2: Integrating with Cocoapods
Make sure your Podfile includes the necessary Netmera SDK modules, along with any other dependencies you need. Here’s an example:
After listing all your pod dependencies, add the following post_install block to the end of your Podfile.
Run
pod installcommand in your terminal.
Step 3: Setup Netmera
Import the Netmera Framework
In your AppDelegate.swift file, import the necessary Netmera modules based on the features you plan to use:
Initialize Netmera
1. Configure with Netmera Plist
Add the
Netmera-Config.plistfile to your project.Ensure the file is included in the correct Target Membership (main target + extensions if applicable).

Replace the placeholders (
{API_KEY},{AppGroupName}, etc.) in the following code snippet with your actual values:
To obtain your SDK API Key, follow these steps:
Go to the Netmera Panel.
Navigate to Developer > API > SDK API Key.
Copy your SDK API Key from this section.
Use this key to replace the {API_KEY} placeholder in either the Netmera-Config.plist or your programmatic setup.

Further Plist Configurations
Source Code View
Property List View

Additional Configuration for On-Premises Customers
If you are using Netmera in an on-premises environment, include the following in your Netmera-Config.plist:
For Multiple Targets
If your project contains multiple targets you can manage this by copying the correct configuration file during build time.
Add the following script as a Run Script Phase in your app target:
This ensures that the correct Netmera-Config.plist file is bundled based on the active build configuration.
⚠️ Make sure the script runs before the app is built, and that Netmera-Config.plist is included in the target bundle.
2. Initialize Netmera
Call the Netmera initialization method in your application(_:didFinishLaunchingWithOptions:) method:
Optional: Initialization Callback
Important Note: To use the initialization callback method, make sure you are using Swift SDK v4.19.0 or later.
Use the initialization callback to listen for init session results, including available user segments and initialization errors.
Add the following code to handle init session success and failure:
Network Request Callback
Important Note: To use the network request callback, make sure you are using Swift SDK v4.27.0 or later.
You can watch the network requests the SDK sends and see whether each one succeeded or failed. Register one callback with Netmera.setNetworkRequestCallback(_:). Pass nil to remove the callback.
To remove the callback:
Failure Details
failure.statusCode: the HTTP status code, ornilwhen there was no HTTP response (for example, offline or timeout).failure.errorCode: Netmera's own error code when the server returns one, otherwise the HTTP status code, or the SDK's own error code when there was no HTTP response.failure.message: the server's error message.
Retries
A failed attempt that the SDK will retry is reported with
failure.willRetry == true. Useresult.isFinalto handle only final outcomes.
Threading
The callback runs on a background queue, one result at a time. Switch to the main queue before updating UI.
Configuring Multiple Environments
If you want to configure multiple environments for your app (e.g., testing and production), follow the steps below:
Step 1: Copy Netmera-Config.plist Files
Copy the Netmera-Config.plist file for the development environment into the Dev directory.
Copy the Netmera-Config.plist file for the production environment into the Prod directory.
When adding these files to your Xcode project, uncheck Copy items if needed and ensure that no targets are selected under Add to targets.

Step 2: Add Run Script Phase
In Xcode, select your app target.
Go to the Build Phases tab and add a New Run Script Phase.
Name the new phase something like "Setup Netmera Environment Netmera-Config.plist".
Position this phase before the Copy Bundle Resources step.
Step 3: Implement Shell Script for Config File Selection
In the new Run Script Phase, implement the following shell script to copy the correct Netmera-Config.plist based on the build configuration (Debug or Release):

The following script checks if the development and production versions of Netmera-Config.plist exist in their respective directories, and based on the build configuration (Debug or Release), it will copy the correct configuration file into the app bundle.
Swift SDK Integration Complete
The Swift SDK integration is complete, and your devices are now ready to receive the following types of push notifications from the Netmera Dashboard:
Standard Push Notifications
Interactive Push Notifications
Widgets
Push Notifications with Deeplinks
Last updated
Was this helpful?