Mobile Push Notifications

If you use TalkJS inside of a mobile app, you might want to use push notifications.

The React Native guide shows you how to set up push notifications in your app when using the React Native SDK.

The Flutter guide shows you how to set up push notifications in your app when using the Flutter SDK.

To use push notifications with TalkJS, you need to do three things:

  1. Add your Apple and Google credentials on the Settings page in your TalkJS dashboard
  2. Add some code to your app that registers your user's device for push notifications. This is documented below.
  3. Optionally, add code that captures the push notifications that TalkJS sends and performs actions based on it (for example, add a notifications to the phone's action center, open the app on the right page when the notifications is tapped, and so on).

In the JavaScript SDK, TalkJS sessions have a function called setPushRegistration which you should call to give TalkJS permission to send push notifications to this user. You first obtain the user's device token or registration token. How this you do this depends on the language and platform you use for developing your app. Then, you make the following call to the JS SDK:

1session.setPushRegistration({ provider: 'apns', pushRegistrationId: token });


1session.setPushRegistration({ provider: 'fcm', pushRegistrationId: token });

The function returns a JavaScript Promise object which resolves once the data was sent successfully to the TalkJS server. The same Promise object is rejected in case of any errors.

That's it. Any message sent to this user on TalkJS now triggers a push notification.