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 the ready event):

notificare.onEventReceived.listen((NotificareEvent event) async {
  if (event.name == "ready") {
    try {
      List<NotificareAsset> assets = await notificare.fetchAssets("GROUP_NAME");
      //Handle Success
    } catch(e){
      //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:

notificare.onEventReceived.listen((NotificareEvent event) async {

  if (event.name == "ready") {

    try {

        List<NotificareAsset> assets = await notificare.fetchAssets("GROUP_NAME");

        if  (response != null && response.length > 0) {
            response.forEach((asset) => {
                if (asset.assetMetaData == null) {

                //If asset only contains text handle the title and description
                } else {

                    if (asset.assetMetaData.contentType == "image/jpeg" || asset.contentType == "image/gif" || asset.contentType == "image/png") {

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

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

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

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

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

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

                        //Handle a HTML file
                    }

                }
            });
        }

    } catch(e){
      //Handle Error
    }

  }

});