Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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

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.

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.

  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.

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.didReceive(bestAttemptContent, withContentHandler: contentHandler)
    }
    
    override func serviceExtensionTimeWillExpire() {
        // Called just before the extension will be terminated by the system.
        // Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
        if let contentHandler = contentHandler, let bestAttemptContent =  bestAttemptContent {
            Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler)
        }
    }
}

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.

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

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

    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.

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

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

import UIKit
import UserNotifications
import UserNotificationsUI
import Euromsg

@available(iOS 10.0, *)
@objc(EMNotificationViewController)
class EMNotificationViewController: UIViewController, UNNotificationContentExtension {

    let appUrl = URL(string: "euromsgExample://") //Change 'euromsgExample://' with your deeplink url
    let carouselView = EMNotificationCarousel.initView()
    var completion: ((_ url: URL?) -> 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 in
            if let url = url {
                self?.extensionContext?.open(url)
            }
            else if let url = self?.appUrl {
                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

import Euromsg
import UserNotifications

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

class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate

Aşağıdaki kod didFinishLaunchingWithOptions fonksiyonunun içerisine ekleyin.

        UNUserNotificationCenter.current().delegate = self
        
        Euromsg.configure(appAlias: "YOUR_APP_ALIAS", enableLog: true)
        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

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.

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.

 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: @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()
    }

SceneDelegate.swift

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

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.

Euromsg.setEmail(email: "test@relateddigital.com", permission: true)
        Euromsg.setEuroUserId(userKey: "1234567890")
        Euromsg.sync()

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

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)

  • No labels