0.2.8 • Published 7 years ago

appvuze v0.2.8

Weekly downloads
17
License
SEE LICENSE IN LI...
Repository
github
Last release
7 years ago

appVuze In-app Customer Support Plugin for PhoneGap/Cordova

Login at https://appvuze.io - manage users, applications, and support your mobile app users

Bitcode vs. No-Bitcode - please read

appVuze.framework included in this repo does not contain bitcode for space considerations. If you distribute your application via the Apple App Store with bitcode enabled, then please download appvuze-phonegap-cordova-plugin from here and unzip it on your local harddrive: https://www.dropbox.com/s/qbev5xdj7f2re3s/appvuze-phonegap-cordova-plugin-0.2.7-bitcode.zip?dl=1

Installation

Project Structure

Usage Example. First, import plugin into your Cordova/PhoneGap app as follows:

$> cordova create AppVuzeTest
$> cd AppVuzeTest
$> cordova platform add ios
$> cordova platform add android
$> cordova plugin add appvuze, *or*
$> cordova plugin add <path-to-appvuze-phonegap-cordova-plugin-with-bitcode>
$> cordova prepare
$> cordova build --device

Required changes to include appVuze plugin in your Cordova/PhoneGap app:

CDVAppVuze.m:

- (void)initializeSdk:(CDVInvokedUrlCommand*)command
{
    // Replace YOUR_APPLICATION_KEY with a key obtained from https://appvuze.io dashboard
    // Remember to enclose application key string in @""
    [appVuze initializeSdkWithApplicationKey:YOUR_APPLICATION_KEY];
}

CDVAppVuze.java:

    private void executeOnUiThread(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
    {
        if (action.equals(ACTION_INITIALIZE_SDK))
        {
            // Replace YOUR_APPLICATION_KEY with a key obtained from https://appvuze.io dashboard
            // Remember to enclose application key string in ""
            appVuze.initializeSdk(cordova.getActivity(), YOUR_APPLICATION_KEY);
        }

Index.js:

var app = {
    // Application Constructor
    initialize: function() {
        this.bindEvents();
    },
    // Bind Event Listeners
    //
    // Bind any events that are required on startup. Common events are:
    // 'load', 'deviceready', 'offline', and 'online'.
    bindEvents: function() {
        document.addEventListener('deviceready', this.onDeviceReady, false);
    },
    // deviceready Event Handler
    //
    // The scope of 'this' is the event. In order to call the 'receivedEvent'
    // function, we must explicitly call 'app.receivedEvent(...);'
    onDeviceReady: function() {
        app.receivedEvent('deviceready');

        var helpButton = document.getElementById('help-me');
        helpButton.addEventListener('click', app.launchAppVuze, false);

        var appvuze = window.cordova.require("cordova/plugin/CDVAppVuze");
        if (appvuze != null) {
            appvuze.initializeSdk();
        } else {
            alert('error!');
        }
    },
    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    },
    launchAppVuze: function() {
        var appvuze = window.cordova.require("cordova/plugin/CDVAppVuze");
        if (appvuze != null) {
            appvuze.beginHelpSession('John', {accountNumber:'1234567890', userEmail:'john@doe.com'});
        } else {
            alert('error!');
        }
    }
};

app.initialize();

Config.xml:

<feature name="AppVuze">
    <param name="ios-package" value="CDVAppVuze" />
</feature>

Index.html:

<html>
    <head>
        <!--
        Customize this policy to fit your own app's needs. For more guidance, see:
            https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy
        Some notes:
            * gap: is required only on iOS (when using UIWebView) and is needed for JS->native communication
            * https://ssl.gstatic.com is required only on Android and is needed for TalkBack to function properly
            * Disables use of inline scripts in order to mitigate risk of XSS vulnerabilities. To change this:
                * Enable inline JS: add 'unsafe-inline' to default-src
        -->
        <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
            <div>
                <button id="help-me">Help me!</button>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
    </body>
</html>