Use this page to learn how to send push notifications to users when they are offline.
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:
Learn more information from the Push Notifications section of our Key Concepts page.
Visit Key Concepts page to learn the most important QuickBlox concepts.
To start working with push notifications, you need to install react-native-push-notification library. Follow the setup steps in the README file. After that, follow the platform-specific steps on this page.
Use the 3.2.1 version of the react-native-push-notification library to be able to display push notifications.
Step1. Create APNs certificate and upload it to the Dashboard.
Each iOS application that uses Apple Push Notifications must have an APNs certificate. Upload the APNs certificate to QuickBlox Dashboard => Push Notifications => Settings => Apple Push Notification Service (APNs). To learn how to create APNs certificates and upload them to Dashboard, refer to our guide.
Step2. Open your project in Xcode and enable Push Notifications capabilities.
Step 1. Configure Firebase project and get API key and Sender ID.
First, you should create a Firebase account if you don’t have it. Then you should configure your Firebase project. To learn how to configure a Firebase project and get API key and Sender ID, refer to our guide .
Step 2. Add Firebase to your project.
Add Firebase dependency and include gms plugin in the bottom of your module android/app/build.gradle.
Make sure that apply plugin: 'com.google.gms.google-services'
is at the end of the file to avoid compilation errors.
Initialize the react-native-push-notification lib using the code snippet below.
Subscribe to FCM or APNs service. Once the device is subscribed, the service delivers a notification to it.
For VoIP push notifications, specify push_channel: apns_voip
channel.
The create()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
deviceToken | yes | Token received from FCM/APNs. |
pushChannel | no | Channel for receiving push notifications. |
The deviceToken
is a device registration token generated by the APNs or GCM/FCM. The token can be unregistered by the APNs or GCM/FCM anytime. In this case, the device should be registered again and obtain a new token. When a new token is obtained, a new subscription should be created.
You can initiate sending a push notification to a user on any event in your application. To do so, you need to set push notification parameters, push recipients, notification type, sender ID, and type of the notification event. For VoIP push notifications, you need to set the ios_voip: 1
parameter.
The create()
method accepts one argument of the object type that has the following fields:
Parameter | Required | Description |
---|---|---|
notificationType | yes | Type of notifications:- QB.events.NOTIFICATION\_TYPE.PUSH - send push notification.- QB.events.NOTIFICATION\_TYPE.EMAIL - send email. |
payload | yes | Push notification payload. Can contain a message (string) property and many other key-value pairs (string-string). Refer here for more details. |
recipientsIds | no | Users’ IDs to deliver notification. |
senderId | yes | ID of the user who created the event. |
type | yes | Types of the notification event.- QB.events.NOTIFICATION\_EVENT\_TYPE.ONE\_SHOT - a one-time event (valid only if the date is not specified).- QB.events.NOTIFICATION\_EVENT\_TYPE.FIXED\_DATE - a one-time event that occurs at a specified date (valid only if the date is specified).- QB.events.NOTIFICATION\_EVENT\_TYPE.PERIOD\_DATE - is a reusable event that occurs within a given period from the initial date (valid only if the period is specified). |
You can send only FCM data messages to the Android app. QuickBlox doesn’t support FCM notification messages.
To process FCM data messages on your app when the app is in the background, you need to handle them. If not handled, they will not pop on the screen even if the app has received such push notification. See FCM documentation to learn more about data messages.
How to set up the FCM console and plug into QuickBlox dash board please see How to enable Cloud Messaging API (Legacy) or HTTP v1 API
You can send APNs VoIP notifications to the iOS app. However, if the iOS app is not subscribed to APNs VoIP notifications or the APNs VoIP certificate has expired, the regular APNs will be delivered instead of APNs VoIP.
When any notification is opened or received the onNotification
callback is called passing an object with the notification data.
Let’s review the notification object below:
You can unsubscribe from receiving push notification by passing a subscription ID.
If you need to display a native calling interface for incoming and outgoing calls, you should use CallKit on iOS. It lets you integrate your calling services with other call-related apps on the system. Use Apple CallKit guide to learn how to integrate a CallKit functionality.
For iOS, together with the CallKit, you also need to integrate VoIP push notifications.
QuickBlox supports iOS VoIP push notifications via the same API described above:
push_channel: apns_voip
in the subscription request.ios_voip: 1
parameter in a push payload of the create event request.Cause: a device registration token is invalid.
The device registration token is represented as deviceToken
within the system. See this section to learn how to subscribe a device to push notifications.
Tip: check if the device registration is correct. The device registration token can be invalid due to a number of reasons:
For all these cases, remove the invalid device registration token and stop using it to send messages. Then, obtain a new token and make sure to create a new subscription with a valid token.
Use this page to learn how to send push notifications to users when they are offline.
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:
Learn more information from the Push Notifications section of our Key Concepts page.
Visit Key Concepts page to learn the most important QuickBlox concepts.
To start working with push notifications, you need to install react-native-push-notification library. Follow the setup steps in the README file. After that, follow the platform-specific steps on this page.
Use the 3.2.1 version of the react-native-push-notification library to be able to display push notifications.
Step1. Create APNs certificate and upload it to the Dashboard.
Each iOS application that uses Apple Push Notifications must have an APNs certificate. Upload the APNs certificate to QuickBlox Dashboard => Push Notifications => Settings => Apple Push Notification Service (APNs). To learn how to create APNs certificates and upload them to Dashboard, refer to our guide.
Step2. Open your project in Xcode and enable Push Notifications capabilities.
Step 1. Configure Firebase project and get API key and Sender ID.
First, you should create a Firebase account if you don’t have it. Then you should configure your Firebase project. To learn how to configure a Firebase project and get API key and Sender ID, refer to our guide .
Step 2. Add Firebase to your project.
Add Firebase dependency and include gms plugin in the bottom of your module android/app/build.gradle.
Make sure that apply plugin: 'com.google.gms.google-services'
is at the end of the file to avoid compilation errors.
Initialize the react-native-push-notification lib using the code snippet below.
Subscribe to FCM or APNs service. Once the device is subscribed, the service delivers a notification to it.
For VoIP push notifications, specify push_channel: apns_voip
channel.
The create()
method accepts one argument of the object type that has the following fields:
Field | Required | Description |
---|---|---|
deviceToken | yes | Token received from FCM/APNs. |
pushChannel | no | Channel for receiving push notifications. |
The deviceToken
is a device registration token generated by the APNs or GCM/FCM. The token can be unregistered by the APNs or GCM/FCM anytime. In this case, the device should be registered again and obtain a new token. When a new token is obtained, a new subscription should be created.
You can initiate sending a push notification to a user on any event in your application. To do so, you need to set push notification parameters, push recipients, notification type, sender ID, and type of the notification event. For VoIP push notifications, you need to set the ios_voip: 1
parameter.
The create()
method accepts one argument of the object type that has the following fields:
Parameter | Required | Description |
---|---|---|
notificationType | yes | Type of notifications:- QB.events.NOTIFICATION\_TYPE.PUSH - send push notification.- QB.events.NOTIFICATION\_TYPE.EMAIL - send email. |
payload | yes | Push notification payload. Can contain a message (string) property and many other key-value pairs (string-string). Refer here for more details. |
recipientsIds | no | Users’ IDs to deliver notification. |
senderId | yes | ID of the user who created the event. |
type | yes | Types of the notification event.- QB.events.NOTIFICATION\_EVENT\_TYPE.ONE\_SHOT - a one-time event (valid only if the date is not specified).- QB.events.NOTIFICATION\_EVENT\_TYPE.FIXED\_DATE - a one-time event that occurs at a specified date (valid only if the date is specified).- QB.events.NOTIFICATION\_EVENT\_TYPE.PERIOD\_DATE - is a reusable event that occurs within a given period from the initial date (valid only if the period is specified). |
You can send only FCM data messages to the Android app. QuickBlox doesn’t support FCM notification messages.
To process FCM data messages on your app when the app is in the background, you need to handle them. If not handled, they will not pop on the screen even if the app has received such push notification. See FCM documentation to learn more about data messages.
How to set up the FCM console and plug into QuickBlox dash board please see How to enable Cloud Messaging API (Legacy) or HTTP v1 API
You can send APNs VoIP notifications to the iOS app. However, if the iOS app is not subscribed to APNs VoIP notifications or the APNs VoIP certificate has expired, the regular APNs will be delivered instead of APNs VoIP.
When any notification is opened or received the onNotification
callback is called passing an object with the notification data.
Let’s review the notification object below:
You can unsubscribe from receiving push notification by passing a subscription ID.
If you need to display a native calling interface for incoming and outgoing calls, you should use CallKit on iOS. It lets you integrate your calling services with other call-related apps on the system. Use Apple CallKit guide to learn how to integrate a CallKit functionality.
For iOS, together with the CallKit, you also need to integrate VoIP push notifications.
QuickBlox supports iOS VoIP push notifications via the same API described above:
push_channel: apns_voip
in the subscription request.ios_voip: 1
parameter in a push payload of the create event request.Cause: a device registration token is invalid.
The device registration token is represented as deviceToken
within the system. See this section to learn how to subscribe a device to push notifications.
Tip: check if the device registration is correct. The device registration token can be invalid due to a number of reasons:
For all these cases, remove the invalid device registration token and stop using it to send messages. Then, obtain a new token and make sure to create a new subscription with a valid token.