Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you are using a version lower than 2.0.0 go here.

Step 1 - Requirements

...

iOS Mobile App & Xcode

...

P12 file & password. Click here to create a P12 file.

...

AppAlias (You can get it from RMC Panel) If you do not have an account, our sales representatives will contact you. Click here.

Step 2 - Installation

2.1 Euromsg is available through CocoaPods. To install it, simply add the If you are using a version lower than 2.0.0 go here.

In this page:

Table of Contents

...

Step 1 - Requirements

iOS Mobile App & Xcode

P12 file & password or P8 File.

Click here to create a P12 file.

Click here to create a P8 file.

AppAlias (You can get it from RMC Panel) If you do not have an account, our sales representatives will contact you. Click here.

Step 2 - Installation

2.1 Euromsg is available through CocoaPods. To install it, simply add the following line to your Podfile

Code Block
pod 'Euromsg', '>= 2.0.0'

Step 3 - Add Application to RMC Panel

First, create your application from the RMC Panel. App Alias section should be unique to you. RMC makes the distinction based on this value.

...

Step 4 - Usage

Add a Notification Service Extension

NotificationServiceExtension allows your iOS application to receive rich notifications with images, buttons, and badges. It's also required for Euromessage's analytics features.

  1. In Xcode File > New > Target...

  2. Select Notification Service Extension then press Next.

    Image Modified

  3. Enter the product name as NotificationService and press Finish.

    Image Modified

  4. Do not select Activate on the dialog that is shown after selecting Finish.

    Image Modified

    By canceling, you are keeping Xcode debugging your app, instead of the extension you just created.

    If you activated by accident, you can switch back to debug your app within Xcode (next to the play button).

  5. In the project navigator, select the top-level project directory and select the NotificationSerivce target in the project and targets list. Unless you have a specific reason not to, you should set the Deployment Target to be iOS 11.

    Image Modified
  6. Open NotificationService.swift and replace the whole file's contents with the following code.

    Code Block
    languageswift
    import UserNotifications
    import Euromsg
    
    class NotificationService: UNNotificationServiceExtension {
    
        var contentHandler: ((UNNotificationContent) -> Void)?
        var bestAttemptContent: UNMutableNotificationContent?
    
        override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
            self.contentHandler = contentHandler
            bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
            Euromsg.

...

  1. configure(appAlias: "EuromsgIOSTest", launchOptions: nil, enableLog: true)
            Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler)
        }
    
        override func serviceExtensionTimeWillExpire() {
            

...

  1. guard 

...

  1. let 

...

  1. contentHandler 

...

  1. = 

...

  1. self.contentHandler 

...

  1. else 

...

  1. {
    

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.         return;
    

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1. }
    

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1. guard 

...

  1. let 

...

  1. bestAttemptContent 

...

  1. = 

...

  1. self.bestAttemptContent else {
           

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1.  

...

  1. return;
    

...

  1.  

...

  1.   

...

  1.  

...

  1.     }
            

...

  1. contentHandler(bestAttemptContent

...

  1. )
        

...

  1. }
    

...

  1. }
  2. Make sure "Copy only when installing" is not selected. First select your Main Target, then open Build Phases > Embed App Extensions. Here, deselect if Copy only when installing is selected. If this is selected, you cannot use images in your pushes.

    Image Added

Add a Notification Content Extension

Note: If you are going to use carousel push sending, you need to add this.

  1. In Xcode File > New > Target...

  2. Select Notification Content Extension then press Next.

    Image Modified

  3. Enter the product name as NotificationContent and press Finish.

    Image Modified

  4. Do not select Activate on the dialog that is shown after selecting Finish.

    Image Modified

    By canceling, you are keeping Xcode debugging your app, instead of the extension you just created.

    If you activated by accident, you can switch back to debug your app within Xcode (next to the play button).

  5. In the project navigator, select the top-level project directory and select the NotificationContent target in the project and targets list. Unless you have a specific reason not to, you should set the Deployment Target to be iOS 11.

    Image Modified

  6. Delete MainInterface.storyboard and NotificationContent.swift files. Then create a swift file named EMNotificationViewController under the NotificationContent folder. Make sure the info.plist file is the same as in this link.

    Image Modified

    Don't Create Objective-C Bridging Header

    Image Modified

  7. Open EMNotificationViewController.swift and replace the whole file's contents with the following code

Code Block
languageswift
import UIKit
import UserNotifications
import UserNotificationsUI
import Euromsg

@available(iOS 10.0, *)
@objc(EMNotificationViewController@objc(EMNotificationViewController)
class EMNotificationViewController: UIViewController, UNNotificationContentExtension {

   
let appUrl = URL(string: "euromsgExample://")
    let carouselView = EMNotificationCarousel.initView()
    var completion: ((_ url: URL?, _ userInfobestAttemptContent: [AnyHashable: Any]UNMutableNotificationContent?) -> Void)?
    
    var notificationRequestIdentifier = ""
    
    func didReceive(_ notification: UNNotification) {
        carouselView.didReceive(notification)notificationRequestIdentifier = notification.request.identifier
     }   Euromsg.configure(appAlias:  func didReceive(_ response: UNNotificationResponse,"EuromsgIOSTest", launchOptions: nil, enableLog: true)
        carouselView.didReceive(notification)
    }
    func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
        carouselView.didReceive(response, completionHandler: completion)

    }
    override func loadView() {
        completion = { [weak self] url, userInfobestAttemptContent in
            if let urlidentifier = urlself?.notificationRequestIdentifier {
                self?.extensionContext?.open(urlUNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [identifier])
                if url.scheme != self?.appUrl?.scheme, let userInfo = userInfo {UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: { notifications in
                    bestAttemptContent?.badge = Euromsg.handlePushNSNumber(pushDictionaryvalue: userInfonotifications.count)
                })
            }
            else if let url = self?.appUrlurl {
                if #available(iOSApplicationExtension self?.extensionContext?.open(url)12.0, *) {
               }     self?.extensionContext?.dismissNotificationContentExtension()
     }         carouselView.completion = completion}
        self.view = carouselView     }
}

The podfile file should be as follows. Then go to the project path through the terminal, type pod install and press enter.

...

AppDelegate.swift

Firstly import Euromsg and UserNotifications

Code Block
languageswift
import Euromsg
import UserNotifications

Add UNUserNotificationCenterDelegate to the class AppDelegate section.

Code Block
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate

Add this code under didFinishLaunchingWithOptions.

Code Block
languageswift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool  self?.extensionContext?.open(url)
            } else {
                if UNUserNotificationCenter.current().delegate = self#available(iOSApplicationExtension 12.0, *) {
                    Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true)self?.extensionContext?.performNotificationDefaultAction()
           Euromsg.registerForPushNotifications()     }
   Euromsg.askForNotificationPermission()         if}
#available(iOS 13, *) {     }
       // handlecarouselView.completion push= forcompletion
iOS 13 and later in sceneDelegate   carouselView.delegate = self
   }     self.view = carouselView
 else if let userInfo}
= launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
            Euromsg.handlePush(pushDictionary: userInfo)
}

/**
 Add if you want to track which carousel element has been selected
 */
extension EMNotificationViewController: CarouselDelegate {
    
  }  func selectedItem(_ element: EMMessage.Element) {
  return true     }

User has to accept to receive push messages. If the user accepts and the device is successfully registered to the APNS, the following method is called in AppDelegate

Code Block
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {// Add your work...
        print("Selected element is => Euromsg.registerToken(tokenData: deviceToken)
\(element)")
    }   
}

In order for push reports to be reflected on RMC, you need to add the following functions.

...

languageswift

...

The podfile file should be as follows. Then go to the project path through the terminal, type pod install and press enter.

...

Code Block
target 'YOUR_PROJECT_NAME' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
pod 'Euromsg'
post_install do |installer|
    installer.pods_project.targets.each do |target|
      Euromsg.handlePush(pushDictionary: userInfo) if target.name == 'Euromsg'
}      func application(_ application: UIApplication,   target.build_configurations.each do |config|
                didReceiveRemoteNotification userInfo: [AnyHashable : Any],
 config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
            end
      fetchCompletionHandler completionHandler: @escapingend
(UIBackgroundFetchResult) -> Void) { end
end
  # Pods for RelatedDigital
Euromsg.handlePush(pushDictionary: userInfo)
end

target 'NotificationService' do
}  # Comment the next funcline userNotificationCenter(_ center: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .badge, .sound])
    }
    
    func userNotificationCenter(_ center: UNUserNotificationCenter,
     if you don't want to use dynamic frameworks
  use_frameworks!
pod 'Euromsg'
  # Pods for RelatedDigital

end

target 'NotificationContent' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!
pod 'Euromsg'
  # Pods for RelatedDigital

end

Adding App Groups

After completing all of them, you need to add App Groups to Targets.

Add App Groups under Signing & Capabilities respectively in Targets marked on the left in the image. Type the App Groups name as group.YOUR_APP_BUNDLE_IDENTIFIER.relateddigital

...

AppDelegate.swift

Firstly import Euromsg and UserNotifications

Code Block
languageswift
import Euromsg
import UserNotifications

Add UNUserNotificationCenterDelegate to the class AppDelegate section.

Code Block
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate

Provisional Push

If you want to get provisional push permission, add the following code to didFinishLaunchingWithOptions. For iOS 12 or older version users, this function will work as askForNotificationPermission.

Code Block
languageswift
        UNUserNotificationCenter.current().delegate = self
        
       didReceive responseEuromsg.configure(appAlias: UNNotificationResponse"YOUR_APP_ALIAS", enableLog: true)
        Euromsg.registerForPushNotifications()
        Euromsg.askForNotificationPermissionProvisional()
        if #available(iOS 13, *) withCompletionHandler{
completionHandler: @escaping () -> Void) {       //  Euromsg.handlePush(pushDictionary: response.notification.request.content.userInfo)
        completionHandler()handle push for iOS 13 and later in sceneDelegate
       }

SceneDelegate.swift

Code Block
languageswift
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
 }
        else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
            Euromsg.handlePush(pushDictionary: userInfo)
       // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.}

If you do not want to get provisional push permission, add the following code to didFinishLaunchingWithOptions.

Code Block
languageswift
        UNUserNotificationCenter.current().delegate = self
        
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true)
        Euromsg.registerForPushNotifications()
   guard let _ = (scene as? UIWindowScene) else { return }
 Euromsg.askForNotificationPermission()
        if #available(iOS 13, *), {
           let userInfo// = connectionOptions.notificationResponse?.notification.request.content.userInfo {
     handle push for iOS 13 and later in sceneDelegate
      Euromsg.handlePush(pushDictionary: userInfo) }
       } else if let userInfo     } 

Send Information to RMC

Run the code below when the user successfully logs in, registers and the first time the application is opened.

P.S. : Depending on the reference of your account, one of the setEuroUserId or setEmail functions is required.

Code Block
Euromsg.setEmail(email: "test@relateddigital.com", permission: true)= launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
            Euromsg.handlePush(pushDictionary: userInfo)
        }

User has to accept to receive push messages. If the user accepts and the device is successfully registered to the APNS, the following method is called in AppDelegate

Code Block
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Euromsg.setEuroUserIdregisterToken(userKeytokenData: "1234567890"deviceToken)
        Euromsg.sync()

IYS Email Register

...

}

In order for push reports to be reflected on RMC, you need to add the following functions.

Code Block
languageswift
Euromsg.registerEmail(email: "example@email.com", permission: true)
//You can also call TACIR account as following
Euromsg.registerEmail(email: "example@commercial.com, permission: true, isCommercial: true)

Optional Parameters

setUserProperty: User to fill demographic fields

setAppVersion: You can segment according to the version your users use.

checkConfiguration: You can check the permission status of users

setPushNotification, setEmail, setPhoneNumber: You can set the permission status of users.

Code Block
Euromsg.setUserProperty(key: "Key", value: "Value")
Euromsg.setAppVersion(appVersion: "1.0.0")
let conf = Euromsg.checkConfiguration()
conf.properties?.pushPermit
conf.properties?.emailPermit
conf.properties?.gsmPermit
Euromsg.setPushNotification(permission: true)
Euromsg.setEmail(permission: true)
Euromsg.setPhoneNumber(permission: true)

Reflection of Push Campaign Revenues to RMC Panel

After clicking the incoming push notification, you need to use the following method to reflect the purchase made in the Revenue field in the RMC panel.

...

You must enter utm parameters in the Custom Parameters field on the push screen.
Ex: utm_medium=apppush;utm_source=related;utm_campaign=campaign_name
P.S: Since utm_campaign should be different each time, you can use the ID of the push campaign you created as a variable. You can optionally use the <## CAMP_ID ##> variable for this.

...

 

...

After clicking the push notification, a data will be returned to you as below.

Sample Data:

Code Block
"pushId": df73706e-1138-40f2-b687-c10c43ee8138,
"aps": {
    alert =     {
        body = Test;
        title = Test;
    };
    badge = 0;
    "content-available" = 0;
    "mutable-content" = 1;
     sound = "";
},
"pushType": Text,
"url": ,
"mediaUrl": ,
"deepLink": ,
"altUrl": ,
"utm_campaign": campaign_name,
"utm_medium": apppush,
"utm_source": related

You should handle this data just like using deeplink and send the utm parameters as event to Visilabs when the push message is clicked. You can find sample Visilabs event codes on the bottom line.

 Objective-C

Code Block
languageobjective-c
NSMutableDictionary *properties = [[NSMutableDictionary alloc] init];
[properties setObject:@"utm_campaign" forKey:@"campaign_name"];
[properties setObject:@"utm_source" forKey:@"related"];
[properties setObject:@"utm_medium" forKey:@"apppush"];
[properties setObject:@"KeyID or Email" forKey:@"OM.exVisitorID"]; //Your reference in the RMC system
[properties setObject:@"User Token for Push Message" forKey:@"OM.sys.TokenID"];
[properties setObject:@"AppAlias" forKey:@"OM.sys.AppID"];
[[Visilabs callAPI] customEvent:@"Campaign" withProperties:properties];

...

Code Block
languageswift
var properties = [String:String]()
properties["utm_campaign"] = "campaign_name"
properties["utm_source"] = "related"
properties["utm_medium"] = "apppush"
properties["OM.exVisitorID "] = "KeyID or Email" //Your reference in the RMC system
properties["OM.sys.TokenID"] = "User Token for Push Message"
properties["OM.sys.AppID"] = "AppAlias"
Visilabs.callAPI().customEvent("Campaign", withProperties: NSMutableDictionary(dictionary: p

...

 func application(_ application: UIApplication,
                     didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
        Euromsg.handlePush(pushDictionary: userInfo)
    }

    func application(_ application: UIApplication,
                     didReceiveRemoteNotification userInfo: [AnyHashable : Any],
                     fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        Euromsg.handlePush(pushDictionary: userInfo)
    }

    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                willPresent notification: UNNotification,
                                withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
        completionHandler([.alert, .badge, .sound])
    }
    
    func userNotificationCenter(_ center: UNUserNotificationCenter,
                                didReceive response: UNNotificationResponse,
                                withCompletionHandler completionHandler: @escaping () -> Void) {
        Euromsg.handlePush(pushDictionary: response.notification.request.content.userInfo)
        completionHandler()
    }

SceneDelegate.swift

Code Block
languageswift
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }

        if #available(iOS 13, *),
            let userInfo = connectionOptions.notificationResponse?.notification.request.content.userInfo {
            Euromsg.handlePush(pushDictionary: userInfo)
        }    
    } 

Send Information to RMC

Run the code below when the user successfully logs in, registers and the first time the application is opened.

In order for your data from the mobile channel to be uploaded to RMC, please pay attention that whatever reference value you have used in your active RMC account (KEY_ID * or E-Mail) comes from the mobile channel with this reference.

*KEY_ID: These are the id values ​​used by the application owner to deduplicate the customer. These can be expressed with different names such as CRMid, userid, customerid, accountid.

Code Block
Euromsg.setEmail(email: "test@relateddigital.com", permission: true)
        Euromsg.setEuroUserId(userKey: "1234567890")
        Euromsg.sync()

IYS Email Register

Add it just before Euromsg.sync() code.

Code Block
languageswift
Euromsg.registerEmail(email: "example@email.com", permission: true)
//You can also call TACIR account as following
Euromsg.registerEmail(email: "example@commercial.com, permission: true, isCommercial: true)