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 the users by calling the methods below.

Step 5: Configure your Xcode Settings for Enabling 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.

Below you may also see the written steps of creating an Apple Push Notification Certificate.

Creating an Apple Push Notification Certificate

You may also see these steps in the video above (iOS Integration Developer Guide Video).

  1. Log in to https://developer.apple.com with your Apple ID.

  2. Click on "Certificates, Identifiers & Profiles."

  3. Press the '+' button and select "Apple Push Notification service SSL" (Sandbox & Production), then proceed.

  4. Choose your App ID and proceed.

  5. Follow general instructions to generate a Certificate Signing Request (CSR) file and upload it on the next page.

  6. Download the generated certificate and add it to your Keychain.

  7. Right-click on the certificate signed with your private key and export it.

Uploading the Created Push Certificate to the Panel:

  1. Go to Developers > Push Backends > IOS.

  2. In the opened window under the APNS Certificate section, upload the created certificate.

  3. Enter the value used when extracting the certificate, which corresponds to the Bundle ID of your application, into the Topic (Bundle ID) field.

  4. Optionally, you can create a password for your certificate.

  5. The Certificate Type field should be set to "Prod" if your application is live, ensuring users can receive push notifications. For testing environments during developers' testing, when the build is obtained with a cable, the certificate type should be set to "Dev" for successful push tests.

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. Access the Netmera SDK by downloading the framework.zip file from this link: Download Netmera SDK

  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. Once you've added the frameworks, initialize Netmera by following the steps outlined in our documentation: iOS SDK Integration

  2. 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. 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. 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.

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.

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 the user by calling the following method.

// 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.

isEnable Method:

With this method, you can determine whether your users have granted permission for notifications.

Netmera.isEnabledReceivingPushNotifications()

Step 5: Configure Xcode Push Notifications Settings

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

Email Subscription Preferences (optional)

The following methods in iOS are used for managing email subscription preferences within the Netmera mobile SDK. Here's an explanation of each method:

  • This method is used to check whether the user has allowed email subscriptions through the Netmera SDK. It returns a Boolean value.

Netmera.isAllowedEmailSubscription()
  • This method is used to set the user's preference for email subscriptions within the Netmera SDK.

Netmera.setAllowedEmailSubscription(true)
Netmera.setAllowedEmailSubscription(false)

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. Standard Push Notifications

  2. Interactive Push Notifications

  3. Push Notifications with Deeplinks ( iOS Deeplink)

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.

Last updated