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
        • 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
        • 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
      • 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 New Target
  • Step 2: Update Pod File
  • Step 3: Add Code to the Notification Service Extension Class
  • Step 4: Info.plist Configuration
  • Troubleshooting

Was this helpful?

  1. Platforms
  2. iOS
  3. Former iOS (Objective-C)
  4. Push Notifications

Media Push

PreviousCustomizing In-App MessagesNextCarousel, Slider and Thumbnail Push

Last updated 2 months ago

Was this helpful?

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

Warning:

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

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()
    }

}
#import <NetmeraNotificationServiceExtension/NetmeraNotificationServiceExtension.h>


@interface NotificationService : NetmeraNotificationServiceExtension

@end
#import "NotificationService.h"

@implementation NotificationService

- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent *contentToDeliver))contentHandler {
    [super didReceiveNotificationRequest:request withContentHandler:contentHandler];
}

- (void)serviceExtensionTimeWillExpire {
    [super serviceExtensionTimeWillExpire];
}

@end

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.

Allow Arbitrary Loads / Yes allows all HTTP loads:

NSAllowsArbitraryLoads allows all HTTP loads. This value should be set to true only if an image URL in HTTP format is being used in push notifications. Otherwise, it is not necessary and might be set as FALSE.

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