swift-server-community / APNSwift

📱HTTP/2 Apple Push Notification Service built with swift - send push notifications to iOS, iPadOS, tvOS, macOS, watchOS, visionOS, and Safari!
Apache License 2.0
686 stars 103 forks source link

Can't send "content-available" on its own #126

Closed marekpridal closed 2 years ago

marekpridal commented 2 years ago

This issue was originally reported in Vapor project but based on discussion it should be probably resolved inside this repo. There is a workaround which requires creating payload from raw data.

DanSessions commented 2 years ago

Having the same issue. @marekpridal, can you share the code for the workaround? Can't get it working.

kylebrowning commented 2 years ago

Hmm this seems to be working for me, would love to see the raw payload so I can make changes for an interface if necesary

kylebrowning commented 2 years ago
        let payload = APNSPayload(hasContentAvailable: true)
        let acme = AcmeNotification(acme1: "hey", acme2: 2, aps: payload)
        try! await req.apns.client.send(acme, pushType: .background, to: dt, priority: 5)

here's the code that worked for me. Going to close this issue, but please re-open if its still an issue for you