Eğer Euromsg SDK 2.0.0 versiyonundan düşük bir versiyon kullanıyorsanız buraya gidin.
Adım 1 - Gerekenler
...
iOS Mobil Uygulaması & Xcode
...
P12 dosyası & şifresi. P12 Dosyası oluşturmak için tıklayın
...
AppAlias (RMC Panelinden alınacak) Eğer bir hesabınız bulunmuyorsa satış temsilcimizle iletişime geçebilirsiniz. Buraya tıklayın.
Adım 2 - Kurulum
2.1 Euromsg SDK’sı Cocoapods aracılığıyla kurulmaktadır. Aşağıdaki kodu Podfile dosyanıza ekledikten sonra pod install diyerek kurabilirsiniz.
Code Block |
---|
pod 'Euromsg', '>= 2.0.0' |
Adım 3 - Uygulamanızı RMC Panele Ekleme
İlk olarak, RMC Panelde sağ üstteki çark ikonu üzerine gelerek Kampanya Yönetimi > Kampanya Ayarları > Push Uygulamaları menüsünden Yeni iOS Uygulaması butonuna tıklayın. RMC uygulamanızı App Alias üzerinden tanır burada uygulamanız için sadece size ait olacak bir App Alias belirleyin.
...
Adım 4 - Kullanım
Notification Service Extension Ekleme
Notification Service Extension zengin push mesajları(görsel, video) almanıza yardımcı olur.
Xcode’u açın ve File > New > Target adımını izleyin
Notification Service Extension'ı seçin ve Next butonuna tıklayın.
Product Name alanına NotificationService yazın ve Finish butonuna tıklayın.
Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna basın.
Eğer Activate butonuna tıklarsanız uygulama Target'ı NotificationService olacaktır. Bu bir sorun değildir. Scheme alanından uygulamanızı seçerek düzeltebilirsiniz.
Sol menüden projenizi seçin açılan alanda TARGETS altından NotificationService’i seçin. Deployment Info bölümünde Target alanını iOS 11.0 yapın.
NotificationService.swift dosyasını açın ve içerisindeki kodları aşağıdaki kodlarla değiştirin.
...
language | swift |
---|
...
Eğer Euromsg SDK 2.0.0 versiyonundan düşük bir versiyon kullanıyorsanız buraya gidin.
Bu sayfada:
Table of Contents |
---|
...
Adım 1 - Gerekenler
iOS Mobil Uygulaması & Xcode |
---|
P12 sertifikası & şifresi veya P8 sertifikası. |
AppAlias (RMC Panelinden alınacak) Eğer bir hesabınız bulunmuyorsa satış temsilcimizle iletişime geçebilirsiniz. Buraya tıklayın. |
Adım 2 - Kurulum
2.1 Euromsg SDK’sı Cocoapods aracılığıyla kurulmaktadır. Aşağıdaki kodu Podfile dosyanıza ekledikten sonra pod install diyerek kurabilirsiniz.
Code Block |
---|
pod 'Euromsg' |
Adım 3 - Uygulamanızı RMC Panele Ekleme
İlk olarak, RMC Panelde sağ üstteki çark ikonu üzerine gelerek Kampanya Yönetimi > Kampanya Ayarları > Push Uygulamaları menüsünden Yeni iOS Uygulaması butonuna tıklayın. RMC uygulamanızı App Alias üzerinden tanır burada uygulamanız için sadece size ait olacak bir App Alias belirleyin.
...
Adım 4 - Kullanım
Notification Service Extension Ekleme
Notification Service Extension zengin push mesajları(görsel, video) almanıza yardımcı olur.
Xcode’u açın ve File > New > Target adımını izleyin
Notification Service Extension'ı seçin ve Next butonuna tıklayın.
Product Name alanına NotificationService yazın ve Finish butonuna tıklayın.
Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna basın.
Eğer Activate butonuna tıklarsanız uygulama Target'ı NotificationService olacaktır. Bu bir sorun değildir. Scheme alanından uygulamanızı seçerek düzeltebilirsiniz.
Sol menüden projenizi seçin açılan alanda TARGETS altından NotificationService’i seçin. Deployment Info bölümünde Target alanını iOS 11.0 yapın.
NotificationService.swift dosyasını açın ve içerisindeki kodları aşağıdaki kodlarla değiştirin.
Code Block language swift 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: "EuromsgIOSTest", launchOptions: nil, enableLog: true) Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler) } override func serviceExtensionTimeWillExpire() { guard let contentHandler = self.contentHandler else { return; } guard let bestAttemptContent = self.bestAttemptContent else { return; } contentHandler(bestAttemptContent) } }
"Copy only when installing" seçili olmadığından emin olun. Öncelikle Main Targetınızı seçin ardından Build Phases > Embed App Extensions'ı açın. Burada eğer Copy only when installing seçili ise seçimi kaldırın. Bu seçili olması halinde pushlarınızda görsel kullanamazsınız.
Notification Content Extension Ekleme
Not: Eğer push mesajı gönderimlerinizde Carousel Push kullanacaksanız bunu eklemeniz zorunludur.
Xcode’u açın ve File > New > Target adımını izleyin
Notification Content Extension'ı seçin ve Next butonuna tıklayın.
Pproduct Name alanına NotificationContent yazın ve Finish butonuna tıklayın.
Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna tıklayın.
Eğer Activate butonuna tıklarsanız uygulama Target'ı NotificationContent olacaktır. Bu bir sorun değildir. Scheme alanından uygulamanızı seçerek düzeltebilirsiniz.
Sol menüden projenizi seçin açılan alanda TARGETS altından NotificationContent’i seçin. Deployment Info bölümünde Target alanını iOS 11.0 yapın.
MainInterface.storyboard ve NotificationContent.swift dosyalarını silin. Ardından NotificationContent klasörü altına EMNotificationViewController isminde swift dosyası oluşturun. Info.plist dosyasını bu linkteki ile aynı olduğuna dikkat ediniz.
Objective-C Bridging Header oluşturma sorulursa Don’t Create butonuna tıklayın.
EMNotificationViewController.swift açın ve içerisindeki kodları aşağıdaki ile değiştirin.
Code Block | ||
---|---|---|
| ||
import UIKit import UserNotifications import UserNotificationsUI import Euromsg @objc(EMNotificationViewController) class EMNotificationViewController: UIViewController, UNNotificationContentExtension { let carouselView = EMNotificationCarousel.initView() var completion: ((_ url: URL?, _ bestAttemptContent: UNMutableNotificationContent?) -> Void)? var notificationRequestIdentifier = "" func didReceive(_ notification: UNNotification) { notificationRequestIdentifier = notification.request.identifier Euromsg.configure(appAlias: "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() { self.contentHandlercompletion = contentHandler{ [weak self] url, bestAttemptContent in bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent) if let Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler)identifier = self?.notificationRequestIdentifier { } override func serviceExtensionTimeWillExpireUNUserNotificationCenter.current() {.removeDeliveredNotifications(withIdentifiers: [identifier]) // Called just before the extension will be terminated by the system. UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: { notifications in // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used. bestAttemptContent?.badge = NSNumber(value: notifications.count) if let}) contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent { } Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler) if let url = url { } } } |
Notification Content Extension Ekleme
Not: Eğer push mesajı gönderimlerinizde Carousel Push kullanacaksanız bunu eklemeniz zorunludur.
Xcode’u açın ve File > New > Target adımını izleyin
Notification Content Extension'ı seçin ve Next butonuna tıklayın.
Pproduct Name alanına NotificationContent yazın ve Finish butonuna tıklayın.
Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna tıklayın.
Eğer Activate butonuna tıklarsanız uygulama Target'ı NotificationContent olacaktır. Bu bir sorun değildir. Scheme alanından uygulamanızı seçerek düzeltebilirsiniz.
Sol menüden projenizi seçin açılan alanda TARGETS altından NotificationContent’i seçin. Deployment Info bölümünde Target alanını iOS 11.0 yapın.
MainInterface.storyboard ve NotificationContent.swift dosyalarını silin. Ardından NotificationContent klasörü altına EMNotificationViewController isminde swift dosyası oluşturun.
Objective-C Bridging Header oluşturma sorulursa Don’t Create butonuna tıklayın.
EMNotificationViewController.swift açın ve içerisindeki kodları aşağıdaki ile değiştirin.
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) if #available(iOSApplicationExtension 12.0, *) { self?.extensionContext?.dismissNotificationContentExtension() } self?.extensionContext?.open(url) } else { if #available(iOSApplicationExtension 12.0, *) { self?.extensionContext?.performNotificationDefaultAction() } } } carouselView.completion = completion carouselView.delegate = self self.view = carouselView } } /** funcAdd didReceive(_ response: UNNotificationResponse, if you want to track which carousel element has been selected */ extension EMNotificationViewController: CarouselDelegate { completionHandler completion: @escapingfunc selectedItem(UNNotificationContentExtensionResponseOption) -> Void_ element: EMMessage.Element) { carouselView.didReceive(response, completionHandler: completion) // Add your work... } override func loadView() { completion = { [weak self] url, userInfo in if let url = url { self?.extensionContext?.open(url) print("Selected element is => \(element)") } } |
NotificationContent ve NotificationService için Euromsg SDK’sını eklemeliyiz. Podfile dosyanızı aşağıdaki şekilde düzenleyin ve tekrar terminalden proje dizininize giderek pod install yazarak enter tuşuna basın.
...
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| if urltarget.schemename != self?.appUrl?.scheme, let userInfo = userInfo'Euromsg' { target.build_configurations.each Euromsg.handlePush(pushDictionary: userInfo)do |config| config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = }'No' }end end else ifend letend url = self?.appUrl { # Pods for RelatedDigital end target 'NotificationService' do # Comment the next line self?.extensionContext?.open(url) } } carouselView.completion = completion self.view = carouselView } } |
NotificationContent ve NotificationService için Euromsg SDK’sını eklemeliyiz. Podfile dosyanızı aşağıdaki şekilde düzenleyin ve tekrar terminalden proje dizininize giderek pod install yazarak enter tuşuna basın.
...
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 |
App Groups Ekleme
Tüm hepsini tamamladıktan sonra Targetlara App Groups eklemeniz gerekmektedir.
Görselde sol tarafta işaretlenmiş olan Targetlarda sırasıyla Signing & Capabilities altından App Groups ekleyin. App Groups adını group.YOUR_APP_BUNDLE_IDENTIFIER.relateddigital şeklinde yazın.
...
AppDelegate.swift
İlk olarak Euromsg ve UserNotifications'ı AppDelegeta’e eklemeliyiz
...
Code Block |
---|
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate |
Aşağıdaki kod kodlardan uygun olanını didFinishLaunchingWithOptions fonksiyonunun içerisine ekleyinekleyin.
Provisional Push
Eğer provisional push izni alınmak isteniyorsa didFinishLaunchingWithOptions’a aşağıdaki kodu ekleyin. iOS 12 ya da daha eski versiyon kullanıcıları için bu fonksiyon askForNotificationPermission şeklinde çalışacaktır.
Code Block | ||
---|---|---|
| ||
UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true) Euromsg.registerForPushNotifications() Euromsg.askForNotificationPermission() if #available(iOS 13, *) { Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: true, appGroupsKey: "group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: false) // handle push for iOS 13 and later in sceneDelegate Euromsg.registerForPushNotifications() Euromsg.askForNotificationPermissionProvisional() } if #available(iOS 13, *) { else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { // handle push for iOS 13 and later in Euromsg.handlePush(pushDictionary: userInfo)sceneDelegate } } else if let return true |
Eğer kullanıcılar bildirim göndermeye izin verirse aşağıdaki metod çalışır ve APNS’ten token alınarak Euromessage sistemlerine kaydolur.
Code Block |
---|
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.registerTokenhandlePush(tokenDatapushDictionary: deviceTokenuserInfo) } |
...
return true |
Eğer provisional push izni almak istemiyorsanız didFinishLaunchingWithOptions’a aşağıdaki kodu ekleyin.
Code Block | ||
---|---|---|
| ||
func application(_ application: UIApplication,UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: didReceiveRemoteNotificationtrue, userInfoappGroupsKey: [AnyHashable : Any]) {"group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: false) Euromsg.registerForPushNotifications() Euromsg.handlePushaskForNotificationPermission(pushDictionary: userInfo) } if func application(_ application: UIApplication, #available(iOS 13, *) { // handle push for iOS 13 and didReceiveRemoteNotificationlater userInfo:in [AnyHashablesceneDelegate : Any], } else if let userInfo = fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.handlePush(pushDictionary: userInfo) } } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, return true |
Eğer kullanıcılar bildirim göndermeye izin verirse aşağıdaki metod çalışır ve APNS’ten token alınarak Euromessage sistemlerine kaydolur.
Code Block |
---|
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) { Euromsg.registerToken(tokenData: deviceToken) } |
RMC paneli üzerinden kullanıcılarınızın push mesajlarına tıklayıp tıklamadıklarını raporlayabilmek için aşağıdaki kodları ekleyin.
Code Block | ||
---|---|---|
| ||
func application(_ application: UIApplication, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { didReceiveRemoteNotification userInfo: completionHandler([.alert, .badge, .soundAnyHashable : Any]) } func userNotificationCenter(_ center: UNUserNotificationCenter,{ Euromsg.handlePush(pushDictionary: userInfo) } func application(_ application: UIApplication, didReceive response: UNNotificationResponse, didReceiveRemoteNotification userInfo: [AnyHashable : Any], withCompletionHandlerfetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { Euromsg.handlePush(pushDictionary: response.notification.request.content.userInfo) userInfo) } func userNotificationCenter(_ center: UNUserNotificationCenter, completionHandler() } |
SceneDelegate.swift
willConnectTo fonksiyonun içerisine aşağıdaki kod bloğunu ekleyin.
Code Block | ||
---|---|---|
| ||
if #available(iOS 13, *), let userInfo = connectionOptions.notificationResponse?.notification.request.content.userInfo { Euromsg.handlePush(pushDictionary: userInfo) } |
RMC’ye bilgi gönderme
Aşağıdaki kodu kullanıcı uygulamanıza üye olduğunda, üye girişi yaptığında ve uygulama ilk açılırken çalıştırın.
Not. : Hesabınızın referansına göre setEmail veya setEuroUserId metodlarından birini kullanmak zorundasınız.
Code Block |
---|
Euromsg.setEmail(email: "test@relateddigital.com", permission: true)willPresent notification: UNNotification, Euromsg.setEuroUserId(userKey: "1234567890") Euromsg.sync() |
IYS E-Posta Kaydı
IYS kodunu Euromsg.sync() kodundan hemen önce ekleyiniz.
Code Block |
---|
Euromsg.registerEmail(email: "example@email.com", permission: true) //TICARI hesaplar için aşağıdaki kodu kullanınız Euromsg.registerEmail(email: "example@commercial.com, permission: True, isCommercial: true) |
İsteğe bağlı parametreler
setUserProperty: Kullanıcının demografik alanlarını doldurmanıza yardımcı olur.
setAppVersion: Kullanıcılarını uygulama versiyonunuza göre segmente etmenize ve raporlamaya yardımcı olur.
checkConfiguration: Kullanıcıların izin bilgilerini kontrol edebilirsiniz.
setPushNotification, setEmail, setPhoneNumber: Kullanıcıların izin durumlarını RMC’ye gönderebilirsiniz.
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) |
Push Kampanyası Cirolarının Panele Yansıması
Gelen push bildirimine tıkladıktan sonra yapılan satın almanın RMC panelinde Ciro alanına yansıması için aşağıdaki metodu kullanmanız gerekmektedir.
...
Push ekranında bulunan Özel Parametreler alanına utm parametrelerini girmelisiniz.
Örn: utm_medium=apppush;utm_source=related;utm_campaign=campaign_name
Not: utm_campaign her seferinde farklı olması gerektiği için oluşturduğunuz push kampanyasının ID’sini değişken olarak kullanabilirsiniz. Bunun için <##CAMP_ID##> değişkenini isteğe bağlı bir şekilde kullanabilirsiniz.
...
...
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 |
Bu datayı aynı deeplink kullanımında olduğu gibi handle ederek utm parametrelerini pusha tıklandığında Visilabs’e event olarak göndermelisiniz. Örnek Visilabs event kodlarını alt satırda bulabilirsiniz.
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 veya Email" forKey:@"OM.exVisitorID"]; //RMC sistemindeki referansınız
[properties setObject:@"Kullanıcı Push Mesaj Tokenı" 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 veya Email" //RMC sistemindeki referansınız
properties["OM.sys.TokenID"] = "Kullanıcı Push Mesaj Tokenı"
properties["OM.sys.AppID"] = "AppAlias"
Visilabs.callAPI().customEvent("Campaign", withProperties: NSMutableDictionary(dictionary: properties)) |
...
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
if #available(iOS 14.0, *) {
completionHandler([.banner, .sound, .badge, .list])
} else {
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
willConnectTo fonksiyonun içerisine aşağıdaki kod bloğunu ekleyin.
Code Block | ||
---|---|---|
| ||
if #available(iOS 13, *),
let userInfo = connectionOptions.notificationResponse?.notification.request.content.userInfo {
Euromsg.handlePush(pushDictionary: userInfo)
} |
RMC’ye bilgi gönderme
Aşağıdaki kodu kullanıcı uygulamanıza üye olduğunda, üye girişi yaptığında ve uygulama ilk açılırken çalıştırın.
Eğer kullanıcı e-mail izni vermemişse permission değerini false olarak göndermelisiniz.
Code Block | ||
---|---|---|
| ||
Euromsg.setEmail(email: "test@relateddigital.com", permission: true)
Euromsg.setEuroUserId(userKey: "1234567890")
Euromsg.sync() |
Mobil kanaldan gelen datalarınızın RMC'ye yüklenebilmesi için, aktif RMC hesabınızda kullanmış olduğunuz referans değeriniz ne ise (KEY_ID* veya E-Mail) mobil kanaldan gelen dataların da bu referans ile gelmesine dikkat ediniz."
*KEY_ID: Uygulama sahibi tarafından müşterisinin tekilleştirilmesi için kullanılan id değerleridir. Bunlar CRM id, userid, customerid, accountid gibi farklı isimlerle ifade ediliyor olabilir.
IYS E-Posta Kaydı
IYS kodunu Euromsg.sync() kodundan hemen önce ekleyiniz.
Code Block | ||
---|---|---|
| ||
Euromsg.registerEmail(email: "example@email.com", permission: true)
//TACIR hesaplar için aşağıdaki kodu kullanınız
Euromsg.registerEmail(email: "example@commercial.com, permission: True, isCommercial: true) |
Iframe | ||
---|---|---|
|