Euromsg ve Firebase Ortak Kullanımı

Uygulamanızda Euromsg SDK’mızı ve Firebase’i ortak kullanmak isterseniz uygulamanız içerisinde Notification Service Extension classına aşağıdaki kodu eklemeniz yeterli.

import UserNotifications import Euromsg import FirebaseMessaging 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) if (self.bestAttemptContent != nil) { var userInfo = self.bestAttemptContent?.userInfo; let emPushSp = userInfo?["emPushSp"]; if (emPushSp != nil) { print("--RelatedDigital Push") userInfo?.removeValue(forKey: "fcm_options") self.bestAttemptContent?.userInfo = userInfo! Euromsg.configure(appAlias: "EuromsgIOSTestDev", launchOptions: nil, enableLog: true, appGroupsKey: "group.com.relateddigital.EuromsgExample.relateddigital", deliveredBadge: false) Euromsg.didReceive(bestAttemptContent, withContentHandler: contentHandler) } else { print("--Firebase Push") Messaging.serviceExtension().populateNotificationContent(self.bestAttemptContent!, withContentHandler: contentHandler) } } } override func serviceExtensionTimeWillExpire() { guard let contentHandler = self.contentHandler else { return; } guard let bestAttemptContent = self.bestAttemptContent else { return; } contentHandler(bestAttemptContent) } }

Copyright 2020 Related Digital