0

We have use-case where we need to send push notification from our backend to buildfire application. And in order to do so, we would need device token on backend.

We tried to extract it using following function in custom plugin but we are getting its value as empty string. We tested this in TestFlight build.

buildfire.getContext(function (err, result) {
  console.log(result.deviceId)
}

We have uploaded firebase certificate to Buildfire and have also linked APNs to it.

If anyone can guide us with this, it will be a great help.

Raeesaa
  • 3,267
  • 2
  • 22
  • 44
  • Have a look at [FIRMessaging](https://firebase.google.com/docs/reference/ios/firebasemessaging/api/reference/Classes/FIRMessaging) class to extract the APNS token and send it to your backend. You should also consider [Firebase Cloud messaging](https://firebase.google.com/docs/cloud-messaging) to send messages from your backend, instead of dealing with the APNS token directly. – mani Sep 21 '22 at 14:59

1 Answers1

0

context.deviceId is not a supported property. Following are the supported documented properties in context: https://sdk.buildfire.com/docs/context/#data

You can also take a look at https://sdk.buildfire.com/AWSGatewayPublicAPI/#/push_notifications and https://sdk.buildfire.com/docs/push-notifications/#schedule to see how push notifications can be triggered from a server or device.

blue
  • 209
  • 1
  • 7
  • Any idea how do we retrieve `deviceToken` using Buildfire SDK? – Raeesaa Sep 25 '22 at 18:06
  • I read in one of the github issues that device token is exposed as `deviceId` field in context object and therefore, we were trying that - https://github.com/BuildFire/simpleBuildFireJSExamples/issues/2#issuecomment-277112193 – Raeesaa Sep 25 '22 at 20:04
  • @Raeesaa I see, this is a prior to releasing the gateway API so your best option is use the API. Also this way you would not have to track changes on tokens. – blue Sep 28 '22 at 22:44
  • We are not saving users on Buildfire server, we have custom backend which is being used by another web app. And therefore, we won't be able to use public API to trigger notifications as we don't have userIds that Buildfire API recognises. Not sure if there is any work-around this. – Raeesaa Sep 29 '22 at 06:50
  • We were planning to register user on Buildfire after they register on our service and perform Buildfire login in background when they login to the app. But looks like implementing second part is not possible as we don't have REST API for login (Buildfire SDK's login API opens login screen which we don't want to do). – Raeesaa Sep 29 '22 at 06:53
  • Have you considered OAuth2 implementation on your servers https://sdk.buildfire.com/docs/using-oauth2-sign-in-integration/ ? this way you have full control over the login process – blue Oct 05 '22 at 16:53