I have found a scrappy solution.
You will need to use the platfrom API and install the following two commands.
- cordova plugin add phonegap-plugin-push --variable SENDER_ID="xxxxxxxx" --save
- cordova plugin add cordova-plugin-fcm
Before the above works in your project you will need to follow the steps 1 & 2 for Android and/or 1,2 and 3 for iOs.
Once all is complete you should have put the following two files in the root directory of your project such that "www" is a sibling to the files in terms of hierarchy.
- google-services.json
- GoogleService-Info.plist
once compelete follow this step from phone-gap-push. You ideally only need the following snippet to register the token.
const push = PushNotification.init({
android: {
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});
push.on('registration', (data) => {
// what you get back in your data variable will be two things
// registrationId and registrationType
// Use the returned values to make the platform api call to sendbird
});
Important things to note sendbird only send push notifications when you are offline. Either the iOs or Android documentaion for push notifications highlights these disclaimers very well.
By setting up push notification service to an app, your app users can receive messages even when they are offline. Typically, you might want users to receive push notifications after their app goes into the background. SendBird SDK automatically detects if your app enters the background and updates the user's connection status to Disconnected. Therefore, in normal cases, you do not have to call disconnect explicitly.
There you have it a corodva/phonegap/javascript implementation of push notifications on Sendbird.
And no I can't tell you why Sendbird didn't document similar! If anyone has a better more efficient way I am all ears.