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
  • iOS SDK

Push notifications on iOS 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 Bot Maintenance
  • Smart Agent Chat
    Set up Admin Settings MyChats Section (Agent Inbox) Live Traffic Section Teams Section Archives Section Analytics Plans on Smart Agent Chat
  • 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 Microsoft Dynamics 365 Integration
  • Deployment
    Web SDK WhatsApp Facebook Instagram Sunshine Conversation LINE Google Business Messages Telegram MS Teams Bot as an API iOS SDK Android SDK
  • External Agent Tool Setup
    Zendesk Chat Salesforce Service Cloud Freshchat Zoho NICE CXOne Gorgias
  • Analytics & Reporting
    Intelligent Analytics
  • Notifications
    SMS Notifications Success Measurement
  • Commerce Plus
    Catalog Integration Bot Building Guide Channel Deployments Unified ML Pipeline Documentation
  • Troubleshooting Guides
    Error Messages FAQs
  • Release Notes
+ More

Table of Contents

Push Notification

Push Notification

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

Checklist

  • Make sure you have a valid APNS (.p8) certificate shared with Haptik
  • Make sure your app supports push notifications under Signing & capabilities

Firstly, you will have to update the APPLE_TEAM_ID 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. 

Once you have updated the APPLE_TEAM_ID, make sure you contact the Support team or your Haptik SPOC, for attaching the  APNS (.p8) certificate in the backend. 

For detailed instructions on how to request an authentication token signing key, see Establishing a Token-Based Connection to APNs.

Sync Device Token

You just need to pass the Device Token to Haptik for it to trigger push notifications from the backend whenever required. One point where you need to set the deviceToken is when the application gets the token after requesting. See the examples below -

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

        ...

        HPKit.sharedSDK.setDeviceToken(deviceToken: deviceToken)
   }

Handle Notification Tap

The Haptik SDK is capable of handling its notifications also. It's also possible to determine whether the notification payload is Haptik-specific or not. If yes then let Haptik handle the notification.

For Haptik to handle its own notifications, you have to pass the required notification response that you get in the notifications payload and the instance of the viewController from where the notifications should be handled. It will take the user directly to the conversation screen. 

Here, if the user is a guest user, the code will be:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
        
        let haptikNotification = (HPKit.sharedSDK.canHandleNotificationWith(UserInfo: userInfo)


                if (haptikNotification == true && application.applicationState != .active) {
            let navController = window?.rootViewController as? UINavigationController
            let controller =  navController?.visibleViewController
            do {
                try HPKit.sharedSDK.loadGuestConversation(launchController: controller!, customData: nil)
            } catch {
                print(error)
            }
        }
}

If the user is a logged-in user, then for custom sign-up the code will be:

func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

        let haptikNotification = (HPKit.sharedSDK.canHandleNotificationWith(UserInfo: userInfo)
                if (haptikNotification == true && application.applicationState != .active) {

            let navController = window?.rootViewController as? UINavigationController
            let controller =  navController?.visibleViewController

            let authAttribute = HPAttributesBuilder.build { (builder) in
                builder.authCode = "your_auth_code"
                builder.authID = "your_auth_id"
                builder.userName = "user_name"
                builder.email = "abcd@gmail.com"
                builder.mobile = "9876543210"
                builder.signupType = "your_signup_type"
            }

            do {
            try HPKit.sharedSDK.loadConversation(launchController: self, attributes: authAttribute, customData: nil)   
            } catch {
                
                print(error)
             }
        }
}

Was this article helpful?

Yes
No
Give feedback about this article

Related Articles

  • Deep links on iOS 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

Knowledge Base Software powered by Helpjuice

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

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

Definition by Author

0
0