Using Media Push

This SDK is developed using the Swift programming language. Unlike our existing iOS SDK, we provide integration support with Swift Package Manager (SPM). You can take advantage of Swift's expressive and intuitive nature, enabling you to create sophisticated applications with ease.

Step 1

Create a new Notification Service Extension to your application. In order to do that, follow these steps:

  • On Xcode click File > New > Target. Choose Notification Service Extension

  • Choose Notification Service Extension

  • After you selected Notification Service Extension new class named NotificationService will be created. It should be extended from MyNetmeraNotificationServiceExtension class. Your NotificationService class should look like the following:

import UserNotifications
import NetmeraNotificationServiceExtension

class NotificationService: NotificationServiceExtension {
  override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
    super.didReceive(request, withContentHandler: contentHandler)
  }

  override func serviceExtensionTimeWillExpire() {
    super.serviceExtensionTimeWillExpire()
  }
}

Step 2

Add your AppGroupName in your Netmera-Config.plist. If you don't have a Netmera-Config.plist see the step here Configuring with Netmera Plist.

<key>app_group_name</key>   
<string>{AppGroupName}</string>
<key>sdk_params</key>
    <dict>
        <key>app_group_name</key> // add this line in Config.plist
        <string>{YourAppGroupName}</string> // add this line in Config.plist
        <key>use_ui_scene</key>
        <false/>
        <key>api_key</key>
        <string>{API_KEY}</string>
        <key>custom_events</key>
        <array>
            <string>{YourCustomEvent}</string>
        </array>
    </dict>

Integrating Netmera Notification Service Extension Using CocoaPods

If you've integrated using CocoaPods, in your pod file, add NetmeraNotificationServiceExtension and install to your extension target like this.

pod 'NetmeraNotificationServiceExtension'

Step 3

After creating the Netmera-Config.plist, you need to select all three targets in the Target Membership section on the right side.

Step 4

Under your Service Extension, you should select both the main project and the service extension in the Target Membership section for Notification Service.

Step 5

If you want to allow your application to receive http media contents:

  • Click Info.plist under NotificationService Extension

  • Add App Transport Security Settings

  • Under App Transport Security Settings add Allow Arbitrary Loads and set it YES.

Troubleshooting

If you're still unable to successfully view the push notification after following the above steps, check the following:

For the target of the extension, go to Build Settings > Runpath Search Paths and ensure the following paths are added:

@executable_path/../../Frameworks
@executable_path/Frameworks
@loader_path/Frameworks

Last updated