Netmera Developer Guide
Ask or search…
K
Comment on page

iOS SDK Integration

Quick Steps Guidelines
Step 1: Enable Push Notifications for Your Project
Obtain your Apple Push Notification Certificate from developer.apple.com and add it to your Netmera panel on Developer > Push Backend.
Step 2: Integrate SDK into Your Project
Integrate Netmera SDK with CocoaPods or choose the manual integration guide.
Step 3: Setup Netmera
Initialize Netmera by adding the two lines of code below in your application delegate class.
Step 4: Request Push Notification Authorization
Request push notification authorization from user by calling the methods below.
Step 5: Enable Push Notifications
Enable push notifications for your app by navigating to Signing & Capabilities > Capability > Push Notifications on Xcode.
iOS SDK integration completed
👏

Video Guide: Watch our Netmera iOS Integration Video

To get a visual guide on how to integrate Netmera into your iOS app, you may watch our iOS integration video below.
Netmera iOS Integration

Step 1: Enable Push Notifications for Your Project

We send push notifications using APNS (Apple Push Notification Service). Therefore, you need to obtain an Apple Push Notification Certificate from www.developer.apple.com using your account. Once you have the certificate, you should export it using Keychain Access and add it to the iOS page in the panel's left menu under Developer > Push Backend.
Important Notes on Bundle ID:
Make sure to add the certificate generated with the bundle ID of your project to the panel, and set the bundle ID of your project in the panel as well. The bundle ID of your project, the bundle ID of the certificate, and the bundle ID set in the panel should all match.
In case of having problems sending push notifications when you build from Xcode:
Check the certificate type on the Developer > Backend Transfer > iOS page in the menu on the left. If you downloaded the app from the store or are testing it via TestFlight, the certificate type must be "prod". If you are compiling from Xcode, the certificate type must be selected as "dev".

Step 2: Integrate SDK into Your Project

CocoaPods is the preferred method for incorporating Netmera into your project. We recommend using CocoaPods for integrating Netmera into your project.
CocoaPods simplifies dependency management and streamlines the integration process. However, if you prefer not to use CocoaPods, you can manually integrate Netmera into your project.

Integration with CocoaPods

Add the following line to your Podfile.
pod 'Netmera'
Without AdId Support:
pod 'Netmera/NetmeraWithoutAdId'

iOS SDK Manual Integration (optional)

Follow the steps outlined in our iOS Manual Integration document to manually integrate Netmera into your project.
Click for Manual Integration Steps
For manual integration of Netmera, please follow these steps:
  1. 1.
    Access the Netmera SDK by downloading the framework.zip file from this link: Download Netmera SDK
  2. 2.
    Add Netmera to your project by selecting the plus sign (+) in the 'Framework, Libraries, and Embedded Content' field within your project's target. Choose the following files:
    • Netmera.xcframework
    • NetmeraAdId.xcframework
    • NetmeraCore.xcframework
  1. 3.
    Once you've added the frameworks, initialize Netmera by following the steps outlined in our documentation: iOS SDK Integration
  2. 4.
    For information on Receiver Methods, enabling/disabling Popups and In-App Messages, Media Push, Carousel/Slider, and Thumbnail Push, please refer to this link: iOS Push
  3. 5.
    Keep in mind that you'll need to create a service extension for Media Push and a content extension for Carousel/Slider and Thumbnail Push.
  4. 6.
    After creating the service extension and content extension, add the relevant frameworks as shown in the provided images.
Ensure that the general settings of your project's targets match the configurations depicted in the images.
This manual integration process will help you successfully incorporate Netmera into your iOS project.

Step 3: Setup Netmera

Initialize Netmera by adding the following two lines of code in your application delegate class.
Swift
Objective-C
import UIKit
// Import Netmera framework
import Netmera
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
//Start Netmera instance
//This must be called before -application:didFinishLaunchingWithOptions: method returns
Netmera.start()
// For On-premise setup
// Netmera.setBaseURL("YOUR PANEL DOMAIN URL")
// This can be called later, see documentation for details
Netmera.setAPIKey("YOUR_CLIENT_API_KEY")
Netmera.setLogLevel(NetmeraLogLevel.debug)
return true
}
Purpose of Netmera.setLogLevel(NetmeraLogLevel.debug):
This method is designed to control the level of logging for Netmera. It offers three different usage options, and adding this method is optional:
  • debug: This setting enables you to view Netmera logs. It is useful when you want to monitor detailed logs for debugging purposes.
  • error: With this option, only error logs are displayed. It is helpful when you specifically need to focus on identifying and addressing issues or errors.
  • none: Use this setting when you don't want any Netmera-related logs to appear. It is suitable for situations where you prefer a clean log output without Netmera logs.
You can choose the appropriate log level based on your needs, and adding this method to your code is optional, depending on whether you want to monitor and control Netmera's logging behavior.
#import "AppDelegate.h"
// Import Netmera framework
#import <Netmera/Netmera.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Start Netmera instance
// This must be called before -application:didFinishLaunchingWithOptions: method returns
[Netmera start];
// For On-premise setup
// [Netmera setBaseURL:@"YOUR PANEL DOMAIN URL"];
// This can be called later, see documentation for details
[Netmera setAPIKey:@"YOUR_SDK_API_KEY"];
[Netmera setLogLevel:(NetmeraLogLevelDebug)];
return YES;
}
Purpose of Netmera.setLogLevel(NetmeraLogLevel.debug)
This method is designed to control the level of logging for Netmera. It offers three different usage options, and adding this method is optional:
  • debug: This setting enables you to view Netmera logs. It is useful when you want to monitor detailed logs for debugging purposes.
  • error: With this option, only error logs are displayed. It is helpful when you specifically need to focus on identifying and addressing issues or errors.
  • none: Use this setting when you don't want any Netmera-related logs to appear. It is suitable for situations where you prefer a clean log output without Netmera logs.
You can choose the appropriate log level based on your needs, and adding this method to your code is optional, depending on whether you want to monitor and control Netmera's logging behavior.
Warning: Please make sure you get the API key value from the relevant panel.
YOUR_SDK_API_KEY: You can get that API key from Developers > API > SDK API Key from your web panel.
If there is an on-premise installation:
Call the method Netmera.setBaseURL("YOUR PANEL DOMAIN URL") on the previous line before Netmera.setAPIKey method.

Step 4: Request Push Notification Authorization

Request push notification authorization from user by calling the following method.
Swift
Objective-C
Netmera.isEnabledReceivingPushNotifications()
[Netmera isEnabledReceivingPushNotifications];
Swift
Objective-C
// Call this method with needed notification types
Netmera.requestPushNotificationAuthorization(forTypes: [.alert, .badge, .sound])
Calling this method will immediately prompt the push notification permission dialog to the user. Make sure to call this method after informing the user about how your application will utilize push notifications.
If push permission requested from Apple or another push provider, you should call this method under that request. Otherwise, interactive push buttons will not be handled by Netmera SDK.
// Call this method with needed notification types
[Netmera requestPushNotificationAuthorizationForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound];
Calling this method will immediately prompt push notification permission dialog to user, therefore it's important for you to call this method after you informed user about how your application will utilize push notifications.
If push permission requested from Apple or another push provider, you should call this method under that request. Otherwise, interactive push buttons will not be handled by Netmera SDK.

Step 5: Enable Push Notifications

Enable push notifications for your app by navigating to: Signing & Capabilities > Capability > Push Notifications.

Email Subscription Preferences

Following methods in iOS are used for managing email subscription preferences within the Netmera mobile SDK. Here's an explanation of each method:
  1. 1.
    Netmera.isAllowedEmailSubscription()
    • This method is used to check whether the user has allowed email subscriptions through the Netmera SDK. It returns a Boolean value.
  2. 2.
    Netmera.setAllowedEmailSubscription(true) Netmera.setAllowedEmailSubscription(false)
    • This method is used to set the user's preference for email subscriptions within the Netmera SDK.

iOS SDK integration completed
👍

iOS SDK integration has been successfully completed, and your devices are now ready to receive the following types of push notifications sent via the Netmera Dashboard:
  1. 1.
    Standard Push Notifications
  2. 2.
    Interactive Push Notifications (If you've configured and published them using the Dashboard)
  3. 3.
    Push Notifications with Web View Content
  4. 4.
    Push Notifications with Deeplinks (If your application supports URL Scheme-based deeplinks and you've configured the application's URL Scheme in the Dashboard.)

Troubleshooting

If you are sending push notifications from the Netmera Dashboard but not receiving them on your devices, please follow the steps described in Apple's Technical Note about Troubleshooting Push Notifications. This will help you verify if your device is successfully registering and receiving push notifications.