Skip to content

Commit

Permalink
fix: Fix TurboModule method signature mismatch in Swift by removing e…
Browse files Browse the repository at this point in the history
…xternal parameter label
  • Loading branch information
Dmitry Belov committed Oct 30, 2024
1 parent 6da1653 commit 3cc290f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions ios/wrappers/push/CioRctPushMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum PushPermissionStatus: String, CaseIterable {
case denied
case notDetermined
case granted

var value: String {
return rawValue.uppercased()
}
Expand All @@ -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
Expand All @@ -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<String, AnyHashable>, 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
Expand All @@ -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)
}
Expand All @@ -98,7 +98,7 @@ class CioRctPushMessaging: NSObject {
onComplete(isGranted)
}
}

private func getPushNotificationPermissionStatus(completionHandler: @escaping(PushPermissionStatus) -> Void) {
var status = PushPermissionStatus.notDetermined
let current = UNUserNotificationCenter.current()
Expand Down

0 comments on commit 3cc290f

Please sign in to comment.