Open ddhanak opened 3 years ago
@benw-pusher hi ben, is it possible to know if this will be prioritized or not?
I have shared the feedback internally but at this time we cannot commit to a release.
@benw-pusher hi any news on this? it has been more than a year now.
Unfortunately, at this time we don't have this work scheduled.
Actually, this is already possible.
Client.setUserId()
takes in an interface (ITokenProvider
):
https://github.com/pusher/push-notifications-web/blob/691ee3200e781a5313b4be331a7b2aa3aac665db/index.d.ts#L42
https://github.com/pusher/push-notifications-web/blob/691ee3200e781a5313b4be331a7b2aa3aac665db/index.d.ts#L4-L6
https://github.com/pusher/push-notifications-web/blob/691ee3200e781a5313b4be331a7b2aa3aac665db/index.d.ts#L1-L3
You'll just need to create your own ITokenProvider
implementation that returns the token immediately, e.g.
client.setUserId(userId, {
fetchToken: () => Promise.resolve({ token }),
});
I have tried multiple versions of the custom ITokenProvider
approach, and it's working locally (I can see "Device paired with User" in the Pusher debug console) but when it's deployed to prod, I get Error: Unexpected status code 401: Unauthorized, Invalid JWT signature
.
The token is being returned by my server and when decoded, it is the same shape as it is locally.
Any idea what might be happening?
Allow passing in the beams token when setting userId (instead of fetching from tokenProvider).
https://github.com/pusher/push-notifications-web/blob/master/src/push-notifications.js#L328
Use case: we have implemented our own logic to fetch the beams token (and we do not want to use the TokenProvider class that sends a request for us through the SDK).