PushNotifications icon indicating copy to clipboard operation
PushNotifications copied to clipboard

Is there a way to include apns headers

Open michzio opened this issue 4 years ago • 7 comments

With watchOS 6 standalone and i think new app there is requirement for

"apns-topic": "#bundle-id" , "apns-push-type": "alert",

I think it should go not into body but into the header. So it will be nice to define header fields!

michzio avatar Mar 14 '20 09:03 michzio

Hi @michzio The app sets these headers automatically, both apns-topic and apns-push-type.

Without apns-topic the notifications wouldn't work at all and when you specify bundle id, you set the header. apns-push-type was defined starting from iOS 13 and app version 1.7.0+ supports it.

Please, check out the latest stable release if you are using an old version and having any issues with that: https://github.com/onmyway133/PushNotifications/releases

Ariandr avatar Mar 14 '20 09:03 Ariandr

Ok cause I am searching for reason why my standalone watchOS app is not receiving push notifications but through iOS app it is delivered to watch correctly.

michzio avatar Mar 16 '20 15:03 michzio

Hi @michzio Okay, I see. I will close the issue for now, but if you find something specific, please feel free to create a new issue or reopen this one with additional details.

Ariandr avatar Mar 18 '20 09:03 Ariandr

Good day! Is there way to change apns-push-type from "alert" to "background"?

ArturRuZ avatar Apr 21 '21 14:04 ArturRuZ

Hi @ArturRuZ Now it's set if content-available == 1 and there are no other fields included in aps (exception is category)

.....
 .... else if (aps && aps["content-available"] === 1) {
        const maxKeysNumber = aps.hasOwnProperty("category") ? 2 : 1

        let size = 0, key
        for (key in aps) {
          size++
        }

        if (size === maxKeysNumber) {
          notification.pushType = "background"
          notification.priority = 5
        }
      }

Ariandr avatar Apr 22 '21 16:04 Ariandr

Hello,

Is it possible to add apns-id, apns-expiration, and apns-collapse-id headers?

Reference: https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

max-potapov avatar Nov 18 '22 10:11 max-potapov

Hi @max-potapov You can enter collapse id from the UI and it's send inside apns-collapse-id header. Two others are not available to enter now.

Ariandr avatar Nov 18 '22 11:11 Ariandr