Skip to content

Commit 0d51e70

Browse files
authored
fix: Encoding Firebase push notification keys (#187)
* fix: Build for Swift 6.0.1 on Linux * Update ci.yml * Update release.yml * Update release.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * Update ci.yml * fix encoding order * Update ci.yml * Update ci.yml * Update Package.swift * Update Package.swift * Update ci.yml * Update ci.yml * Use macOS 13 runner * Update ci.yml * Update ci.yml * Update ci.yml * fix encoding Firebase push keys
1 parent 4799684 commit 0d51e70

File tree

10 files changed

+35
-32
lines changed

10 files changed

+35
-32
lines changed

.github/workflows/ci.yml

+14-12
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
env:
1111
CI_XCODE_OLDEST: '/Applications/Xcode_14.2.app/Contents/Developer'
1212
CI_XCODE_14: '/Applications/Xcode_14.3.1.app/Contents/Developer'
13-
CI_XCODE_LATEST: '/Applications/Xcode_15.4.app/Contents/Developer'
13+
CI_XCODE_LATEST: '/Applications/Xcode_16.2.app/Contents/Developer'
1414

1515
concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
@@ -19,21 +19,21 @@ concurrency:
1919
jobs:
2020
test:
2121
timeout-minutes: 25
22-
runs-on: macos-14
22+
runs-on: macos-15
2323
strategy:
2424
matrix:
25-
destination: ['platform=iOS\ Simulator,OS=17.5,name=iPhone\ 15\ Pro\ Max', 'platform\=tvOS\ Simulator,OS=17.5,name\=Apple\ TV', 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 9\ \(41mm\)', 'platform=macOS', 'platform=visionOS\ Simulator,OS=1.2,name=Apple\ Vision\ Pro']
25+
destination: ['platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max', 'platform\=tvOS\ Simulator,OS=18.2,name\=Apple\ TV', 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 10\ \(42mm\)', 'platform=macOS', 'platform=visionOS\ Simulator,OS=2.2,name=Apple\ Vision\ Pro']
2626
action: ['test', 'build']
2727
exclude:
28-
- destination: 'platform=iOS\ Simulator,OS=17.5,name=iPhone\ 15\ Pro\ Max'
28+
- destination: 'platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max'
2929
action: 'build'
30-
- destination: 'platform\=tvOS\ Simulator,OS=17.5,name\=Apple\ TV'
30+
- destination: 'platform\=tvOS\ Simulator,OS=18.2,name\=Apple\ TV'
3131
action: 'build'
3232
- destination: 'platform=macOS'
3333
action: 'build'
34-
- destination: 'platform=visionOS\ Simulator,OS=1.2,name=Apple\ Vision\ Pro'
34+
- destination: 'platform=visionOS\ Simulator,OS=2.2,name=Apple\ Vision\ Pro'
3535
action: 'test'
36-
- destination: 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 9\ \(41mm\)'
36+
- destination: 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 10\ \(42mm\)'
3737
action: 'test'
3838
steps:
3939
- uses: actions/checkout@v4
@@ -55,6 +55,7 @@ jobs:
5555
with:
5656
format: lcov
5757
search-paths: ./DerivedData
58+
ignore-conversion-failures: true
5859
env:
5960
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}
6061
- name: Upload coverage to Codecov
@@ -68,7 +69,7 @@ jobs:
6869

6970
spm-test:
7071
timeout-minutes: 25
71-
runs-on: macos-14
72+
runs-on: macos-15
7273
steps:
7374
- uses: actions/checkout@v4
7475
- name: Create and set the default keychain
@@ -89,6 +90,7 @@ jobs:
8990
with:
9091
format: lcov
9192
search-paths: ./.build
93+
ignore-conversion-failures: true
9294
env:
9395
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}
9496
- name: Upload coverage to Codecov
@@ -104,11 +106,11 @@ jobs:
104106
xcode-test-5_7:
105107
timeout-minutes: 25
106108
needs: linux
107-
runs-on: macos-12
109+
runs-on: macos-13
108110
steps:
109111
- uses: actions/checkout@v4
110112
- name: Build-Test
111-
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace Parse.xcworkspace -scheme ParseSwift -destination platform\=iOS\ Simulator,name\=iPhone\ 13\ Pro\ Max -derivedDataPath DerivedData build 2>&1 | xcbeautify --renderer github-actions
113+
run: set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace Parse.xcworkspace -scheme ParseSwift -destination platform\=iOS\ Simulator,name\=iPhone\ 14\ Pro\ Max -derivedDataPath DerivedData build 2>&1 | xcbeautify --renderer github-actions
112114
env:
113115
DEVELOPER_DIR: ${{ env.CI_XCODE_OLDEST }}
114116

@@ -156,7 +158,7 @@ jobs:
156158
docs:
157159
timeout-minutes: 10
158160
needs: linux
159-
runs-on: macos-14
161+
runs-on: macos-15
160162
steps:
161163
- uses: actions/checkout@v4
162164
- name: Generate Docs
@@ -166,7 +168,7 @@ jobs:
166168

167169
cocoapods:
168170
needs: linux
169-
runs-on: macos-14
171+
runs-on: macos-15
170172
steps:
171173
- uses: actions/checkout@v4
172174
- name: Update Framework Version

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ on:
44
types: [published]
55
env:
66
CI_XCODE_14: '/Applications/Xcode_14.3.1.app/Contents/Developer'
7-
CI_XCODE_LATEST: '/Applications/Xcode_15.4.app/Contents/Developer'
7+
CI_XCODE_LATEST: '/Applications/Xcode_16.1.app/Contents/Developer'
88

99
jobs:
1010
cocoapods:
11-
runs-on: macos-14
11+
runs-on: macos-15
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Get release version
@@ -24,7 +24,7 @@ jobs:
2424
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}
2525

2626
docs:
27-
runs-on: macos-14
27+
runs-on: macos-15
2828
steps:
2929
- uses: actions/checkout@v4
3030
- name: Get release version

.swiftlint.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ disabled_rules:
33
- identifier_name
44
- blanket_disable_command
55
- non_optional_string_data_conversion
6+
- optional_data_string_conversion
67
excluded: # paths to ignore during linting. Takes precedence over `included`.
78
- Tests/ParseSwiftTests/ParseEncoderTests
89
- DerivedData

Sources/ParseSwift/API/API+Command.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ internal extension API {
100100
allowIntermediateResponses: Bool = false,
101101
uploadProgress: ((URLSessionTask, Int64, Int64, Int64) -> Void)? = nil,
102102
downloadProgress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? = nil,
103-
completion: @escaping(Result<U, ParseError>) -> Void) async {
103+
completion: @escaping (Result<U, ParseError>) -> Void) async {
104104
let currentNotificationQueue: DispatchQueue!
105105
if let notificationQueue = notificationQueue {
106106
currentNotificationQueue = notificationQueue
@@ -257,7 +257,7 @@ internal extension API {
257257
batching: Bool = false,
258258
childObjects: [String: PointerType]? = nil,
259259
childFiles: [String: ParseFile]? = nil,
260-
completion: @escaping(Result<URLRequest, ParseError>) -> Void) {
260+
completion: @escaping (Result<URLRequest, ParseError>) -> Void) {
261261
let params = self.params?.getURLQueryItems()
262262
Task {
263263
do {

Sources/ParseSwift/API/API+NonParseBodyCommand.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ internal extension API {
3737
func execute(options: API.Options,
3838
callbackQueue: DispatchQueue,
3939
allowIntermediateResponses: Bool = false,
40-
completion: @escaping(Result<U, ParseError>) -> Void) async {
40+
completion: @escaping (Result<U, ParseError>) -> Void) async {
4141

4242
switch await self.prepareURLRequest(options: options) {
4343
case .success(let urlRequest):

Sources/ParseSwift/Extensions/URLSession.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ internal extension URLSession {
143143
attempts: Int = 1,
144144
allowIntermediateResponses: Bool,
145145
mapper: @escaping (Data) async throws -> U,
146-
completion: @escaping(Result<U, ParseError>) -> Void
146+
completion: @escaping (Result<U, ParseError>) -> Void
147147
) async {
148148
do {
149149
let (responseData, urlResponse) = try await dataTask(for: request)
@@ -288,7 +288,7 @@ internal extension URLSession {
288288
from file: URL?,
289289
progress: ((URLSessionTask, Int64, Int64, Int64) -> Void)?,
290290
mapper: @escaping (Data) async throws -> U,
291-
completion: @escaping(Result<U, ParseError>) -> Void
291+
completion: @escaping (Result<U, ParseError>) -> Void
292292
) {
293293
var task: URLSessionTask?
294294
if let data = data {
@@ -354,7 +354,7 @@ internal extension URLSession {
354354
with request: URLRequest,
355355
progress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)?,
356356
mapper: @escaping (Data) async throws -> U,
357-
completion: @escaping(Result<U, ParseError>) -> Void
357+
completion: @escaping (Result<U, ParseError>) -> Void
358358
) async {
359359
let task = downloadTask(with: request) { (location, urlResponse, responseError) in
360360
Task {
@@ -374,7 +374,7 @@ internal extension URLSession {
374374
func downloadTask<U>(
375375
with request: URLRequest,
376376
mapper: @escaping (Data) async throws -> U,
377-
completion: @escaping(Result<U, ParseError>) -> Void
377+
completion: @escaping (Result<U, ParseError>) -> Void
378378
) {
379379
Task {
380380
do {

Sources/ParseSwift/Storage/ParseFileManager.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extension ParseFileManager {
112112
}
113113
}
114114

115-
func writeString(_ string: String, filePath: URL, completion: @escaping(Error?) -> Void) {
115+
func writeString(_ string: String, filePath: URL, completion: @escaping (Error?) -> Void) {
116116
synchronizationQueue.async {
117117
do {
118118
guard let data = string.data(using: .utf8) else {
@@ -127,7 +127,7 @@ extension ParseFileManager {
127127
}
128128
}
129129

130-
func writeData(_ data: Data, filePath: URL, completion: @escaping(Error?) -> Void) {
130+
func writeData(_ data: Data, filePath: URL, completion: @escaping (Error?) -> Void) {
131131
synchronizationQueue.async {
132132
do {
133133
try data.write(to: filePath, options: self.defaultDataWritingOptions)
@@ -138,7 +138,7 @@ extension ParseFileManager {
138138
}
139139
}
140140

141-
func copyItem(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
141+
func copyItem(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
142142
synchronizationQueue.async {
143143
do {
144144
try FileManager.default.copyItem(at: fromPath, to: toPath)
@@ -149,7 +149,7 @@ extension ParseFileManager {
149149
}
150150
}
151151

152-
func moveItem(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
152+
func moveItem(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
153153
synchronizationQueue.async {
154154
if fromPath != toPath {
155155
do {
@@ -164,7 +164,7 @@ extension ParseFileManager {
164164
}
165165
}
166166

167-
func moveContentsOfDirectory(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
167+
func moveContentsOfDirectory(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
168168
synchronizationQueue.async {
169169
do {
170170
if fromPath == toPath {

Sources/ParseSwift/Types/ParsePushPayload/Firebase/ParsePushFirebaseNotification.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public struct ParsePushFirebaseNotification: ParseTypeable {
128128
enum CodingKeys: String, CodingKey {
129129
case titleLocKey = "title_loc_key"
130130
case titleLocArgs = "title_loc_args"
131-
case bodyLocKey = "body_loc-key"
132-
case bodyLocArgs = "body-loc-args"
131+
case bodyLocKey = "body_loc_key"
132+
case bodyLocArgs = "body_loc_args"
133133
case clickAction = "click_action"
134134
case androidChannelId = "android_channel_id"
135135
case title, icon, body, sound, badge, tag,

Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class ParsePushPayloadAnyTests: XCTestCase {
115115
XCTAssertEqual(decodedAny2, applePayload)
116116
#if !os(Linux) && !os(Android) && !os(Windows)
117117
XCTAssertEqual(fcmPayload.description,
118-
"{\"collapseKey\":\"nope\",\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc-key\":\"cousin\",\"body-loc-args\":[\"mother\"],\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
118+
"{\"collapseKey\":\"nope\",\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc_args\":[\"mother\"],\"body_loc_key\":\"cousin\",\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
119119
#endif
120120
}
121121

@@ -230,7 +230,7 @@ class ParsePushPayloadAnyTests: XCTestCase {
230230
XCTAssertEqual(decoded2, fcmPayload)
231231
#if !os(Linux) && !os(Android) && !os(Windows)
232232
XCTAssertEqual(fcmPayload.description,
233-
"{\"collapseKey\":\"nope\",\"contentAvailable\":true,\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"mutableContent\":true,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc-key\":\"cousin\",\"body-loc-args\":[\"mother\"],\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"priority\":\"high\",\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
233+
"{\"collapseKey\":\"nope\",\"contentAvailable\":true,\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"mutableContent\":true,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc_args\":[\"mother\"],\"body_loc_key\":\"cousin\",\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"priority\":\"high\",\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
234234
#endif
235235
}
236236
}

Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class ParsePushPayloadFirebaseTests: XCTestCase {
7373
XCTAssertEqual(fcmPayload, decoded)
7474
#if !os(Linux) && !os(Android) && !os(Windows)
7575
XCTAssertEqual(fcmPayload.description,
76-
"{\"collapseKey\":\"nope\",\"contentAvailable\":true,\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"mutableContent\":true,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc-key\":\"cousin\",\"body-loc-args\":[\"mother\"],\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"priority\":\"high\",\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
76+
"{\"collapseKey\":\"nope\",\"contentAvailable\":true,\"data\":{\"help\":\"you\"},\"delayWhileIdle\":false,\"dryRun\":false,\"mutableContent\":true,\"notification\":{\"android_channel_id\":\"you\",\"badge\":\"no\",\"body\":\"android\",\"body_loc_args\":[\"mother\"],\"body_loc_key\":\"cousin\",\"click_action\":\"to\",\"color\":\"blue\",\"icon\":\"world\",\"image\":\"icon\",\"sound\":\"yes\",\"subtitle\":\"trip\",\"tag\":\"it\",\"title\":\"hello\",\"title_loc_args\":[\"arg\"],\"title_loc_key\":\"it\"},\"priority\":\"high\",\"restrictedPackageName\":\"geez\",\"title\":\"peace\",\"uri\":\"https:\\/\\/parse.org\"}")
7777
#endif
7878
}
7979
}

0 commit comments

Comments
 (0)