Skip to content

Commit 9eb4200

Browse files
sebalandameter
authored andcommitted
fix: Making OptOut nil when no address is present on the endpoint. (#2796)
1 parent b8e6b58 commit 9eb4200

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

AmplifyPlugins/Internal/Sources/InternalAWSPinpoint/Endpoint/EndpointClient.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,10 @@ actor EndpointClient: EndpointClientBehaviour {
191191
endpointProfile.effectiveDate.asISO8601String
192192
}
193193

194-
nonisolated private func getOptOut(from endpointProfile: PinpointEndpointProfile) -> String {
194+
nonisolated private func getOptOut(from endpointProfile: PinpointEndpointProfile) -> String? {
195+
if endpointProfile.deviceToken == nil {
196+
return nil
197+
}
195198
return endpointProfile.isOptOut ? EndpointClient.Constants.OptOut.all : EndpointClient.Constants.OptOut.none
196199
}
197200

AmplifyPlugins/Internal/Tests/InternalAWSPinpointUnitTests/EndpointClientTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class EndpointClientTests: XCTestCase {
188188
XCTAssertEqual(publicEndpoint.attributes?.count, 0)
189189
XCTAssertEqual(publicEndpoint.metrics?.count, 0)
190190
XCTAssertNil(publicEndpoint.channelType)
191-
XCTAssertEqual(publicEndpoint.optOut, "NONE")
191+
XCTAssertNil(publicEndpoint.optOut)
192192
XCTAssertEqual(publicEndpoint.demographic?.appVersion, mockModel.appVersion)
193193
XCTAssertEqual(publicEndpoint.demographic?.make, "apple")
194194
XCTAssertEqual(publicEndpoint.demographic?.model, mockModel.model)

0 commit comments

Comments
 (0)