From 3cc290ff6eb158f57da79195936c8d7e02cc8aa7 Mon Sep 17 00:00:00 2001 From: Dmitry Belov Date: Wed, 30 Oct 2024 11:30:55 +0100 Subject: [PATCH] fix: Fix TurboModule method signature mismatch in Swift by removing external parameter label --- ios/wrappers/push/CioRctPushMessaging.swift | 32 ++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ios/wrappers/push/CioRctPushMessaging.swift b/ios/wrappers/push/CioRctPushMessaging.swift index 75ef6a28..49359656 100644 --- a/ios/wrappers/push/CioRctPushMessaging.swift +++ b/ios/wrappers/push/CioRctPushMessaging.swift @@ -6,7 +6,7 @@ enum PushPermissionStatus: String, CaseIterable { case denied case notDetermined case granted - + var value: String { return rawValue.uppercased() } @@ -18,24 +18,24 @@ class CioRctPushMessaging: NSObject { @objc static func requiresMainQueueSetup() -> Bool { false /// false because our native module's initialization does not require access to UIKit } - + // Tracks `opened` push metrics when a push notification is interacted with. @objc - func trackNotificationResponseReceived(payload: NSDictionary) { + func trackNotificationResponseReceived(_ payload: NSDictionary) { trackPushMetrics(payload: payload, event: .opened) } - + // Tracks `delivered` push metrics when a push notification is received. @objc - func trackNotificationReceived(payload: NSDictionary) { - + func trackNotificationReceived(_ payload: NSDictionary) { + trackPushMetrics(payload: payload, event: .delivered) } - + // Get the currently registered device token for the app @objc(getRegisteredDeviceToken:rejecter:) func getRegisteredDeviceToken(resolver resolve: @escaping(RCTPromiseResolveBlock), rejecter reject: @escaping(RCTPromiseRejectBlock)) -> Void { - + guard let token = CustomerIO.shared.registeredDeviceToken else { reject(CustomerioConstants.cioTag, CustomerioConstants.showDeviceTokenFailureError, nil) return @@ -46,18 +46,18 @@ class CioRctPushMessaging: NSObject { private func trackPushMetrics(payload: NSDictionary, event : Metric) { guard let deliveryId = payload[CustomerioConstants.CioDeliveryId] as? String, let deviceToken = payload[CustomerioConstants.CioDeliveryToken] as? String else {return} - + MessagingPush.shared.trackMetric(deliveryID: deliveryId, event: event, deviceToken: deviceToken) } - + @objc(showPromptForPushNotifications:resolver:rejecter:) func showPromptForPushNotifications(options : Dictionary, resolver resolve: @escaping(RCTPromiseResolveBlock), rejecter reject: @escaping(RCTPromiseRejectBlock)) -> Void { - + // Show prompt if status is not determined getPushNotificationPermissionStatus { status in if status == .notDetermined { self.requestPushAuthorization(options: options) { permissionStatus in - + guard let isGranted = permissionStatus as? Bool else { reject(CustomerioConstants.cioTag, CustomerioConstants.showPromptFailureError, permissionStatus as? Error) return @@ -69,20 +69,20 @@ class CioRctPushMessaging: NSObject { } } } - + @objc(getPushPermissionStatus:rejecter:) func getPushPermissionStatus(resolver resolve: @escaping(RCTPromiseResolveBlock), rejecter reject: @escaping(RCTPromiseRejectBlock)) -> Void { getPushNotificationPermissionStatus { status in resolve(status.value) } } - + private func requestPushAuthorization(options: [String: Any], onComplete : @escaping(Any) -> Void ) { let current = UNUserNotificationCenter.current() var notificationOptions : UNAuthorizationOptions = [.alert] if let ios = options[CustomerioConstants.platformiOS] as? [String: Any] { - + if let soundOption = ios[CustomerioConstants.sound] as? Bool, soundOption { notificationOptions.insert(.sound) } @@ -98,7 +98,7 @@ class CioRctPushMessaging: NSObject { onComplete(isGranted) } } - + private func getPushNotificationPermissionStatus(completionHandler: @escaping(PushPermissionStatus) -> Void) { var status = PushPermissionStatus.notDetermined let current = UNUserNotificationCenter.current()