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 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):

Notificare.shared().fetchAssets("ASSET_GROUP", new NotificareCallback<List<NotificareAsset>>() {
    @Override
    public void onSuccess(List<NotificareAsset> notificareAssets) {
        for (NotificareAsset asset : notificareAssets) {
            Log.d(TAG, asset.getTitle());
        }
    }
    @Override
    public void onError(NotificareError notificareError) {
        Log.e(TAG, "Error: " + notificareError.getMessage());
    }
});
Notificare.shared().fetchAssets("ASSET_GROUP", object : NotificareCallback<List<NotificareAsset>> {
    override fun onSuccess(notificareAssets: List<NotificareAsset>) {
        for (asset in notificareAssets) {
            Log.d(TAG, asset.title)
        }
    }

    override fun onError(notificareError: NotificareError) {
        Log.e(
            TAG,
            "Error: " + notificareError.message
        )
    }
})

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:

Notificare.shared().fetchAssets("ASSET_GROUP", new NotificareCallback<List<NotificareAsset>>() {
    @Override
    public void onSuccess(List<NotificareAsset> notificareAssets) {
        for (NotificareAsset asset : notificareAssets) {

            if (asset.getKey() == null) {

                //If asset only contains text handle the title and description
                //notificareAsset.getTitle()
                //notificareAsset.getDescription()
            } else {

                if (asset.getContentType().equals("image/jpeg") ||
                                asset.getContentType().equals("image/gif") ||
                                asset.getContentType().equals("image/png"))) {


                    //Handle an image
                    //asset.getUrl()
                } else if(asset.getContentType().equals("video/mp4")){

                    //Handle a video
                    //asset.getUrl()
                } else if(asset.getContentType().equals("application/pdf")){

                    //Handle a pdf
                    //asset.getUrl()
                } else if(asset.getContentType().equals("application/json")){

                    //Handle a json file
                    //asset.getUrl()
                } else if(asset.getContentType().equals("text/javascript")){

                    //Handle a javascript file
                    //asset.getUrl()
                } else if(asset.getContentType().equals("text/css")){

                    //Handle a css
                    //asset.getUrl()
                } else if(asset.getContentType().equals("text/html")){

                    //Handle a HTML file
                    //asset.getUrl()
                }

            }

        }
    }
    @Override
    public void onError(NotificareError notificareError) {
        Log.e(TAG, "Error: " + notificareError.getMessage());
    }
});
Notificare.shared().fetchAssets("ASSET_GROUP", object : NotificareCallback<List<NotificareAsset>> {
    override fun onSuccess(notificareAssets: List<NotificareAsset>) {
        for (asset in notificareAssets) {
            if (asset.key == null) {

                //If asset only contains text handle the title and description
                //notificareAsset.getTitle()
                //notificareAsset.getDescription()
            } else {
                if (asset.contentType == "image/jpeg" || asset.contentType == "image/gif" || asset.contentType == "image/png") {


                    //Handle an image
                    //asset.getUrl()
                } else if (asset.contentType == "video/mp4") {

                    //Handle a video
                    //asset.getUrl()
                } else if (asset.contentType == "application/pdf") {

                    //Handle a pdf
                    //asset.getUrl()
                } else if (asset.contentType == "application/json") {

                    //Handle a json file
                    //asset.getUrl()
                } else if (asset.contentType == "text/javascript") {

                    //Handle a javascript file
                    //asset.getUrl()
                } else if (asset.contentType == "text/css") {

                    //Handle a css
                    //asset.getUrl()
                } else if (asset.contentType == "text/html") {

                    //Handle a HTML file
                    //asset.getUrl()
                }
            }
        }
    }

    override fun onError(notificareError: NotificareError) {
        Log.e(TAG, "Error: " + notificareError.message)
    }
})