If you are using a version lower than 2.0.0 go here.
...
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 | ||
---|---|---|
| ||
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.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true) Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler) } override func serviceExtensionTimeWillExpire() { //guard Calledlet justcontentHandler before= theself.contentHandler extensionelse will{ be terminated by the system. return; // Use this as an opportunity to deliver your} "best attempt" at modified content, otherwise the original pushguard payloadlet willbestAttemptContent be= usedself.bestAttemptContent else { if let contentHandler = contentHandler, let bestAttemptContentreturn; = bestAttemptContent { } Euromsg.didReceivecontentHandler(bestAttemptContent, withContentHandler: contentHandler) } } } |
Add a Notification Content Extension
...
Code Block | ||
---|---|---|
| ||
import UIKit import UserNotifications import UserNotificationsUI import Euromsg @available(iOS 10.0, *) @objc(EMNotificationViewController) class EMNotificationViewController: UIViewController, UNNotificationContentExtension { let appUrl = URL(string: "euromsgExample://") let carouselView = EMNotificationCarousel.initView() var completion: ((_ url: URL?, _ userInfo: [AnyHashable: Any]?) -> Void)? func didReceive(_ notification: UNNotification) { carouselView.didReceive(notification) } func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { carouselView.didReceive(response, completionHandler: completion) } override func loadView() { completion = { [weak self] url, userInfo in if let url = url { self?.extensionContext?.open(url) if url.scheme != self?.appUrl?.scheme, let userInfo = userInfo { Euromsg.handlePush(pushDictionary: userInfo) } } else if let url = self?.appUrl { self?.extensionContext?.open(url) } } carouselView.completion = completion //Hangi öğenin seçildiğini izlemek istiyorsanız ekleyin self.view carouselView.delegate = self 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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { self.view = carouselView } } /** Hangi carousel öğesinin seçildiğini izlemek istiyorsanız ekleyin */ extension EMNotificationViewController: CarouselDelegate { func selectedItem(_ UNUserNotificationCenter.current().delegate = selfelement: EMMessage.Element) { print("Selected element is => \(element)") } Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true) } |
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 Euromsg.registerForPushNotifications()next line if you don't want to use dynamic Euromsg.askForNotificationPermission()frameworks use_frameworks! pod 'Euromsg' post_install do |installer| if #available(iOS 13, *) { installer.pods_project.targets.each do |target| if // handle push for iOS 13 and later in sceneDelegatetarget.name == 'Euromsg' target.build_configurations.each do |config| } else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No' end Euromsg.handlePush(pushDictionary: userInfo) end } end end # Pods for returnRelatedDigital true end target } |
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.registerToken(tokenData: deviceToken)
} |
In order for push reports to be reflected on RMC, you need to add the following functions.
Code Block | ||
---|---|---|
| ||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any]) { Euromsg.handlePush(pushDictionary: userInfo) } func application(_ application: UIApplication, 'NotificationService' do # Comment the next line 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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true) Euromsg.registerForPushNotifications() didReceiveRemoteNotification userInfo: [AnyHashable : Any], Euromsg.askForNotificationPermissionProvisional() if #available(iOS 13, *) { fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Euromsg.handlePush(pushDictionary: userInfo)// handle push for iOS 13 and later in sceneDelegate } func userNotificationCenter(_ center: UNUserNotificationCenter,else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.handlePush(pushDictionary: userInfo) willPresent notification: UNNotification,} |
If you do not want to get provisional push permission, add the following code to didFinishLaunchingWithOptions.
Code Block | ||
---|---|---|
| ||
UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true) withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { Euromsg.registerForPushNotifications() completionHandler([.alert, .badge, Euromsg.sound]askForNotificationPermission() } if #available(iOS 13, *) { func userNotificationCenter(_ center: UNUserNotificationCenter, // handle push for iOS 13 and later in sceneDelegate } didReceive response: UNNotificationResponse,else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.handlePush(pushDictionary: userInfo) withCompletionHandler completionHandler: @escaping () -> Void} |
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.handlePushregisterToken(pushDictionarytokenData: response.notification.request.content.userInfodeviceToken) completionHandler() } |
...
} |
In order for push reports to be reflected on RMC, you need to add the following functions.
Code Block | ||
---|---|---|
| ||
func sceneapplication(_ sceneapplication: UISceneUIApplication, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { // Use this method to optionally configure anddidReceiveRemoteNotification attachuserInfo: the[AnyHashable UIWindow: `window`Any]) to{ the provided UIWindowScene `scene`. Euromsg.handlePush(pushDictionary: userInfo) // If using} a storyboard, the `window` property willfunc automatically be initialized and attached to the scene.application(_ application: UIApplication, // This delegate does not imply the connecting scene ordidReceiveRemoteNotification sessionuserInfo: are[AnyHashable new (see `application:configurationForConnectingSceneSession` instead).: Any], guard let _ = (scene as? UIWindowScene) else { return }fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { if #available(iOS 13, *), Euromsg.handlePush(pushDictionary: userInfo) } let userInfofunc = connectionOptions.notificationResponse?.notification.request.content.userInfo {userNotificationCenter(_ center: UNUserNotificationCenter, Euromsg.handlePush(pushDictionary: userInfo) } willPresent } |
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.
...
notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler([.alert, .badge, .sound]) } func userNotificationCenter(_ center: UNUserNotificationCenter, |
...
|
...
|
...
IYS Email Register
Add it just before Euromsg.sync() code.
Code Block | ||
---|---|---|
| ||
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:
...
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void) {
Euromsg.handlePush(pushDictionary: response.notification.request.content.userInfo)
completionHandler()
} |
SceneDelegate.swift
Code Block | ||
---|---|---|
| ||
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, |
...
*), |
...
|
...
|
...
|
...
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 | ||
---|---|---|
| ||
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 | ||
---|---|---|
| ||
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 |
...
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 | ||
---|---|---|
| ||
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) |