Skip to content
Closed
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
8 changes: 2 additions & 6 deletions LoopFollow/Remote/TRC/PushMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@ struct EncryptedPushMessage: Encodable {
let aps: APSPayload
let encryptedData: String

init(encryptedData: String, commandType: TRCCommandType) {
init(encryptedData: String, commandType _: TRCCommandType) {
self.encryptedData = encryptedData
aps = APSPayload(alert: "Remote Command: \(commandType.displayName)")
aps = APSPayload()
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This article says background notifications should not contain alert: developer.apple.com/documentation/usernotifications/pushing-background-updates-to-your-app

}

struct APSPayload: Encodable {
let contentAvailable: Int = 1
let interruptionLevel: String = "time-sensitive"
let alert: String

enum CodingKeys: String, CodingKey {
case contentAvailable = "content-available"
case interruptionLevel = "interruption-level"
case alert
}
}

Expand Down
4 changes: 2 additions & 2 deletions LoopFollow/Remote/TRC/PushNotificationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ class PushNotificationManager {
request.httpMethod = "POST"
request.setValue("bearer \(jwt)", forHTTPHeaderField: "authorization")
request.setValue("application/json", forHTTPHeaderField: "content-type")
request.setValue("10", forHTTPHeaderField: "apns-priority")
request.setValue("5", forHTTPHeaderField: "apns-priority")
request.setValue("600", forHTTPHeaderField: "apns-expiration")
request.setValue(bundleId, forHTTPHeaderField: "apns-topic")
request.setValue("alert", forHTTPHeaderField: "apns-push-type")
request.setValue("background", forHTTPHeaderField: "apns-push-type")
request.setValue(payload.commandType.rawValue, forHTTPHeaderField: "apns-collapse-id")

request.httpBody = try JSONEncoder().encode(finalMessage)
Expand Down