pubnub / js-chat

PubNub JavaScript Chat SDK
https://github.com/pubnub/js-chat
8 stars 8 forks source link

Push Payload does not properly set the environment for APNS from init configuration #164

Closed jarchowk closed 5 months ago

jarchowk commented 5 months ago

I don't believe apnsEnvironment is actually ever sent in the message push payload, and is always sent with the "development" default from the javascript SDK.

Example of my Chat.init:

Chat.init({
        ...
        pushNotifications:  {
              sendPushes: false,
              deviceToken: deviceToken,
              deviceGateway: "apns2",
              apnsTopic: "<topic>",
              apnsEnvironment: "production",
            },
         ...
      });

In the file js-chat: js-chat/lib/src/entities/channel.ts:

protected getPushPayload(text: string) {
const { sendPushes, apnsTopic } = this.chat.config.pushNotifications
if (!sendPushes) return {}

const title = this.chat.currentUser.name || this.chat.currentUser.id
const pushBuilder = PubNub.notificationPayload(title, text)
const pushGateways = ["fcm"]
pushBuilder.sound = "default"
if (this.name) pushBuilder.subtitle = this.name
if (apnsTopic) {
pushBuilder.apns.configurations = [{ targets: [{ topic: apnsTopic }] }]
pushGateways.push("apns2")
}

return pushBuilder.buildPayload(pushGateways)
}
Salet commented 5 months ago

Thanks for your input and patience @jarchowk, happy to inform this has been fixed in #167 and included in both 0.6.2 and 0.7.0 versions released today.