Skip to content

Commit

Permalink
chore: TurboModule method signature mismatch in Swift by removing ext…
Browse files Browse the repository at this point in the history
…ernal parameter label (#352)

Co-authored-by: Dmitry Belov <[email protected]>
  • Loading branch information
dmitry-blackwave and Dmitry Belov authored Nov 18, 2024
1 parent fb27305 commit 2172838
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 2172838

Please sign in to comment.