...
...
...
...
Bu sayfada bulabilecekleriniz:
Table of Contents | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Notification Service Extension Ekleme
...
Code Block | ||
---|---|---|
| ||
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) { RelatedDigital.handlePush(pushDictionary: userInfo) } func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) { RelatedDigital.handlePush(pushDictionary: userInfo) } func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { if completionHandler([.alert, .badge, .sound]) #available(iOS 14.0, *) { } func userNotificationCenter(_ center: UNUserNotificationCenter, completionHandler([.banner, .sound, .badge, .list]) } else { completionHandler([.alert, .badge, .sound]) } didReceive response: UNNotificationResponse } func userNotificationCenter(_ center: UNUserNotificationCenter, withCompletionHandlerdidReceive completionHandlerresponse: @escapingUNNotificationResponse, () -> Void) { RelatedDigital withCompletionHandler completionHandler: @escaping () -> Void) { RelatedDigital.handlePush(pushDictionary: response.notification.request.content.userInfo) completionHandler() } |
...
Code Block | ||
---|---|---|
| ||
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.
...
Code Block |
---|
RelatedDigital.getPushMessagesWithID { messages ingetPushMessagesWithID { messages in if messages.isEmpty { print("🚲 there is no recorded push message.") } for message in messages { print("🆔: \(message.pushId ?? "")") print("📅: \(message.formattedDateString ?? "")") print(message.encoded) } } |
Push Bildirim Sesi Kullanma
iOS Custom Sound eklemek için projenizin root dizinine .wav .mp3 .ogg uzantıları kabul edilen ses dosyalarınızı maksimum 2 adet olacak şekilde ekleyebilirsiniz.
Bu adımdan sonra Ayarlar > Kampanya Ayarları > Push Uygulamaları > UYGULAMANIZIN_ISMI adımından Özel Ses Dosyası 1 ve Özel Ses Dosyası 2 alanlarına ses dosyalarınızın ismini/isimlerini yazmanız gerekmektedir.
...
Action Button Callback Kullanma
Action Button kullandığınız pushlarda kullanıcının tıkladığı butona göre yönlendirme yapabilmek için Action Button delege methodunu kullanmalısınız.
Öncelikle AppDelegate class'ına PushAction protokolünü ekleyin.
Code Block |
---|
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, PushAction {
...
} |
Ardından aşağıdaki fonksiyonu AppDelegate class'ının içerisine ekleyerek kullanabilirsiniz.
Code Block |
---|
func actionButtonClicked(identifier: String, url: String) {
print(identifier,url)
} |
Son hali aşağıdaki ekran görüntüsündeki gibi olacaktır.
...
Push Mesajlarını Okundu Olarak İşaretleme
getPushMessages fonksiyonunda kullanıcılarınıza uygulama içerisinde gösterdiğiniz push mesajların okundu bilgisini işaretlemek için aşağıdaki fonksiyonları kullanabilirsiniz. Bu fonksiyonlar ile getPushMessages içerisinde bulunan payload/payloadlarda ki status durumunu O yapar ve buna göre kendi oluşturduğunuz bildirim merkezinde buna göre aksiyon alabilirsiniz. Bu fonksiyonları kullandığınız zaman size geri dönüş olarak true veya false döner.
Tümünü okundu olarak işaretleme
Code Block | ||
---|---|---|
| ||
RelatedDigital.readAllPushMessages { success in
print(success)
} |
Bildirim bazlı okundu olarak işaretleme
Code Block |
---|
RelatedDigital.readAllPushMessages(pushId: "BURAYA_PUSH_ID_GELECEK") { success in
print(success)
} |
getPushMessage fonksiyonunda payloadda pushId bulunmaktadır buraya o değeri ekleyeceksiniz.
Push Mesajlarını Silme
deleteAllPayloads ve deleteAllPayloadWithId fonksiyonlarını kullanarak getPushMessages fonksiyonumuz ile uygulamanız içerisinde gösterdiğiniz pushları silinde olarak işaretleyebilirsiniz.
Tüm bildirimleri silme
Code Block |
---|
RelatedDigital.deleteAllPayloads { completed in
print(completed)
} |
Bildirim bazlı silme
Code Block |
---|
RelatedDigital.deletePayloadWithId(pushId: "1234567890") { completed in
print(completed)
} |
Related Digital ile Firebase’i Ortak Kullanma
Uygulamanızda Related Digital SDK’mızı ve Firebase’i ortak kullanmak isterseniz uygulamanız içerisinde Notification Service Extension classına aşağıdaki kodu eklemeniz yeterli.
Code Block |
---|
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) if messages.isEmpty { } else { print("🚲 there is no recorded push message.")"--Firebase Push") Messaging.serviceExtension().populateNotificationContent(self.bestAttemptContent!, withContentHandler: contentHandler) } } for} message in messages { } override func serviceExtensionTimeWillExpire() { guard let contentHandler print("🆔: \(message.pushId ?? "")")= self.contentHandler else { return; print("📅: \(message.formattedDateString ?? "")") } guard let bestAttemptContent = self.bestAttemptContent else { print(message.encoded) return; } } contentHandler(bestAttemptContent) } } } |