SDK

Storage

This is an add-on feature of Notificare. Before you can use this functionality you must subscribed to the Storage add-on as described here.

In this page you'll learn how to transform any type of content you upload to Notificare into timely and relevant content for each individual user of your web app. Before you can retrieve and display text or media files in your app, you need to create asset groups in our dashboard. This is covered in our guides located here.

Once you have create one or more asset groups, to retrieve a certain asset group, use the following method (make sure that you always call this method after onReady):

$("body").bind("notificare:onReady", function(event, data) {

...more code

    instance.notificare("fetchAssets", "ASSET_GROUP", function(assets){
        //Handle list of assets
    }, function(error){
        //Handle error
    });

});

Because you can create groups with the same name but with different time, location or segmentation criteria, this method will give you different assets for different users.

However your app is responsible for handling the assets correctly. In order to do that you will need to handle each asset accordingly. Here's an example how that is usually done:

...more code

instance.notificare("fetchAssets", "ASSET_GROUP", function(assets){

    if ( assets && assets.length > 0 ){

       //Handle assets list
        $.each(assets, function( key, value ) {

            if (value.url) {

                if (value.metaData) {

                    if (value.metaData.contentType.match('image/')) {

                        //Handle images
                    } else if (value.metaData.contentType.match('video/')) {

                        //Handle video
                    } else if (value.metaData.contentType.match('/pdf')) {

                        //Handle PDF
                    } else if (value.metaData.contentType.match('/javascript')) {

                        //Handle Javascript
                    } else if (value.metaData.contentType.match('/json')) {

                        //Handle JSON
                    } else if (value.metaData.contentType.match('/html')) {

                        //Handle HTML
                    } else if (value.metaData.contentType.match('/css')) {

                        //Handle CSS
                    }

                } else {
                    //This should not happen
                }

            } else {
                //No asset image provide, handle just the title or description
            }
        });
    } else {
        //Asset list is empty
    }


}, function(error){
    //Handle error
});