Netmera Developer Guide
Netmera Docs
  • Netmera Developer Guide
  • Platforms
    • iOS
      • New iOS (Swift)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Widget and In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Advertising ID
        • Changelog
      • Former iOS (Objective-C)
        • SDK Integration
        • Push Notifications
          • Delegate Methods
          • Push Payload Receivers
          • Widget and In-App Messages
          • Customizing In-App Messages
          • Media Push
          • Carousel, Slider and Thumbnail Push
          • Custom Web View Presentation
          • Push Icon
        • Live Activities
        • Deep Linking
          • Custom Deep Links
        • Sound & Vibration
        • Push Inbox
        • Events
        • Geofence & Location
        • User Attributes & Preferences
        • Data Transfer
        • Advertising ID
        • SSL Pinning
        • Changelog
    • Android
      • SDK Integration
        • Huawei Integration
        • Huawei Message Receipt
        • Custom FCM and HMS Implementations
        • Android Integration FAQs
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
        • Custom Web View Presentation
        • Push Icon
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
        • Background Location Permission
      • User & Attributes
      • Data Transfer
      • Advertising ID
      • App Tracking
      • SSL Pinning
      • Changelog
    • Web
      • SDK Setup
        • Self-Hosted SDK Setup
      • Mobile Web Push for iOS
      • Deep Linking
        • Custom Deep Links
      • Events
      • User & Attributes
    • React Native
      • SDK Integration
      • Push Notifications
        • Widget and In-App Messages
        • Push Callbacks
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • Changelog
    • Flutter
      • SDK Integration
        • Custom FCM and HMS Implementations
      • Push Notifications
        • Push Notification Permissions
        • Widget and In-App Messages
        • Flutter iOS Media Push
      • Deep Linking
        • Custom Deep Links
      • Sound & Vibration
      • Push Inbox
      • Events
      • Geofence & Location
      • User & Attributes
      • SSL Pinning
      • Changelog
    • Cordova
      • SDK Integration
      • Push Notifications
      • Sound & Vibration
      • Push Inbox
      • Events
      • User & Attributes
    • Unity
      • SDK Integration
      • Sound & Vibration
      • Events
      • User & Attributes
      • Changelog
  • Integrated Modules
    • Optimove
    • Adjust
    • Mixpanel
    • IYS Integration
    • VIA Integration
      • Short URL Consent Requests
      • OTP Consent Requests
        • OTP Confirmation Completion
      • VIA Email Rejection Link Generation
      • ETK Rejection via SMS
  • API Documentation
    • REST API
      • Setup
      • Notifications
      • Events
      • User & Device Management
      • Inbox Feature
      • GDPR
      • Error Responses
  • FAQs
    • Push Notifications FAQs
Powered by GitBook
On this page
  • Step 1: Create a New Notification Service Extension
  • Optional: Integrating Notification Service Extension Using CocoaPods
  • Step 2: Add App Group Capability
  • Step 3: Add Your AppGroupName
  • Step 4: Select Targets in Target Membership
  • Step 5: Select Main Project & Service Extension
  • Step 6: Receiving Http Media Contents
  • Troubleshooting

Was this helpful?

  1. Platforms
  2. iOS
  3. New iOS (Swift)
  4. Push Notifications

Media Push

Step 1: Create a New Notification Service Extension

To create a new Notification Service Extension to your application:

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

  2. Choose Notification Service Extension

  3. A 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()
  }
}

Optional: Integrating Notification Service Extension Using CocoaPods

If you're using a Podfile for dependency management, follow these steps along with the rest of the steps from 1 to 5:

  • Add NetmeraNotificationServiceExtension in your Podfile:

  • Install it to your extension target.

pod 'NetmeraNotificationServiceExtension'

Note: If you're not using CocoaPods, you can skip this step.

Step 2: Add App Group Capability

You need to add the App Groups capability to both your main app target and your Service Extension target via the Signing & Capabilities section.

  1. Open your project in Xcode.

  2. Go to the Signing & Capabilities tab.

  3. Select App Groups from the list.

  1. Add or select an existing App Group (e.g., group.example.app).

  2. Repeat steps 2–6 for your Service Extension target.

  1. Add the App Group name under the appropriate key (e.g., NetmeraAppGroup) to match the App Group you added in Xcode.

  2. Open the Netmera-Config.plist file in your project.

Step 3: Add Your AppGroupName

  1. Add your AppGroupName in your Netmera-Config.plist.

<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 4: Select Targets in Target Membership

  1. Select all three targets in the Target Membership section on the right.

Step 5: Select Main Project & Service Extension

  1. Go to Notification Service > Target Membership.

  2. Select both the main project and the service extension.

Step 6: Receiving Http Media Contents

Sample Service Extention Info.plist

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

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

  1. Click Info.plist under Notification Service Extension,

  2. Add App Transport Security Settings,

  3. Add Allow Arbitrary Loads under App Transport Security Settings and set it to YES.

Troubleshooting

If push notifications do not display correctly:

  1. Go to Build Settings > Runpath Search Paths in the extension target. Ensure the following paths are added:

@executable_path/../../Frameworks  
@executable_path/Frameworks  
@loader_path/Frameworks
  1. Remove the default label in MainInterface.

PreviousWidget and In-App MessagesNextCarousel, Slider and Thumbnail Push

Last updated 16 days ago

Was this helpful?

If you don't have a Netmera-Config.plist see the step here .

1. Configure with Netmera Plist