Using Carousel/Slider and Thumbnail 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 Content Extension to your application. In order to do that, follow these steps:

  • On Xcode click File -> New -> Target and choose Notification Content Extension.

  • New class named NotificationViewController will be created. It should be extended from NetmeraNotificationContentExtension class.

Your NotificationContent class should look like the following:

import UserNotifications
import UserNotificationsUI
import NetmeraNotificationContentExtension

class NotificationViewController: NotificationContentExtension {
  override func viewDidLoad() {
    super.viewDidLoad()
  }

  override func didReceive(_ notification: UNNotification) {
    super.didReceive(notification)
  }
}
  • After that enable App Groups from the Capabilities for both of your application and NotificationContent extension.

  • Add bundle_identifier.group_name to your app groups.

Step 2

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

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 Content Extension, you should select both the Main Project and the Content Extension in the Target Membership section for NotificationViewController.

Step 5

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

  1. Click Info.plist under NotificationContentExtension

  2. Add App Transport Security Settings.

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

If you want to add slide to Carousel property: UNNotificationExtensionUserInteractionEnabled must be set YES.

  1. Add UNNotificationExtensionCategory as an array to the info.plist items, and include NetmeraGeneral and NetmeraCarousel.

When adding UNNotificationExtensionCategory as an array in the info.plist, please note that this field will not appear automatically and is not selectable from the standard options. You will need to manually enter and configure this field within the info.plist file.

Here’s a formatted example of the info.plist source code for implementing a carousel in the notification extension in NSExtensionAttributes:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>UNNotificationExtensionUserInteractionEnabled</key>
            <true/>
            <key>UNNotificationExtensionCategory</key>
            <array>
                <string>NetmeraCarousel</string>
                <string>NetmeraGeneral</string>
            </array>
            <key>UNNotificationExtensionInitialContentSizeRatio</key>
            <real>1</real>
        </dict>
        <key>NSExtensionMainStoryboard</key>
        <string>MainInterface</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.content-extension</string>
    </dict>
</dict>
</plist>

If You Use Podfile

In your pod file, you should add NetmeraNotificationContentExtension and install to your extension target like this. You should complete all the steps from 1-5 if you are using Podfile for your integration.

pod "NetmeraNotificationContentExtension"

Default label in MainInterface should be deleted.

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