SDK

Storage

This is an add-on feature of Notificare. Before you can use this functionality you must subscribe 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 created one or more asset groups, to retrieve a certain asset group, use the following method:

Notificare.assets().fetch("ASSET_GROUP", object : NotificareCallback<List<NotificareAsset>> {
    override fun onSuccess(result: List<NotificareAsset>) {

    }

    override fun onFailure(e: Exception) {

    }
})
NotificareAssetsCompat.fetch("ASSET_GROUP", new NotificareCallback<List<NotificareAsset>>() {
    @Override
    public void onSuccess(List<NotificareAsset> result) {

    }

    @Override
    public void onFailure(@NonNull Exception e) {

    }
});

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.assets().fetch("ASSET_GROUP", object : NotificareCallback<List<NotificareAsset>> {
    override fun onSuccess(result: List<NotificareAsset>) {
        result.forEach { asset ->
            if (asset.url == null) {
                // If asset only contains text handle the title and description.
                // asset.title
                // asset.description
                return@forEach
            }

            when (asset.metaData?.contentType) {
                "image/jpeg", "image/gif", "image/png" -> {
                    // Handle image asset.
                    // asset.url
                }
                "video/mp4" -> {
                    // Handle video asset.
                    // asset.url
                }
                "application/pdf" -> {
                    // Handle PDF asset.
                    // asset.url
                }
                "application/json" -> {
                    // Handle JSON file asset.
                    // asset.url
                }
                "text/javascript" -> {
                    // Handle Javascript file asset.
                    // asset.url
                }
                "text/css" -> {
                    // Handle CSS file asset.
                    // asset.url
                }
                "text/html" -> {
                    // Handle HTML file asset.
                    // asset.url
                }
            }
        }
    }

    override fun onFailure(e: Exception) {

    }
})
NotificareAssetsCompat.fetch("ASSET_GROUP", new NotificareCallback<List<NotificareAsset>>() {
    @Override
    public void onSuccess(List<NotificareAsset> result) {
        for (NotificareAsset asset : result) {
            if (asset.getUrl() == null) {
                // If asset only contains text handle the title and description.
                // asset.title
                // asset.description
                return;
            } else if (asset.getMetaData() != null) {
                if (asset.getMetaData().getContentType().equals("image/jpeg") ||
                        asset.getMetaData().getContentType().equals("image/gif") ||
                        asset.getMetaData().getContentType().equals("image/png")) {
                    // Handle image asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("video/mp4")) {
                    // Handle video asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("application/pdf")) {
                    // Handle PDF asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("application/json")) {
                    // Handle JSON file asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("text/javascript")) {
                    // Handle Javascript file asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("text/css")) {
                    // Handle CSS file asset.
                    // asset.url
                } else if (asset.getMetaData().getContentType().equals("text/html")) {
                    // Handle HTML file asset.
                    // asset.url
                }
            }
        }
    }

    @Override
    public void onFailure(@NonNull Exception e) {

    }
});