Skip to content

Commit

Permalink
fix(PushNotifications): Adding missing escape hatch to the plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruisebas committed Sep 1, 2023
1 parent 3fdd8cb commit 2b0bdef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Amplify
import AWSPinpoint
import Foundation
@_spi(InternalAWSPinpoint) import InternalAWSPinpoint
import UserNotifications
Expand Down Expand Up @@ -59,6 +60,13 @@ extension AWSPinpointPushNotificationsPlugin {
}
#endif

/// Retrieves the escape hatch to perform actions directly on PinpointClient.
///
/// - Returns: PinpointClientProtocol instance
public func getEscapeHatch() -> PinpointClientProtocol {
pinpoint.pinpointClient
}

private func recordNotification(_ userInfo: [String: Any],
applicationState: ApplicationState,
action: PushNotification.Action) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import Amplify
import AWSPinpoint
@_spi(InternalAWSPinpoint) @testable import InternalAWSPinpoint
@testable import AWSPinpointPushNotificationsPlugin
import UserNotifications
Expand Down Expand Up @@ -206,6 +207,16 @@ class AWSPinpointPushNotificationsPluginClientBehaviourTests: AWSPinpointPushNot
}
#endif

// - MARK: Escape Hatch tests
func testGetEscapeHatch() {
guard let escapeHatch = plugin.getEscapeHatch() as? PinpointClient else {
XCTFail("Unable to retrieve PinpointClient")
return
}

XCTAssertTrue(escapeHatch === (mockPinpoint.pinpointClient as? PinpointClient))
}

private func createUserInfo(for source: PushNotification.Source) -> Notifications.Push.UserInfo {
return [
"data": [
Expand Down

0 comments on commit 2b0bdef

Please sign in to comment.