Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Go to Haptik Website
  • Contact Us
  • Home
  • Deployment
  • Android SDK

Push notifications on Android SDK

Written by Soham Amburle

Updated on July 26th, 2022

Contact Us

If you still have questions or prefer to get help directly from an agent, please submit a request.
We’ll get back to you as soon as possible.

Please fill out the contact form below and we will reply as soon as possible.

  • Getting Started
    Build Deploy Analyse Manage Account Bot Deactivation
  • Bot Building
    Essentials Smart Skills Steps User Messages Bot Responses Entities Connections Customisations User feedback collection Testing Whatsapp Bots NLU
  • Conversation Design
    Design Basics Design Guides Designing for Platforms Designing WhatsApp Bots
  • Developer Guides
    Code Step Integration Static Step Integration Shopify Integration SETU Integration Exotel Integration CIBIL integration Freshdesk KMS Integration PayU Integration Zendesk Guide Integration Twilio Integration Razorpay Integration LeadSquared Integration USU(Unymira) Integration Helo(VivaConnect) Integration Salesforce KMS Integration Stripe Integration PayPal Integration CleverTap Integration Fynd Integration HubSpot Integration Magento Integration WooCommerce Integration
  • Deployment
    Web SDK WhatsApp Facebook Instagram Sunshine Conversation LINE Google Business Messages Telegram MS Teams Bot as an API iOS SDK Android SDK
  • Agent Setup
    Haptik's Smart Agent Chat Zendesk Chat Salesforce Service Cloud Freshchat Zoho NICE CXOne Gorgias
  • Analytics & Reporting
    Intelligent Analytics
  • Proactive Messaging
    WhatsApp Notifications & Templates Team and User Management APIs and Integrations SMS Notifications Embedded Signup Proactive Messaging Attribution
  • Commerce Plus
    Commerce Plus for Instagram Commerce Plus for Facebook Catalog Localization
  • Troubleshooting Guides
    Error Messages FAQs
  • Release Notes
+ More

Push notifications can considerably enhance your customer experience. Haptik SDK can also be configured to receive and handle Push Notifications for the conversation.

We use Firebase Cloud Messaging for push notifications. Firstly, you will have to update the GCM key in your Partner tool, which is available on the Haptik platform. You can navigate to this tool by logging in to Haptik and the admin tools > partner. 

To further enable push notification in HaptikSDK, you have to perform the following three steps :

Add Manifest Entry -

The following Activity needs to be added to your Manifest and add your desired activity as parent activity. This is required so that the user can be navigated to the proper activity when user presses the back button.

<application>
. 
. 
<activity android:name="ai.haptik.android.wrapper.sdk.HaptikWebView" 
          android:parentActivityName=".MainActivity" />
. 
.
</application>

Sync Notification Token -

You just need to pass the notification token to Haptik SDK so that the Haptik platform

can trigger push notifications from the backend whenever required.

Forward Notification to Haptik SDK -

Whenever you receive a notification check if it's from the Haptik platform. If it's a Haptik notification forward it to Haptik SDK.

Example:

Kotlin Code:

class MyFirebaseMessagingService : FirebaseMessagingService() {
    override fun onMessageReceived(remoteMessage : RemoteMessage) {
        val data = remoteMessage.data
        // check if it's Haptik notification
        if (HaptikSDK.isHaptikNotification(data)) {
            HaptikSDK.handleNotification(
                applicationContext,
                data,
                // Icon to show in notification
                R.mipmap.ic_launcher_round
            )
        }
    }
    override fun onNewToken(token: String) {
        super.onNewToken(token)
        HaptikSDK.setNotificationToken(applicationContext, token)
    }
}

Java Code:

public class MyFirebaseInstanceMessagingService extends FirebaseMessagingService {
   @Override
   public void onMessageReceived(@NonNull RemoteMessage message) {
       super.onMessageReceived(message);
       Map<String, String> data = message.getData();
       if(HaptikSDK.INSTANCE.isHaptikNotification(data)){
           HaptikSDK.INSTANCE.handleNotification(this, data, R.mipmap.ic_launcher);
       }
   }


   @Override
   public void onNewToken(@NonNull String token) {
       super.onNewToken(token);
       HaptikSDK.INSTANCE.setNotificationToken(getApplicationContext(), token);
   }
}


Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Logging out of Android SDK

Platform

  • Conversation Studio
  • Smart Skills
  • Advanced NLU
  • Intelligent Analytics
  • Omnichannel
  • Smart Agent Chat
  • Enterprise Security
  • Integrations

Solutions

  • Conversational Commerce
  • Lead Generation
  • Customer Care
  • WhatsApp
  • Conversational IVR
  • Google Business Messages

Industries

  • Retail/ E-Commerce
  • Financial Services
  • Travel & Hospitality
  • Telecom

Knowledge

  • ROI Calculator
  • Reports & Research
  • Case Studies
  • Webinars
  • ISAT
  • Tech Blog
  • Business Blog
  • Resources
  • Haptik v/s Yellow
  • Haptik v/s Liveperson
  • Haptik v/s IBM Watson
  • Haptik v/s Verloop
  • Conversations on AI

Company

  • Why Haptik
  • About Us
  • Careers
  • News & Media
  • Awards & Recognition
  • Contact Us
  • Partnerships
  • Investor Relations

Subscribe

Sign up to recieve the latest updates

Find us on

  • Twitter-footer
  • Linkedin-footer
  • YT-footer
  • Insta-footer
  • G2-footer
  • Facebook-footer

Copyright © jio Haptik Technology Limited 2021 | Data Security & Privacy Policy | GDPR

North America | Asia Pacific | Africa | enterprise@haptik.ai

Definition by Author

0
0