Set up push notifications
Set up push notifications for your application to keep your users updated by sending them notifications of events and announcements.
How do I configure push notifications in Zoho SalesIQ?
Step 1: In the Zoho SalesIQ console, navigate to Settings > Brands > Installation > Android, and enable Push notification.
Step 2: Add Firebase to your Android project. How to add Firebase to my Android project.
Step 3: Get the private key (JSON file) from Google services. A Private key (JSON) that authorizes your app to access Google services, including sending messages via Firebase Cloud Messaging. Follow the steps here to set up FCM service.
Note: Legacy FCM API to HTTP v1 API Migration guide
Before you proceed with the below steps, check the listed requirements:
- Create a project in the firebase.
- Add your app to the created Firebase project
- Override onNewToken() method from the FirebaseMessagingService class
- Override onMessageReceived() methods method from the FirebaseMessagingService class
Step 4: Click the Settings icon in the Firebase console and navigate to Project Settings > Service accounts. Under the Firebase Admin SDK, select Node.js and click on Generate new private key.
Step 5: Click Browser, select the private key file, and click Upload.
Step 6: Runtime permissions
From API level 33, it is mandatory to add POST_NOTIFICATIONS permissions in the AndroidManifest.xml file and request runtime permissions to post notifications. For more information, refer to this Android developer document.
AndroidManifest.xml
Copied
<service android:name=".MyFirebaseMessagingService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
Step 7: You should have a class that extends FirebaseMessagingService, which will consume pushes intended for SalesIQ. To allow us to draw the Zoho SalesIQ pushes, you should set up the FirebaseMessagingService as follows:
MyFirebaseMessagingService.java
Copied
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.zoho.salesiqembed.ZohoSalesIQ;
import java.util.Map;
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Map extras = remoteMessage.getData();
ZohoSalesIQ.Notification.handle(this.getApplicationContext(), extras, R.mipmap.ic_launcher);
}
@Override
public void onNewToken(String token) {
ZohoSalesIQ.Notification.enablePush(token, true);
}
}
Note:
By passing 'testdevice' as true, you can test the push notification messages from the Zoho SalesIQ console.
Step 7: Run your app with the implementation.
Step 8: To experiment with the push notification message services, you can initiate a test message to the registered mobile device here.
You can enter the notification text in the message and click Send button to test. The Registered mobile devices will receive your test notification message.
You also have an option to delete the registered test devices.
Note:
If you delete the test device here, the test message notifications alone will not be sent to those devices. Other notifications will be received/sent on the registered mobile devices.
Step 9: Using this API, you can set a custom notification icon for the push notification messages.
Copied
ZohoSalesIQ.Notification.setIcon(R.drawable.ic_notification);
Note:
You can refer here for more APIs on Notification. If you wish to send Push Notification through Zoho SalesIQ, you can use the Push Notification API.
Step 10: Notification channel
The mobilisten notification channel name can be changed with the string attribute - mobilisten_notification_channel_name
Copied
<string name="mobilisten_notification_channel_name">Support notifications</string>
Note:
By default, the notification channel name will be "Zoho SalesIQ".