Media Push

Rich Media Integration for Versions 3.14.4 and higher

Starting from Netmera SDK version 3.14.4, it is no longer necessary to include a bridging header file in order to utilize iOS 10 media push features.

Step 1: Create New Target

Make sure you have Xcode 8 or a higher version installed. If not, upgrade your Xcode installation to use iOS10 media push on your application.

First you should create a new Notification Service Extension to your application. In order to do that, you should Follow those steps:

  • Open Xcode and navigate to File -> New -> Target

  • Choose Notification Service Extension frrom the available options.

Switching Back to Debugging

If you accidentally "Activate", you can return to debugging your app using Xcode, which is located alongside the play button.

Step 2: Add your Project to Pod File

Remove the Objective-C Bridging Header file from the project and add:

NetmeraNotificationServiceExtension in the NotificationService.swift file.

Link the Netmera.framework to the Notification Content Extension. Add the Notification Content Extension as a new target in your Podfile by including the following lines,

target 'your_service_extension_target_name' do

 pod "Netmera/NotificationServiceExtension"

end

Warning:

After adding the previous line to your Podfile, pod update is used.

Step 3: Add Codes to Notification Service Extension Class

A new class named "NotificationService" will be created, which should be extended from the NetmeraNotificationServiceExtension class. Your NotificationService class should look like the following.

class NotificationService : NetmeraNotificationServiceExtension {

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

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

}

Step 4: Info.plist Configuration

To receive HTTP media contents, follow these steps.

  1. Click Info.plist under NotificationService Extension

  2. Add App Transport Security Settings

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

<?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>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.service</string>
        <key>NSExtensionPrincipalClass</key>
        <string>$(PRODUCT_MODULE_NAME).NotificationService</string>
    </dict>
</dict>
</plist>

Completed

The integration process for Media Push has been successfully completed, and you are now ready to commence testing and further enhancements.

Troubleshooting

Service extension target settings

  • In the service extension target settings, if the minimum deployment version is set higher than the device's version, it may result in the inability to retrieve images. You may check the following location to see it in XCode.

Copy only when installing

  • Check if "Copy only when installing" is turned off for your main target. To do this:

  1. Select your main target.

  2. Go to "Build Phases."

  3. Expand "Embed App Extensions."

  4. Ensure that "Copy only when installing" is NOT checked. If it is checked, please uncheck it.

Last updated