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: Now, get the FCM key from Google services. A server key that authorizes your app server for access to Google services, including sending messages via Firebase Cloud Messaging. Follow the steps here to set up FCM service. 

Before you proceed with the below steps, check the listed requirements:

  • Created a project in the https://console.firebase.google.com/
  • Added 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 -> Cloud Messaging; you can find the server key.

Step 5: Enter the server key in the input box.

​​

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. 

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:

AndroidManifest.xml

Copied <service android:name=".MyFirebaseMessagingService">
    <intent-filter>
        <action android:name="com.google.firebase.MESSAGING_EVENT"/>
    </intent-filter>
</service>​

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

<string name="mobilisten_notification_channel_name">Support notifications</string>

Note: 
By default, the notification channel name will be "Zoho SalesIQ".