Versions Compared

Key

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

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'

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 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ı.
-P12 sertifikası oluşturmak için tıklayın
-P8 sertifikası 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'

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.

  1. Xcode’u açın ve File > New > Target adımını izleyin

  2. Notification Service Extension'ı seçin ve Next butonuna tıklayın.

    Image Added

  3. Product Name alanına NotificationService yazın ve Finish butonuna tıklayın.

    Image Added

  4. Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna basın.

    Image Added

    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.

  5. 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.

    Image Modified
  6. NotificationService.swift dosyasını açın ve içerisindeki kodları aşağıdaki kodlarla değiştirin.

    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", 

...

  1. launchOptions: 

...

  1. nil, enableLog: true)
           

...

  1.  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. "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.

    Image Added

Notification Content Extension Ekleme

Not: Eğer push mesajı gönderimlerinizde Carousel Push kullanacaksanız bunu eklemeniz zorunludur.

  1. Xcode’u açın ve File > New > Target adımını izleyin

  2. Notification Content Extension'ı seçin ve Next butonuna tıklayın.

    Image Modified

  3. Pproduct Name alanına NotificationContent yazın ve Finish butonuna tıklayın.

    Image Modified

  4. Finish butonuna tıkladıktan sonra açılacak diyalog penceresinde Cancel butonuna tıklayın.

    Image Modified
    1. 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.

  5. 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.

    Image Modified

  6. MainInterface.storyboard ve NotificationContent.swift dosyalarını silin. Ardından NotificationContent klasörü altına EMNotificationViewController isminde swift dosyası oluşturun.

...

  1. Info.plist dosyasını bu linkteki ile aynı olduğuna dikkat ediniz.

    Image Modified

    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.

...

languageswift

...

  1. .

    Image Added

  2. EMNotificationViewController.swift açın ve içerisindeki kodları aşağıdaki ile değiştirin.

Code Block
languageswift
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() {
        completion = { [weak self] url, bestAttemptContent in
            if let identifier = self?.notificationRequestIdentifier {
                UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: [identifier])
                UNUserNotificationCenter.current().getDeliveredNotifications(completionHandler: { notifications in
                    bestAttemptContent?.badge = NSNumber(value: notifications.count)
                })
            }
            if let url = url {
                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
    }
}

/**
 Add if you want to track which carousel element has been selected
 */
extension EMNotificationViewController: CarouselDelegate {   
    func selectedItem(_ element: EMMessage.Element) {
        // Add your work...
        print("Selected completionHandlerelement completion:is @escaping=> \(UNNotificationContentExtensionResponseOption) -> Void) {
        carouselView.didReceive(response, completionHandler: completion)
    }
    override func loadView() {
        completion = { [weak self] url, userInfo in
     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
languagenone
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 target.name == 'Euromsg'
      if let url = url { target.build_configurations.each do |config|
             self?.extensionContext?.open(url)   config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'No'
           if url.schemeend
!= self?.appUrl?.scheme, let userInfo = userInfo {  end
    end
end
  # Pods for RelatedDigital

end

target   Euromsg.handlePush(pushDictionary: userInfo)
   '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 elseline if letyou urldon't = self?.appUrl {
 want to use dynamic frameworks
  use_frameworks!
pod 'Euromsg'
  # Pods for     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.

...

AppDelegate.swift

İlk olarak Euromsg ve UserNotifications'ı AppDelegeta’e eklemeliyiz

Code Block
languageswift
import Euromsg
import UserNotifications

class AppDelegate’in sonuna UNUserNotificationCenterDelegate eklemelisiniz. Alt satırda örneğini görebilirsiniz.

Code Block
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate

Aşağıdaki kodlardan uygun olanını didFinishLaunchingWithOptions fonksiyonunun içerisine ekleyin.

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
languageswift
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
languageswift
import Euromsg
import UserNotifications

class AppDelegate’in sonuna UNUserNotificationCenterDelegate eklemelisiniz. Alt satırda örneğini görebilirsiniz.

Code Block
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate

Aşağıdaki kodlardan uygun olanını didFinishLaunchingWithOptions fonksiyonunun içerisine ekleyin.

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
languageswift
        UNUserNotificationCenter.current().delegate = self
        
        Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: true, appGroupsKey: "group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: false)
        Euromsg.registerForPushNotifications()
        UNUserNotificationCenterEuromsg.current().delegate = self
      askForNotificationPermissionProvisional()
        if #available(iOS 13, *) {
            // handle push for iOS 13 and later in sceneDelegate
        }
 Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true)    else if let userInfo  Euromsg.registerForPushNotifications()
        Euromsg.askForNotificationPermissionProvisional()= launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
           if #available(iOS 13, *) {Euromsg.handlePush(pushDictionary: userInfo)
        }
       // handlereturn true

Eğer provisional push

...

izni almak istemiyorsanız didFinishLaunchingWithOptions’a aşağıdaki kodu ekleyin.

Code Block
languageswift
        UNUserNotificationCenter.current().delegate = self
     }   
     else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
    Euromsg.configure(appAlias: "YOUR_APP_ALIAS", launchOptions: launchOptions, enableLog: true, appGroupsKey: "group.YOUR_BUNDLE_ID.relateddigital", deliveredBadge: false)
        Euromsg.handlePushregisterForPushNotifications(pushDictionary: userInfo)
        }Euromsg.askForNotificationPermission()
        return true

Eğer provisional push izni almak istemiyorsanız didFinishLaunchingWithOptions’a aşağıdaki kodu ekleyin.

Code Block
languageswift
    if #available(iOS 13, *) {
   UNUserNotificationCenter.current().delegate = self       // handle push for iOS 13 and later in sceneDelegate
 Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true)    }
    Euromsg.registerForPushNotifications()    else if let userInfo  Euromsg.askForNotificationPermission()
    = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
   if #available(iOS 13, *) {     Euromsg.handlePush(pushDictionary: userInfo)
      // handle push}
for iOS 13 and later in sceneDelegate         }
 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) {
      else if let userInfo = launchOptions?[UIApplication.LaunchOptionsKey.remoteNotification] as? [String: Any] {
        Euromsg.registerToken(tokenData: deviceToken)
    Euromsg.handlePush(pushDictionary: userInfo)
  }

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
languageswift
 func application(_ application: UIApplication,
     }         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       didReceiveRemoteNotification userInfo: [AnyHashable : Any]) {
        Euromsg.registerTokenhandlePush(tokenDatapushDictionary: deviceTokenuserInfo)
    }

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
languageswift


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

    func userNotificationCenter(_ center: UNUserNotificationCenter,
             fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {         Euromsg.handlePush(pushDictionary: userInfo)   willPresent notification: }UNNotification,
     func userNotificationCenter(_ center: UNUserNotificationCenter,                        withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
  willPresent notification: UNNotification,    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()
     withCompletionHandler completionHandler: @escaping () -> Void) {}

SceneDelegate.swift

willConnectTo fonksiyonun içerisine aşağıdaki kod bloğunu ekleyin.

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

SceneDelegate.swift

...

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
languageswift
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)
        Euromsg.setEuroUserId(userKey: "1234567890")
        Euromsg.sync()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
languageswift
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
isMissingRequiredParameterstrue