Cordova sdk


We provide cordova plugin as wrapper for ours native plugins. Currently supported only iOS and Android.



Installation



For automatic installation:


cordova plugin add https://github.com/apps-m/inapphelp-cordova

Note: For android you needed have [email protected] version or higher. Because we use gradle for build dependency. For check version

cordova platform ls

For update:

cordova platform update [email protected]
cordova plugin add https://github.com/apache/cordova-plugin-whitelist.git#r1.0.0
 # To install Crosswalk (optional):
cordova plugin add https://github.com/MobileChromeApps/cordova-plugin-crosswalk-webview.git#1.0.0

Release notes



Integration


Initializing


We identifies your App with three params:

App id    - Unique app id.

App key - Unique app key.

Domain - Your inapphelp company domain name.

To get this params navigate to Settings -> integration in your admin panel.


To initialize inapphelp:

window.Inapphelp.init("appid", "appkey", "domain");

Optional you can set your custom user id (To identificate user in your system).

window.Inapphelp.setUserId('[email protected]');

And user secret key, to allow issues only from signed users. Secret key it is userid signed by your own server. Learn more about secure concept

window.Inapphelp.setUserSecretKey('a5748c37d50bd8cce1ae26ebc0788e960037777b');

Using


Inapphelp is now integrated. To show a help:

window.Inapphelp.showHelp();

Push notifications


We recommend you to use PhoneGap Push plugin

Android

If you have problems with building android app after installing pushPlugin - see troubleshooting section.

First configure your app settings in admin panel. Go to your admin panel - > settings -> applications and click on the app. Set android push notification state to 'On', and provide your GCM Api Key and Bundle ID.

After earn push notification token - send it on backend window.Inapphelp.setPushToken(token); Example:

function onNotification(e) {
    switch( e.event )
    {
        case 'registered':
            if ( e.regid.length > 0 ) {
                // Your GCM push server needs to know the regID before it can push to this device
                // here is where you might want to send it the regID for later use.
                window.Inapphelp.setPushToken(e.regid);
            }
        break;
    }
}; 

And on notification received:

function onNotification(e) {
    switch( e.event )
    {
        case 'message':
        if (e.payload.source == 'inapphelp')
            window.Inapphelp.handlePushNotification(e.payload, e.foreground);
        break;
    }
}; 



iOS

First, setup your application with Apple and prepare certificates. Create certificates

After you got cert.cer and private.p12 generate new .p12 by there steps:

Convert the developer certificate file you receive from Apple into a PEM certificate file:

openssl x509 -in cert.cer -inform DER -out cert.pem -outform PEM

Сonvert .p12 it into a PEM key:

openssl pkcs12 -nocerts -in key.p12 -out key.pem

Now generate a valid P12 file, based on the key and the PEM version of the iPhone developer certificate:

openssl pkcs12 -export -inkey key.pem -in cert.pem -out upload.p12

All right. We are almost at the end. Now you need to enable ios pushes in your admin panel.

Go to your admin panel - > settings -> applications and click on the app. Set ios push notification state to 'On', upload certificate select push mode and upload a cert.


Okay go to your application.

After earn push notification token - send it on backend window.Inapphelp.setPushToken(token); Example:

pushNotification.register(
function(token){window.Inapphelp.setPushToken(token);},
function(error){console.log('Push register error = ' + error);},
{
"badge":"true",
"sound":"true",
"alert":"true",
"ecb":"onNotificationAPN"
});

And on notification received:

function onNotificationAPN (e) {
    if (e.source == 'inapphelp')
         window.Inapphelp.handlePushNotification(e, e.foreground == "1");
    };


Troubleshooting


If you have "java.lang.IllegalArgumentException: already added: Landroid/support/v4/print/PrintHelper$1;" error while build android:

Replace in files ./plugins/ru.apps-m.inapphelp/inapphelp.gradle and ./platforms/android/ru.appsm.inapphelp.YOUR_APP_NAME-inapphelp.gradle :

compile "ru.apps-m:inapphelp:0.3.2";

To:

compile ("ru.apps-m:inapphelp:0.3.2") {exclude module: 'support-v4'}