Giter Club home page Giter Club logo

cordova-sdk's Introduction

cordova-sdk

Cordova plugin for integrating Queue-it's virtual waiting room into Cordova/Ionic apps.

Sample app

A sample app project to try out functionality of the library can be found in the example directory.

Installation

Before starting please download the whitepaper Mobile App Integration from the Go Queue-it Platform. This whitepaper contains the needed information to perform a successful integration.

You can install this plugin in the following ways:

  • Using the Github repository:
cordova plugin add https://github.com/queueit/cordova-sdk.git
  • Using NPM:
cordova plugin add @queue-it/cordova-sdk

This plugin adds a new Android Activity so you might need to add it to your manifest.

<activity android:name="com.queue_it.androidsdk.QueueActivity"/>

Usage

To protect parts of your application you'll need to make a QueueIt.run call and wait for it's result in a callback.
The callback is called with different states as you can see in the example:

//This function would make the user enter a queue and it uses a callback to handle the user's state.
//When the user gets his turn he may get a QueueITToken which signifies the user's session.
//An error would be sent to the callback if:
// 1) Queue-it's servers can't be reached (connectivity issue).
// 2) SSL connection error if custom queue domain is used having an invalid certificate.
// 3) Client receives HTTP 4xx response.
// In all these cases is most likely a misconfiguration of the queue settings:
// Invalid customer ID, event alias ID or cname setting on queue (GO Queue-it portal -> event settings).
function enqueue(){
    var customerId = "myCustomerId";
    var waitingRoomIdOrAlias = "waitingRoom";
    var layoutName = null;
    var language = null;
    var clearCache = false; // Use `true` here if you want to reset the user's position when queueing.

    QueueIt.run(customerId, waitingRoomId, layoutName, language, clearCache, function(result){
        console.log("QueueIt run result", JSON.stringify(result));
        if(result.Error){
            console.warn("Errored out: " + result.Message);
            return;
        }
        switch (result.State){
            case "Passed":
                // At this point the Queue-it webview is closed and the previous screen is visible
                console.log("User got his turn with token: " + result.QueueITToken);
                break;
            case "Disabled":
                console.log("Waiting room is disabled");
                break;
            case "Unavailable":
                console.log("Waiting room is not available");
                break;
            case "ViewWillOpen":
                console.log("Waiting room WebView is being opened");
                break;
            case "CloseClicked":
                console.log("User clicked on a `queueit://close` link, so webview was closed")
                break;
        }
    })
}

As the App developer you must manage the state (whether user was previously queued up or not) inside your app's storage. After you get the callback call with State: Passed, the app must remember this, possibly with a date/time expiration.
When the user goes to another page/screen - you check his state, and only call run in the case where the user was not previously queued up. When the user clicks back, the same check needs to be done.

App Integration Flow

License

MIT

cordova-sdk's People

Contributors

johowoo avatar sp0x avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.