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

[[NotificarePushLib shared] fetchAssets:@"ASSET_GROUP" completionHandler:^(NSArray *info) {
    //Handle list of assets
} errorHandler:^(NSError *error) {
    //Handle error
}];
NotificarePushLib.shared().fetchAssets("ASSET_GROUP", completionHandler: {(_ info: [Any]) -> Void in
    //Handle list of assets
}, errorHandler: {(_ error: Error?) -> Void in
    //Handle error fetching assets
})

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:

[[NotificarePushLib shared] fetchAssets:@"ASSET_GROUP" completionHandler:^(NSArray *info) {

    for (NotificareAsset *item in info) {
        if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"image/jpeg"] ||
           [[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"image/gif"] ||
           [[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"image/png"]){

            //Handle Images

        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"video/mp4"]){

            //Handle Video
        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"application/pdf"]){

            //Handle PDF
        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"application/json"]){

            //Handle JSON
        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"text/javascript"]){

           //Handle Javascript
        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"text/css"]){

            //Handle CSS
        } else if([[[item assetMetaData] objectForKey:@"contentType"] isEqualToString:@"text/html"]){

            //Handle HTML
        }
    }

} errorHandler:^(NSError *error) {
    //Handle error fetching assets
}];
NotificarePushLib.shared().fetchAssets("ASSET_GROUP", completionHandler: {(_ info: [Any]) -> Void in
    for item: NotificareAsset in info {
        if (item.assetMetaData()["contentType"] == "image/jpeg") || (item.assetMetaData()["contentType"] == "image/gif") || (item.assetMetaData()["contentType"] == "image/png") {
            //Handle Images
        }
        else if (item.assetMetaData()["contentType"] == "video/mp4") {
            //Handle Video
        }
        else if (item.assetMetaData()["contentType"] == "application/pdf") {
            //Handle PDF
        }
        else if (item.assetMetaData()["contentType"] == "application/json") {
            //Handle JSON
        }
        else if (item.assetMetaData()["contentType"] == "text/javascript") {
            //Handle Javascript
        }
        else if (item.assetMetaData()["contentType"] == "text/css") {
            //Handle CSS
        }
        else if (item.assetMetaData()["contentType"] == "text/html") {
            //Handle HTML
        }
    }
}, errorHandler: {(_ error: Error?) -> Void in
    //Handle error fetching assets
})