Versions Compared

Key

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

Notification Service Extension Ekleme

...

  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.

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

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

  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.

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

    Code Block
    languageswift

...

  1. import RelatedDigitalIOS
    import UserNotifications
    
    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)
            DispatchQueue.main.async {
                RelatedDigital.initialize(organizationId: "YOUR_ORGANIZATION_ID", profileId: "YOUR_SITE_ID", dataSource: "YOUR_DATA_SOURCE", launchOptions: nil)
    
                RelatedDigital.enablePushNotifications(appAlias: "YOUR_APP_ALIAS", launchOptions: nil, appGroupsKey: "YOUR_APP_GROUPS_KEY")
                RDPush.didReceive(self.bestAttemptContent, withContentHandler: contentHandler)
            }
        }
    
        override func serviceExtensionTimeWillExpire() {
            guard let contentHandler = contentHandler else {
                return
            }
            guard let bestAttemptContent = bestAttemptContent else {
                return
            }
            contentHandler(bestAttemptContent)
        }
    }

...

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

...

Code Block
languageswift
RelatedDigital.setEmail(email: "test@relateddigital.com", permission: true)
RelatedDigital.setEuroUserId(userKey: "1234567890")
RelatedDigital.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.

...