Eğer Euromsg SDK 2.0.0 versiyonundan düşük bir versiyon kullanıyorsanız buraya gidin.
...
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.
...
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) } }
Notification Content Extension Ekleme
Not: Eğer push mesajı gönderimlerinizde Carousel Push kullanacaksanız bunu eklemeniz zorunludur.
...
"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 @available(iOS 10.0, *) @objc(EMNotificationViewController) class 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)? func didReceive(_ notification: UNNotification)var {notificationRequestIdentifier = "" carouselView. func didReceive(_ notification: UNNotification) { notificationRequestIdentifier }= notification.request.identifier func didReceive(_ response: UNNotificationResponse, 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() { completion = { [weak self] url, bestAttemptContent in if let identifier = self?.notificationRequestIdentifier { UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [identifier]) UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: { notifications in completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) { bestAttemptContent?.badge = NSNumber(value: notifications.count) carouselView.didReceive(response, completionHandler: completion) } override func loadView() { completion = { [weak self] url, userInfo in} if let url = url { self?.extensionContext?.open(url) if #available(iOSApplicationExtension 12.0, *) { if url.scheme != self?.appUrl?.scheme, let userInfo = userInfo { extensionContext?.dismissNotificationContentExtension() Euromsg.handlePush(pushDictionary: userInfo) } }self?.extensionContext?.open(url) } else { else if let urlif = self?.appUrl {#available(iOSApplicationExtension 12.0, *) { self?.extensionContext?.openperformNotificationDefaultAction(url) } } } } carouselView.completion = completion } //Hangi öğenin seçildiğini izlemekcarouselView.completion istiyorsanız= ekleyincompletion carouselView.delegate = self self.view = carouselView } } /** Add if you want to Hangitrack which carousel öğesininelement seçildiğinihas izlemekbeen istiyorsanız ekleyinselected */ extension EMNotificationViewController: CarouselDelegate { func selectedItem(_ element: EMMessage.Element) { { // Add your work... 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 | ||
---|---|---|
| ||
UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: true, appGroupsKey: "group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: false) Euromsg.registerForPushNotifications() Euromsg.askForNotificationPermissionProvisional() if #available(iOS 13, *) { // handle push for iOS 13 and later in sceneDelegate } else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.handlePush(pushDictionary: userInfo) } return true |
...
Code Block | ||
---|---|---|
| ||
UNUserNotificationCenter.current().delegate = self Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: true, appGroupsKey: "group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: truefalse) Euromsg.registerForPushNotifications() Euromsg.askForNotificationPermission() if #available(iOS 13, *) { // handle push for iOS 13 and later in sceneDelegate } else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] { Euromsg.handlePush(pushDictionary: userInfo) } return true |
...
Code Block | ||
---|---|---|
| ||
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: UNNotification, @escaping (UNNotificationPresentationOptions) -> Void) { if #available(iOS 14.0, *) { completionHandler([.banner, .sound, .badge, .list]) withCompletionHandler} completionHandler:else @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() } |
...
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.
...
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 | ||
---|---|---|
|