The QuickBlox Developer Hub

Welcome to the QuickBlox developer hub. You'll find comprehensive guides and documentation to help you start working with QuickBlox as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Push Notifications

This is our new documentation for beta version of QuickBlox React Native SDK. Please contact our Customer Support Team to provide your feedback, suggestions, and requests to improve this page.

Push Notifications provide a way to deliver some information to a user while they are not using your app actively. The following use cases can be covered by push notifications:

  • Send a chat message if the recipient is offline (a push notification will be sent automatically).
  • Make a video call with offline opponents (a push notification will be sent manually).

Configure

Android

In order to start working with push notifications functionality, you need to configure the Firebase project and API key.

  1. Create and configure your Firebase project and obtain the API key.
  2. Find your FCM server key following your Firebase console => Cloud Messaging section.
  3. Copy your FCM server key to your Dashboard => Your App =>Push Notifications => Certificates & API keys. Select the environment for which you are adding the key and hit Save key. Use the same key for development and production zones. Add your FCM server key to your Dashboard.

Prepare app dependencies

As part of enabling Firebase services in your Android application, you need to add the google-services plugin to your project android/build.gradle file.

dependencies {
  classpath 'com.google.gms:google-services:4.3.0'
    ...
}

Add FCM dependency and include gms plugin in the bottom of your module android/app/build.gradle.

implementation "com.google.firebase:firebase-core:17.0.1"
implementation "com.google.firebase:firebase-messaging:19.0.1"
...
apply plugin: 'com.google.gms.google-services'

Pay attention

Make sure that apply plugin: 'com.google.gms.google-services' is at the end of the file to avoid compilation errors.

Put your google-services.json file for your package into android/app/ folder.

iOS

In order to start working with push notifications functionality do the following:

  1. Create APNS certificate. Each iOS application that uses Apple Push Notifications must have an APNS certificate.
  2. Upload the APNS certificate to QuickBlox Dashboard => Push Notifications module => Settings tab => Apple Push Notification Service (APNS) section.

To get the information on how to create APNS certificates and upload them to Dashboard, refer to the How to generate APNS certificate guide.

Create push subscription

Subscribe for push notifications. Create a push subscription using the code below.

// token obtained from APNS or FCM
const subscription = { deviceToken: token }

QB.subscriptions
  .create(subscription)
  .then(() => { /* subscription(s) created successfully */ })
  .catch(e => { /* handle error */ })

Send push notifications

You can manually initiate sending push notifications to user/users on any event in your application. To do so, you need to form push notification parameters (payload) and set the push recipients.

const event = {
  notificationType: QB.events.NOTIFICATION_TYPE.PUSH,
  payload: {
    // ios_voip: 1, for iOS voip push
    message: 'Your push notification message',
    // VOIPCall: 1, for android voip push
  },
  recipientsIds: session.opponentsIds, // send push to call opponents
  senderId: session.initiatorId, // in case you're call initiator
  type: QB.events.NOTIFICATION_EVENT_TYPE.ONE_SHOT,
}

QB.events
  .create(event)
  .then(function (data) { /* notification event(s) created successfully */ })
  .catch(function (e) { /* handle error */ })

Remove push subscription

To delete a subscription, use the following code snippet.

QB.subscriptions
  .remove({ id: 'your subscription Id' })
  .then(() => { /* removed successfully */ })
  .catch(function (e) { /* handle error */ })

Updated 8 days ago


What's Next

Custom Objects

Push Notifications


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.