Notifications via Push

Teliver sdk provides you the way to notify your customers about the events that can occur within the Operator and Consumer. Let’s see that in detail.

Notifications work with the help of FCM in Teliver sdk so let’s set the configuration to do it. You can know how to setup FCM in your Android Project here.

  • Identifying Users

    To send/recieve a notification to users, the device must be first identified, to do so use the following method.

Teliver.identifyUser(new UserBuilder("consumer_id").setUserType(USER_TYPE.CONSUMER).registerPush().build());

You can also identify your users with additional details such as Name, Phone and email as well with the below methods.


Note: Consumer_1 here can be your user’s unique identifier in your system for identification, this will reflect under Users on dashboard. You can also use this method without registerPush().

Ref: The above view will appear on dashboard on identifying user.

  • Send Notification from Operator

    Now let’s notify the user's that the trip has been started along with Start Trip.

TripBuilder builder = new TripBuilder("Tracking_Id");
PushData pushData = new PushData("user_1");
pushData.setMessage("Trip has been Started");
pushData.setPayload("Your Payload");


  • Handling push on Consumer

    The Teliver sdk already has necessary FCM class to get token and to handle push notification follow the steps below.

Create MyFirebaseMessageService class as shown like below in your application.

public class MyFirebaseMessageService extends FirebaseMessagingService {

    public void onMessageReceived(RemoteMessage remoteMessage) {
        try {
            if (Teliver.isTeliverPush(remoteMessage)) {
                Map<String, String> pushData = remoteMessage.getData();
                NotificationData data = new GsonBuilder().create().fromJson(pushData.get("description"), NotificationData.class);
                if (data.getCommand().equals(TConstants.CMD_TRIP_START)) {
                    TrackingBuilder builder = new TrackingBuilder(new MarkerOption(data.getTrackingID()));
                    Intent notificationIntent = new Intent(this, TeliverMap.class);
                    notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,
                            notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);

                    NotificationManager notificationManager = (NotificationManager)
                    NotificationCompat.Builder notBuilder = new NotificationCompat.Builder(this);
                    notBuilder.addAction(R.drawable.ic_toolbar, this.getString(R.string.txt_start_tracking), pendingIntent);
                    Notification notification =;
                    notification.defaults |= Notification.DEFAULT_SOUND;
                    notification.flags = Notification.FLAG_AUTO_CANCEL;
                    notificationManager.notify(12, notification);
                } else if (data.getCommand().equals(TConstants.CMD_EVENT_PUSH)) {

            } else {
                //The push is not for us, You can handle it.
        } catch (Exception e) {

Open your app AndroidManifest.xml and add register MyFirebaseMessageService in application tag

<service android:name=".push.MyFirebaseMessageService">
        <action android:name="" />

  • Custom event push

    What if you want to send your own event push like “Picked up the Parcel”, “Traffic! Arriving late”, “I am near, Open the gates”etc? Let’s see how can it be done.

PushData eventPush=new PushData("user_id"); 
eventPush.setMessage("We have reached near you");
eventPush.setPayload("Your Payload");

Teliver.sendEventPush("Tracking_Id", eventPush);

You can also tag the location along with event push by using following method.

Teliver.sendEventPush("Tracking_Id", eventPush, "Order Picked");

To send event push to multiple users then use the following method,

String[] users=new String[]{"user_1","user_2"};
PushData eventPush=new PushData(users);
eventPush.setMessage("Traffic! Arriving late");
eventPush.setPayload("Your Payload");

Teliver.sendEventPush("Tracking_Id", eventPush);

Note: Don’t forget to identify the Consumer before using these methods

  • Unregister User

    What if you want to unregister the identified user?


results matching ""

    No results matching ""