The Netmera Developer Hub

Welcome to the Netmera developer hub. You'll find comprehensive guides and documentation to help you start working with Netmera as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Push Notifications

Advanced Push Notification Management

Push Notification Delegate Methods

Unless you need special use cases, Netmera handles all UIApplicationDelegate methods related to remote notifications, so you do not need to implement them in your App Delegate class.

However, if your application has use cases that require a custom implementation on remote notification delegate methods, you can freely implement them and perform your specific logic inside these delegate methods.

You can find detailed information about the delegate methods related to push notifications in UIApplicationDelegate Protocol Reference

Accessing NetmeraPushObject Inside Delegate Methods

SDK provides [Netmera recentPushObject] method which returns the object representation of the remote notification payload. You can use this method to access the NetmeraPushObject instance corresponding to the remote notification inside your UIApplicationDelegate methods.

Custom Web View Presentation

By default, Netmera provides a good looking UI when a web view content should be shown on push/popup notification action and automatically presents the web view content.

If you have a standard web view presentation flow and want to use it, or want to implement your own presentation flow, you can do this by implementing -handleWebViewPresentation: method inside your NetmeraPushDelegate object and calling [Netmera loadWebViewContentInWebView:] method inside the delegate method. Here is a simple stupid sample implementation (note that below implementation won't work itself, you should implement your own presentation flow):

#import <Netmera/Netmera.h>

@interface YourClass <NetmeraPushDelegate>
@end
  
@implementation YourClass
  
- (instancetype)init {
  self = [super init];
  if(self) {
    // Make sure you have set your object as the push delegate of Netmera SDK!
    [Netmera setPushDelegate:self];
  }
  return;
}

- (void) handleWebViewPresentationForPushObject:(NetmeraPushObject *)object {
  // Present your web view UI
  YourWebViewController *vc = [[YourWebViewController alloc] init];
  UIViewController *rootVC = [UIApplication sharedApplication].keyWindow.rootViewController;
  [rootVC presentViewController:vc animated:YES completion:nil];
  
  // Load web view content inside the presented webView
  [Netmera loadWebViewContentInWebView:vc.webView];
}

@end
import Netmera

class YourClass {
    init() {
        
        // Make sure you have set your object as the push delegate of Netmera SDK!
        Netmera.setPushDelegate(self as! NetmeraPushDelegate)
        
        return
    }
}

func handleWebViewPresentation(for object: NetmeraPushObject!) {
        
        let vc = TableViewController()
        let rootVC: UIViewController? = UIApplication.shared.keyWindow?.rootViewController
        rootVC?.present(vc , animated: true) { _ in }
        // Load web view content inside the presented webView
        Netmera.loadWebViewContent(in: vc.webView)
        
}

Whenever SDK needs to present a web view content (when popup notification is received, when user open a push notification including web view content, etc.), SDK will call -handleWebViewPresentation: method if it has a NetmeraPushDelegate object previously set using [Netmera setPushDelegate:] method, and that delegate object has implemented -handleWebViewPresentation: method.

Otherwise, SDK will automatically present the web view content using it's internal presentation flow.

Disable/Enable Popups and In App Messages

When a popup notification or an in app message is received by the SDK, it immediately presents the corresponding web view content if the application is in foreground state. If application is in background state when popup is received, SDK presents the web view content whenever application comes to foreground state.

You may want to disable this immediate presentation behavior for cases like when your users watch a video, when they are in the middle of their favorite game level, or when they are about to finish purchasing their order. You use the following two methods to manage this process:

// Call this method to disable immediate popup presentation
[Netmera setEnabledPopupPresentation:false];

// Call this method to re-enable immediate popup presentation
[Netmera setEnabledPopupPresentation:true];
// Call this method to disable immediate popup presentation
Netmera.setEnabledPopupPresentation(false)

// Call this method to re-enable immediate popup presentation
Netmera.setEnabledPopupPresentation(true)

In order to use in app messages, you should integrate the SDK version 3.4.0 or higher.

If you want to customize in app messages, you should add the plist inside the Headers folder in Netmera Framework.

<?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>TitleColor</key>
    <string></string>
    <key>TextColor</key>
    <string>0</string>
    <key>BackgroundColor</key>
    <string>16777215</string>
    <key>CancelButtonColor</key>
    <string>16777215</string>
    <key>CancelButtonBackgroundColor</key>
    <string>0</string>
    <key>TitleFont</key>
    <string></string>
    <key>TextFont</key>
    <string></string>
    <key>CancelButtonRadius</key>
    <string>15</string>
    <key>ShadowOpacity</key>
    <string>1</string>
    <key>BottomPaddingRatio</key>
    <string>0.01</string>
</dict>
</plist>

If a popup is received when popup presentation is disabled by your code, SDK will store it, and present whenever popup presentation is re-enabled. If multiple popup notifications are received during that period, SDK stores the most recent notification, and present only that one.

If you want to recieve popups or in app messages while application is closed and killed, you should enable Remote Notifications at Background Modes from Capabilities.

Also device cannot recieve popups or in app messages while application is closed and killed while low battery mode is on. Because that mode disable background application resfresh mode

Using iOS10 Media Push

You should build your application with Xcode 8 or higher 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:

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

After you selected Notification Service Extension new class named NotificationService will be created. It should be extended from NetmeraNotificationServiceExtension class. Your NotificationService class should look like that:

#import "Netmera/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

Or

class NotificationService : NetmeraNotificationServiceExtension {

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

}

After that, you should link Netmera.framework to that Extension. In order to do that you should add your Notification Service Extension as a target to your podfile like that;

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '9.3'

target 'Elevate' do
    pod 'Netmera'
end

target 'NotificationService' do
    pod 'Netmera'
end

After you update your pod, all linking process will be done.

As an addition, if you want to allow your application to receive http media contents, you should do that change:

  • Click Info.plist under NotificationService Extension
  • Add App Transport Security Settings
  • Under App Transport Security Settings add Allow Arbitrary Loads and set it YES

Done

You can now receive iOS 10 media pushes.

Using Carousel Push

You should build your application with Xcode 8 or higher to use iOS10 media push on your application.

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

  • On Xcode click File > New > Target.Choose Notification Content Extension
  • Choose Notification Content Extension

After you selected Notification Content Extension new class named NotificationViewController will be created. It should be extended from NetmeraNotificationContentExtension class. Your NotificationContent class should look like that:

#import <UIKit/UIKit.h>
#import <Netmera/NetmeraNotificationContentExtension.h>

@interface NotificationViewController : NetmeraNotificationContentExtension

@end
#import "NotificationViewController.h"
#import <UserNotifications/UserNotifications.h>
#import <UserNotificationsUI/UserNotificationsUI.h>

@interface NotificationViewController ()

@end

@implementation NotificationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // If you want to change the background color, uncomment the next line
    // self.view.backgroundColor = [UIColor whiteColor];
}

@end

After that, you should link Netmera.framework to that Extension. In order to do that you should add your Notification Content Extension as a target to your podfile like that;

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
platform :ios, '9.3'

target 'Elevate' do
    pod 'Netmera'
end

target 'NotificationContent' do
    pod 'Netmera'
end

After you update your pod, all linking process will be done.

Now you should create an app group from https://developer.apple.com/account/ios/identifier/applicationGroup. Lets say your group name is
group.com.yourcompany.carousel. Now you should change the info.plist of NotificationContent with the info.plist below and change the AppGroupName with your app group name.

<?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>AppGroupName</key>
  //You should change this with your app groups name <string>group.com.yourcompany.carousel</string>
  
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
    <key>CFBundleDisplayName</key>
    <string>NotificationContent</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundlePackageType</key>
    <string>XPC!</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionAttributes</key>
        <dict>
            <key>UNNotificationExtensionCategory</key>
            <string>NetmeraCarousel</string>
            <key>UNNotificationExtensionInitialContentSizeRatio</key>
            <real>0.5</real>
        </dict>
        <key>NSExtensionPrincipalClass</key>
        <string>NotificationViewController</string>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.usernotifications.content-extension</string>
    </dict>
</dict>
</plist>

After that you should enable App Groups from the Capabilities for both of your application and NotificationContent extension then add "group.com.yourcompany.carousel" to your app groups.

After you added the app groups to your app, you should set your app group name like this;

[Netmera setAppGroupName:@"group.com.yourcompany.carousel"];
Netmera.appGroupName = "group.com.yourcompany.carousel"

App Tracking

If you want to know which applications are installed on the device of a user, you should add key below to your application's info.plist. You should the scheme of the targeted applications.

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>application1</string>
        <string>application2</string>
        <string>application3</string>
    </array>

Push Notifications

Advanced Push Notification Management