Giter Site home page Giter Site logo

Comments (14)

0xTim avatar 0xTim commented on July 21, 2024 1

I'm going to close this as it looks like there's a workaround and if you're having issues you should create an issue at https://github.com/kylebrowning/APNSwift

from apns.

marekpridal avatar marekpridal commented on July 21, 2024 1

This is the workaround which work for me

request.apns.send(rawBytes: payload,
                                  pushType: APNSwiftConnection.PushType.background,
                                  to: apnsToken,
                                  expiration: nil,
                                  priority: nil,
                                  collapseIdentifier: nil,
                                  topic: nil,
                                  logger: request.logger,
                                  apnsID: nil)

from apns.

idelfonsog2 avatar idelfonsog2 commented on July 21, 2024

Hi @MacFriis did you enable the background+remote notifications in the background modes?

which is different from the capability of push notification

from apns.

MacFriis avatar MacFriis commented on July 21, 2024

Hi @idelfonsog2, yes I have had this on all along, and I have made a lot of Remote Notification on Apple devices using other libraries for C#, and finished services where I can get the "content-available" to work without having a message within the notification.
I can't see what I'm doing wrong if it is working in the library.

from apns.

0xTim avatar 0xTim commented on July 21, 2024

This is probably better suited to https://github.com/kylebrowning/APNSwift as this package just proxies directly to that and that package does the actual sending.

Any idea on why this may be happening @kylebrowning ?

from apns.

kylebrowning avatar kylebrowning commented on July 21, 2024

Yup. This should be handle upstream. I’ll take a look!

from apns.

magnolialogic avatar magnolialogic commented on July 21, 2024

+1, running into this while porting a service from Python/PyAPNs2 to vapor/apns

from apns.

magnolialogic avatar magnolialogic commented on July 21, 2024

@MacFriis FWIW using apns.send(rawBytes: ...) works for me, instead of apns.send(payload: ...) or apns.send(notification: ...)

from apns.

FriisConsultApS avatar FriisConsultApS commented on July 21, 2024

@magnolialogic I'll give it a try

from apns.

marekpridal avatar marekpridal commented on July 21, 2024

@magnolialogic can you please send example code how you were able to send an update notification using rawBytes? I wasn't able to do so with code below.

Payload:
"{
    "aps" : { 
         "content-available" : 1 
    }
}"

request.apns.send(rawBytes: payload,
                                  pushType: APNSwiftConnection.PushType.alert,
                                  to: apnsToken,
                                  expiration: nil,
                                  priority: nil,
                                  collapseIdentifier: nil,
                                  topic: nil,
                                  logger: request.logger,
                                  apnsID: nil)

EDIT: Got this working by using APNSwiftConnection.PushType.background although testing of this feature on iOS is really tricky.

from apns.

DanSessions avatar DanSessions commented on July 21, 2024

Can anyone share the code for the workaround? Can't seem to get it working.

from apns.

FriisConsultApS avatar FriisConsultApS commented on July 21, 2024

Sorry, I have abandon the servicer side swift all together... now back on dotnet 6

from apns.

idelfonsog2 avatar idelfonsog2 commented on July 21, 2024

Thank you so much @marekpridal for sharing.

Mine was the followoing:

private func sendPushes(_ tokens: [String], alert: APNSwiftAlert , on req: Request) async throws {
...
      for token in tokens {
         do {
            try await req.apns.send(payload,
                                    pushType: .alert,
                                    to: token,
                                    with: JSONEncoder(),
                                    expiration: Date().addingTimeInterval(3600),
                                    priority: 10,
                                    collapseIdentifier: nil,
                                    topic: applicationTopic,
                                    logger: req.logger,
                                    apnsID: apnsID).get()
...
// to complete

from apns.

kylebrowning avatar kylebrowning commented on July 21, 2024
    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)

this worked for me.

from apns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.