Media Push

Step 1: Create New Target

  1. Ensure you are using Xcode 8 or a higher version.

  2. In Xcode, navigate to File > New > Target.

  1. Select Notification Service Extension from the available options and create the new target.

Switching Back to Debugging

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

Step 2: Update Pod File

  1. Remove the Objective-C Bridging Header from your project.

  2. Add the following to your Podfile to link the Netmera.framework to the Notification Content Extension.

  3. Run pod update to install the dependency.

target 'your_service_extension_target_name' do
  pod "Netmera/NotificationServiceExtension"
end

Step 3: Add Code to the Notification Service Extension Class

  1. Create a new class NotificationService that extends NetmeraNotificationServiceExtension.

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

  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>

Troubleshooting

Check Service Extension Target Settings

  • Ensure the minimum deployment version of your service extension matches or is lower than the device’s iOS version.

Ensure 'Copy only when installing' is Unchecked

  • In Xcode, go to Build Phases and expand Embed App Extensions. Ensure that Copy only when installing is unchecked for your main target.

  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

Was this helpful?