SDK Integration
Last updated
Was this helpful?
Last updated
Was this helpful?
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.
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.
To enable push notifications, Netmera uses APNS (Apple Push Notification Service). Follow these steps to create and upload the required certificate:
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.
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.
You can integrate the Netmera SDK into your project using either Cocoapods or Swift Package Manager (SPM). Follow the instructions for your chosen method.
Open your project's Podfile
and add the relevant lines for the Netmera features you need:
Run pod install
command in your terminal.
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.
In your AppDelegate.swift file, import the necessary Netmera modules based on the features you plan to use:
Add the Netmera-Config.plist
file to your project.
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.
Additional Configuration for On-Premises Customers
If you are using Netmera in an on-premises environment, include the following in your Netmera-Config.plist
:
Call the Netmera initialization method in your application(_:didFinishLaunchingWithOptions:)
method:
1. Add NetmeraNotification to Your Podfile
To enable push notifications, add the following line to your Podfile and install it for your app target:
Run the following command in your terminal to install:
2. Request Push Notification Authorization
Request push notification permission from the user by calling the following method in an appropriate place in your code:
1. Enable Push Notifications in Xcode
To enable push notifications for your app, follow these steps:
Open your Xcode project.
Navigate to Signing & Capabilities.
Under Capability, select Push Notifications.
2. Implement UNUserNotificationCenterDelegate Methods
In your AppDelegate
, you need to implement the necessary methods for handling push notifications. Add the following code to your didFinishLaunchingWithOptions
method:
Then, implement the following delegate methods to handle the push notifications:
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.
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
Log in to with your Apple Developer account.