npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hotline

v1.2.1

Published

Plugin for integrating the Hotline SDK into a Phonegap/Cordova project

Downloads

18

Readme

Hotline Phonegap plugin

Twitter

This plugin integrates Hotline's SDK into a Phonegap/Cordova project.

You can reach us anytime at [email protected] if you run into trouble.

AppId and AppKey You'll need these keys while integrating Hotline SDK with your app. you can get the same from the Settings -> API&SDK page. Do not share them with anyone. If you do not have an account, you can get started for free at hotline.io

Where to find AppId and AppKey

For platform specific details please refer to the Documentation

Supported platforms :

  • Android
  • iOS

Note : This is an early version and so expect changes to the API

Integrating the Plugin :

  1. Add required platforms to your PhoneGap project
cordova platform add android
cordova platform add ios
  1. Add the hotline plugin to your project.

You can add the plugin from command line like:

cordova plugin add hotline

You can also add it to your config.xml like

<plugin name="hotline" source="npm"/>

Initializing the plugin

Hotline.init needs to be called from ondeviceready event listener to make sure the SDK is initialized before use.

document.addEventListener("deviceready", function(){
  // Initialize Hotline with your AppId & AppKey from your portal https://web.hotline.io/settings/apisdk
  window.Hotline.init({
    appId       : "<Your App Id>",
    appKey      : "<Your App Key>"
  });
});

The following optional boolean parameters can be passed to the init Object

  • agentAvatarEnabled
  • cameraCaptureEnabled
  • voiceMessagingEnabled
  • pictureMessagingEnabled
  • showNotificationBanner (ios only)

Here is a sample init code with the optional parameters

window.Hotline.init({
   appId       : "<Your App Id>",
   appKey      : "<Your App Key>",
   agentAvatarEnabled      : true,
   cameraCaptureEnabled    : false,
   voiceMessagingEnabled   : true,
   pictureMessagingEnabled : true
});

The init function is also a callback function and can be implemented like so:

window.Hotline.init({
     appId       : "<Your App Id>",
     appKey      : "<Your App Key>",
     agentAvatarEnabled      : true,
     cameraCaptureEnabled    : false,
     voiceMessagingEnabled   : true,
     pictureMessagingEnabled : true
 }, function(success){
     console.log("This is called form the init callback");
 });

Once initialized you can call Hotline APIs using the window.Hotline object.

//After initializing Hotline
showSupportChat = function() {
 window.Hotline.showConversations();
};
document.getElementById("launch_conversations").onclick = showSupportChat;


//in index.html
//<button id="launch_conversations"> Inbox </button>

Hotline APIs

  • Hotline.showFAQs()

    • Launch FAQ / Self Help

    The following FAQOptions can be passed to the showFAQs() call

      -showFaqCategoriesAsGrid
      -showContactUsOnAppBar
      -showContactUsOnFaqScreens
      -showContactUsOnFaqNotHelpful
        

    Here is a sample call to showFAQs() with the additional parameters:

    window.Hotline.showFAQs( {
        showFaqCategoriesAsGrid     :true,
        showContactUsOnAppBar       :true,
        showContactUsOnFaqScreens   :true,
        showContactUsOnFaqNotHelpful:false
    });

    Tags can also be passed as parameters to filer solution articles, Here is a sample call to showFAQs() implementing tags.

    window.Hotline.showFAQs( {
        tags :["sample","video"],
        filteredViewTitle   : "Tags"
    });

    v1.1 adds support for filtering both categories and filters, Example of filtering FAQs by Articles.

    window.Hotline.showFAQs( {
        tags :["sample","video"],
        filteredViewTitle   : "Tags",
        articleType   : Hotline.FilterType.ARTICLE
    });

    v1.1 adds support for filtering both categories and filters, Example of filtering FAQs by Categories.

    window.Hotline.showFAQs( {
        tags :["sample","video"],
        filteredViewTitle   : "Tags",
        articleType   : Hotline.FilterType.CATEGORY
    });

    Not specifying an articleType, by default filters by Article.

  • Hotline.showConversations()

    • Launch Channels / Conversations.

    v1.1 also adds supportto filter conversations with tags. This filters the list of channels shown to the user. Example showing how to filter converstions using tags.

      window.Hotline.showConversations( {
          tags :["new","test"],
          filteredViewTitle   : "Tags"
      });

NOTE:- Filtering conversations is also supported inside FAQs, i.e show conversation button from the category list or the article list view can also be filtered. Here is a sample.

  window.Hotline.showFAQs( {
      tags :["sample","video"],
      filteredViewTitle   : "Tags",
      articleType   : Hotline.FilterType.CATEGORY,
      contactusTags : ["test"], 
      contactusFilterTitle: "contactusTags"
  });
  ```

In the above example clicking on show conversations in the filtered category list view takes you to a conversation
view filtered by the tag "test".

* Hotline.unreadCount(callback)
  - Fetch count of unread messages from agents.
  
* Hotline.updateUser(userInfo)
  - Update user info. Accepts a JSON with the following format  
```javascript
{
 "name" : "John Doe",
 "email" : "[email protected]",
 "externalId" : "some unique Identifier from your system",
 "countryCode" : "+91",
 "phoneNumber" : "1234234123"
}
  • Hotline.updateUserProperties(userPropertiesJson)
    • Update custom user properties using a Json containing key, value pairs. A sample json follows
{
   "user_type" : "Paid",
   "plan" : "Gold"
}
  • Hotline.clearUserData()
    • Clear user data when users logs off your app.

You can pass in an optional callback function to an API as the last parameter, which gets called when native API is completed. Eg.

window.Hotline.unreadCount(function(success,val) {
    //success indicates whether the API call was successful
    //val contains the no of unread messages
});

Push Notifications

To setup push notifications we recommend using our forked version of the phonegap-plugin-push available [here] (https://github.com/freshdesk/phonegap-plugin-push) . It can be installed by the following command :

cordova plugin add https://github.com/freshdesk/phonegap-plugin-push.git

Or you can add it to your config.xml like:

<plugin name="phonegap-plugin-push" spec="https://github.com/freshdesk/phonegap-plugin-push.git">
        <param name="SENDER_ID" value="XXXXXXXXXX" />
    </plugin>

Initialize the push plugin and it will handle registering the tokens and displaying the notifications. here is a sample init function, call this in your onDeviceReady

function initializePush() {
    var push = PushNotification.init({
        "android":{
            "senderID":"XXXXXXXXXX"
        },
        "ios": {
            "alert": "true",
            "badge": "true",
            "sound": "true"
        },
        "windows": {}
    });
}

If you decide to handle push notifications with some other plugin, here are some of the APIs you will need.

When you receive a deviceToken from GCM or APNS , you need to update the deviceToken in hotline as follows warning updateRegistrationToken is now deprecated and replaced with updatePushNotificationToken from v1.2.0 and above

    // Example illustrates usage for phonegap-push-plugin
    push.on('registration',function(data) {
        window.Hotline.updatePushNotificationToken(data.registrationId);
     });

Whenever a push notification is received. You will need to check if the notification originated from Hotline and have Hotline SDK handle it.

// Example illustrates usage for phonegap-push-plugin
push.on('notification',function(data) {
  window.Hotline.isHotlinePushNotification(data.additionalData, function(success, isHotlineNotif) {
    if( success && isHotlineNotif ) {
      window.Hotline.handlePushNotification(data.additionalData);
    }
 });
});

Android notification properties can be changed with the updateAndroidNotificationProperties API. The properties that can be updated are.

  • "notificationSoundEnabled" : Notifiction sound enabled or not.
  • "smallIcon" : Setting a small notification icon (move the image to drawbles folder and pass the name of the jpeg file as parameter).
  • "largeIcon" : setting a large notification icon.
  • "deepLinkTargetOnNotificationClick" : Toggles if the deeplink target of a notification should open on click.
  • "notificationPriority" : set the priority of notification through hotline.
  • "launchActivityOnFinish" : Activity to launch on up navigation from the messages screen launched from notification. The messages screen will have no activity to navigate up to in the backstack when its launched from notification. Specify the activity class name to be launched.

The API is called like:

window.Hotline.updateAndroidNotificationProperties({
                "smallIcon" : "image",
                "largeIcon" : "image",
                "notificationPriority" : window.Hotline.NotificationPriority.PRIORITY_MAX,
                "notificationSoundEnabled" : false,
                "deepLinkTargetOnNotificationClick" : true
                "launchActivityOnFinish" : "MainActivity.class.getName()"
            });

List of hotline Priorities:

  • Hotline.NotificationPriority.PRIORITY_DEFAULT
  • Hotline.NotificationPriority.PRIORITY_HIGH
  • Hotline.NotificationPriority.PRIORITY_LOW
  • Hotline.NotificationPriority.PRIORITY_MAX
  • Hotline.NotificationPriority.PRIORITY_MIN

They follow the same priority order as Android's NotificaitonCompat.

DEPRECATED!

If you have been using the registerPushNotification call up until now, we recommend you use the method suggested above as we are removing support for it

window.Hotline.registerPushNotification('ANDROID_SENDER_ID'); // takes care of registration and handling of push notification on iOS and Android.

updateRegistrationToken has been replaced from v1.2.0

Caveats

Android :
  • Needs appcompat-v7 : 21+
  • Needs support-v4 : 21+
  • MinSdkVersion must be atleast 10 (in config.xml)
iOS
  • Needs iOS 7 and above