Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Encoding Firebase push notification keys #187

Merged
merged 27 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
env:
CI_XCODE_OLDEST: '/Applications/Xcode_14.2.app/Contents/Developer'
CI_XCODE_14: '/Applications/Xcode_14.3.1.app/Contents/Developer'
CI_XCODE_LATEST: '/Applications/Xcode_15.4.app/Contents/Developer'
CI_XCODE_LATEST: '/Applications/Xcode_16.2.app/Contents/Developer'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -19,21 +19,21 @@ concurrency:
jobs:
test:
timeout-minutes: 25
runs-on: macos-14
runs-on: macos-15
strategy:
matrix:
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']
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']
action: ['test', 'build']
exclude:
- destination: 'platform=iOS\ Simulator,OS=17.5,name=iPhone\ 15\ Pro\ Max'
- destination: 'platform=iOS\ Simulator,OS=18.2,name=iPhone\ 16\ Pro\ Max'
action: 'build'
- destination: 'platform\=tvOS\ Simulator,OS=17.5,name\=Apple\ TV'
- destination: 'platform\=tvOS\ Simulator,OS=18.2,name\=Apple\ TV'
action: 'build'
- destination: 'platform=macOS'
action: 'build'
- destination: 'platform=visionOS\ Simulator,OS=1.2,name=Apple\ Vision\ Pro'
- destination: 'platform=visionOS\ Simulator,OS=2.2,name=Apple\ Vision\ Pro'
action: 'test'
- destination: 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 9\ \(41mm\)'
- destination: 'platform=watchOS\ Simulator,name=Apple\ Watch\ Series\ 10\ \(42mm\)'
action: 'test'
steps:
- uses: actions/checkout@v4
Expand All @@ -55,6 +55,7 @@ jobs:
with:
format: lcov
search-paths: ./DerivedData
ignore-conversion-failures: true
env:
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}
- name: Upload coverage to Codecov
Expand All @@ -68,7 +69,7 @@ jobs:

spm-test:
timeout-minutes: 25
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Create and set the default keychain
Expand All @@ -89,6 +90,7 @@ jobs:
with:
format: lcov
search-paths: ./.build
ignore-conversion-failures: true
env:
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}
- name: Upload coverage to Codecov
Expand All @@ -104,11 +106,11 @@ jobs:
xcode-test-5_7:
timeout-minutes: 25
needs: linux
runs-on: macos-12
runs-on: macos-13
steps:
- uses: actions/checkout@v4
- name: Build-Test
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
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
env:
DEVELOPER_DIR: ${{ env.CI_XCODE_OLDEST }}

Expand Down Expand Up @@ -156,7 +158,7 @@ jobs:
docs:
timeout-minutes: 10
needs: linux
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Generate Docs
Expand All @@ -166,7 +168,7 @@ jobs:

cocoapods:
needs: linux
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Update Framework Version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
types: [published]
env:
CI_XCODE_14: '/Applications/Xcode_14.3.1.app/Contents/Developer'
CI_XCODE_LATEST: '/Applications/Xcode_15.4.app/Contents/Developer'
CI_XCODE_LATEST: '/Applications/Xcode_16.1.app/Contents/Developer'

jobs:
cocoapods:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Get release version
Expand All @@ -24,7 +24,7 @@ jobs:
DEVELOPER_DIR: ${{ env.CI_XCODE_LATEST }}

docs:
runs-on: macos-14
runs-on: macos-15
steps:
- uses: actions/checkout@v4
- name: Get release version
Expand Down
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ disabled_rules:
- identifier_name
- blanket_disable_command
- non_optional_string_data_conversion
- optional_data_string_conversion
excluded: # paths to ignore during linting. Takes precedence over `included`.
- Tests/ParseSwiftTests/ParseEncoderTests
- DerivedData
Expand Down
4 changes: 2 additions & 2 deletions Sources/ParseSwift/API/API+Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal extension API {
allowIntermediateResponses: Bool = false,
uploadProgress: ((URLSessionTask, Int64, Int64, Int64) -> Void)? = nil,
downloadProgress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)? = nil,
completion: @escaping(Result<U, ParseError>) -> Void) async {
completion: @escaping (Result<U, ParseError>) -> Void) async {
let currentNotificationQueue: DispatchQueue!
if let notificationQueue = notificationQueue {
currentNotificationQueue = notificationQueue
Expand Down Expand Up @@ -257,7 +257,7 @@ internal extension API {
batching: Bool = false,
childObjects: [String: PointerType]? = nil,
childFiles: [String: ParseFile]? = nil,
completion: @escaping(Result<URLRequest, ParseError>) -> Void) {
completion: @escaping (Result<URLRequest, ParseError>) -> Void) {
let params = self.params?.getURLQueryItems()
Task {
do {
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseSwift/API/API+NonParseBodyCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal extension API {
func execute(options: API.Options,
callbackQueue: DispatchQueue,
allowIntermediateResponses: Bool = false,
completion: @escaping(Result<U, ParseError>) -> Void) async {
completion: @escaping (Result<U, ParseError>) -> Void) async {

switch await self.prepareURLRequest(options: options) {
case .success(let urlRequest):
Expand Down
8 changes: 4 additions & 4 deletions Sources/ParseSwift/Extensions/URLSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ internal extension URLSession {
attempts: Int = 1,
allowIntermediateResponses: Bool,
mapper: @escaping (Data) async throws -> U,
completion: @escaping(Result<U, ParseError>) -> Void
completion: @escaping (Result<U, ParseError>) -> Void
) async {
do {
let (responseData, urlResponse) = try await dataTask(for: request)
Expand Down Expand Up @@ -288,7 +288,7 @@ internal extension URLSession {
from file: URL?,
progress: ((URLSessionTask, Int64, Int64, Int64) -> Void)?,
mapper: @escaping (Data) async throws -> U,
completion: @escaping(Result<U, ParseError>) -> Void
completion: @escaping (Result<U, ParseError>) -> Void
) {
var task: URLSessionTask?
if let data = data {
Expand Down Expand Up @@ -354,7 +354,7 @@ internal extension URLSession {
with request: URLRequest,
progress: ((URLSessionDownloadTask, Int64, Int64, Int64) -> Void)?,
mapper: @escaping (Data) async throws -> U,
completion: @escaping(Result<U, ParseError>) -> Void
completion: @escaping (Result<U, ParseError>) -> Void
) async {
let task = downloadTask(with: request) { (location, urlResponse, responseError) in
Task {
Expand All @@ -374,7 +374,7 @@ internal extension URLSession {
func downloadTask<U>(
with request: URLRequest,
mapper: @escaping (Data) async throws -> U,
completion: @escaping(Result<U, ParseError>) -> Void
completion: @escaping (Result<U, ParseError>) -> Void
) {
Task {
do {
Expand Down
10 changes: 5 additions & 5 deletions Sources/ParseSwift/Storage/ParseFileManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ extension ParseFileManager {
}
}

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

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

func copyItem(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
func copyItem(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
synchronizationQueue.async {
do {
try FileManager.default.copyItem(at: fromPath, to: toPath)
Expand All @@ -149,7 +149,7 @@ extension ParseFileManager {
}
}

func moveItem(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
func moveItem(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
synchronizationQueue.async {
if fromPath != toPath {
do {
Expand All @@ -164,7 +164,7 @@ extension ParseFileManager {
}
}

func moveContentsOfDirectory(_ fromPath: URL, toPath: URL, completion: @escaping(Error?) -> Void) {
func moveContentsOfDirectory(_ fromPath: URL, toPath: URL, completion: @escaping (Error?) -> Void) {
synchronizationQueue.async {
do {
if fromPath == toPath {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ public struct ParsePushFirebaseNotification: ParseTypeable {
enum CodingKeys: String, CodingKey {
case titleLocKey = "title_loc_key"
case titleLocArgs = "title_loc_args"
case bodyLocKey = "body_loc-key"
case bodyLocArgs = "body-loc-args"
case bodyLocKey = "body_loc_key"
case bodyLocArgs = "body_loc_args"
case clickAction = "click_action"
case androidChannelId = "android_channel_id"
case title, icon, body, sound, badge, tag,
Expand Down
4 changes: 2 additions & 2 deletions Tests/ParseSwiftTests/ParsePushPayloadAnyTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ParsePushPayloadAnyTests: XCTestCase {
XCTAssertEqual(decodedAny2, applePayload)
#if !os(Linux) && !os(Android) && !os(Windows)
XCTAssertEqual(fcmPayload.description,
"{\"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\"}")
"{\"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\"}")
#endif
}

Expand Down Expand Up @@ -230,7 +230,7 @@ class ParsePushPayloadAnyTests: XCTestCase {
XCTAssertEqual(decoded2, fcmPayload)
#if !os(Linux) && !os(Android) && !os(Windows)
XCTAssertEqual(fcmPayload.description,
"{\"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\"}")
"{\"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\"}")
#endif
}
}
2 changes: 1 addition & 1 deletion Tests/ParseSwiftTests/ParsePushPayloadFirebaseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ParsePushPayloadFirebaseTests: XCTestCase {
XCTAssertEqual(fcmPayload, decoded)
#if !os(Linux) && !os(Android) && !os(Windows)
XCTAssertEqual(fcmPayload.description,
"{\"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\"}")
"{\"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\"}")
#endif
}
}
Loading