I'm trying to setup Pusher to receive push notifications from my server. I've gone through the docs and followed the instructions but I'm getting this error which I have no clue how to get past. If you help me sort it out it'll be like an early Christmas gift.
This is my client code:
const beamsClient = new PusherPushNotifications.Client({
instanceId: 'XXXXX-XXXX-XXXXX-XXXX',
});
const beamsTokenProvider = new PusherPushNotifications.TokenProvider({
url: "/Account/BeamsAuth/",
});
var currentUserId = `@User.Identity.GetUserId()`;
beamsClient.start()
.then(() => beamsClient.setUserId(currentUserId, beamsTokenProvider))
.then(() => beamsClient.addDeviceInterest('WaitingForRide'))
.then(() => beamsClient.getDeviceInterests())
.then((interests) => console.log("Current interests: ", interests))
.then(() => console.log('Successfully registered and subscribed!'))
.catch(console.error);
This is my server code:
This is the error I'm seeing on my browser's console:
TypeError: Cannot read properties of null (reading 'token')
at Client._callee14$ (push-notifications-cdn.js:2102)
at tryCatch (push-notifications-cdn.js:82)
at Generator.invoke [as _invoke] (push-notifications-cdn.js:308)
at Generator.prototype.<computed> [as next] (push-notifications-cdn.js:134)
at asyncGeneratorStep (push-notifications-cdn.js:770)
at _next (push-notifications-cdn.js:792)
The token acquisition process to create an Authenticated User is described here:
I'm positive that I've implemented the token acquisition process correctly but I can't seem to get past this error. It's a total curveball.
I'm really at a loss of what to do here. I tried researching this particular error but didn't get anything back on it. Any ideas are appreciated.
You should ensure the token is in JSON format, such as:
{"token":"XXXXXXXXX"}