Stack Class Reference

Inherits from NSObject
Declared in Stack.h

Properties

  apiKey

Readonly property to check value of apikey

@property (nonatomic, copy, readonly) NSString *apiKey

Declared In

Stack.h

  accessToken

Readonly property to check value of access token

@property (nonatomic, copy, readonly) NSString *accessToken

Declared In

Stack.h

  environment

Readonly property to check value of environment provided

@property (nonatomic, copy, readonly) NSString *environment

Declared In

Stack.h

  config

Readonly property to check value of config provided

@property (nonatomic, copy, readonly) Config *config

Declared In

Stack.h

ContentType

– contentTypeWithName:

Gets the new instance of ContentType object with specified name.

- (ContentType *)contentTypeWithName:(NSString *)contentTypeName

Parameters

contentTypeName

name of the contentType to perform action.

Return Value

instance of ContentType.

Discussion

//Obj-C
ContentType *contentTypeObj = [stack contentTypeWithName:@"blog"];

//Swift
var contentTypeObj:ContentType = stack.contentTypeWithName("blog")

Declared In

Stack.h

Manually set headers

– setHeader:forKey:

Set a header for Stack

- (void)setHeader:(NSString *)headerValue forKey:(NSString *)headerKey

Parameters

headerValue

The header key

headerKey

The header value

Discussion

//Obj-C
[stack setHeader:@"MyValue" forKey:@"My-Custom-Header"];

//Swift
stack.setHeader("MyValue", forKey: "My-Custom-Header")

Declared In

Stack.h

– addHeadersWithDictionary:

Set a header for Stack

- (void)addHeadersWithDictionary:(NSDictionary<NSString*,NSString*> *)headers

Parameters

headers

The headers as dictionary which needs to be added to the application

Discussion

//Obj-C
[stack addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];

//Swift
stack.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])

Declared In

Stack.h

– removeHeaderForKey:

Removes a header from this Stack.

- (void)removeHeaderForKey:(NSString *)headerKey

Parameters

headerKey

The header key that needs to be removed

Discussion

//Obj-C
[stack removeHeaderForKey:@"My-Custom-Header"];

//Swift
stack.removeHeaderForKey("My-Custom-Header")

Declared In

Stack.h

Asset and AssetLibrary

– assetLibrary

Represents a Asset on ‘Stack’ which can be executed to get AssetLibrary object

- (AssetLibrary *)assetLibrary

Return Value

Returns new AssetLibrary instance

Discussion

 //Obj-C
 AssetLibrary *assetLib = [stack assetLibrary];

 //Swift
 var assetLib: AssetLibrary = stack.assetLibrary()

Declared In

Stack.h

– asset

Represents a Asset on ‘Stack’ which can be executed to get Asset object

- (Asset *)asset

Return Value

Returns new Asset instance

Discussion

 //Obj-C
 Asset *assetObj = [stack asset];

 //Swift
 var assetObj:Asset = stack.asset()

Declared In

Stack.h

– assetWithUID:

Gets the new instance of Asset object with specified UID.

- (Asset *)assetWithUID:(NSString *)uid

Parameters

uid

uid of the Asset object to fetch.

Return Value

new instance of Asset with uid.

Discussion

 //Obj-C
 Asset *assetObj = [contentTypeObj assetWithUID:@"bltf4fsamplec851db"];

 //Swift
 var assetObj:Asset = contentTypeObj.assetWithUID("bltf4fsamplec851db")

Declared In

Stack.h

– imageTransformWithUrl:andParams:

Transforms provided image url based on transformation parameters.

- (NSString *)imageTransformWithUrl:(NSString *)url andParams:(NSDictionary<NSString*,id> *)params

Parameters

url

Url on which transformations to be applied.

params

Transformation parameters.

Return Value

new instance of transform url.

Discussion

 //Obj-C
 NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:100], @"width", [NSNumber numberWithInt:100], @"height", nil];
 NSString *transformedUrl = [stack imageTransformWithUrl:imageURL andParams:params];

 //Swift
 let params:[String : AnyObject?] = [
 "width":100 as AnyObject,
 "height":100 as AnyObject,
 ];
 let transformedUrl:String = stack.imageTransformation(withUrl: imageURL, andParams: params);

Declared In

Stack.h

ContentTypes Schema

– getContentTypes:completion:

Gets all the ContentTypes and its Schema defination.

- (void)getContentTypes:(NSDictionary<NSString*,id> *_Nullable)params completion:(void ( ^ ) ( NSArray<NSString*> *BUILT_NULLABLE_P contentTypes , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

params

params is dictionary of additional parameter

completionBlock

block to be called once operation is done.

Discussion

 //Obj-C
 [csStack getContentTypes:params completion:^(NSArray * _Nullable contentTypes, NSError * _Nullable error) {

 }];

 //Swift
 csStack.getContentTypes(params, { (contentTypes, error) in

 })

Declared In

Stack.h

Sync

– sync:

The Initial Sync request performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response. The response also contains a sync token, which you need to store, since this token is used to get subsequent delta updates later.

- (void)sync:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

completionBlock

called synchronization is done.

Discussion

 //Obj-C
     [stack sync:^(SyncStack * _Nullable syncStack, NSError * _Nullable error) {

     }];

 //Swift
     stack.sync({ ( syncStack:SyncStack, error: NSError) in

     })

Declared In

Stack.h

– syncPaginationToken:completion:

If the result of the initial sync (or subsequent sync) contains more than 100 records, the response would be paginated. It provides pagination token in the response. However, you do not have to use the pagination token manually to get the next batch, the SDK does that automatically until the sync is complete. Pagination token can be used in case you want to fetch only selected batches. It is especially useful if the sync process is interrupted midway (due to network issues, etc.). In such cases, this token can be used to restart the sync process from where it was interrupted.

- (void)syncPaginationToken:(NSString *)token completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncResult , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

token

Pagination token from where to perform sync

completionBlock

called synchronization is done.

Discussion

//Obj-C

NSString *token = @“blt129393939”; //Pagination token [stack syncPaginationToken:token completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift var token = @“blt129393939”; //Pagination token syncPaginationToken(token, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h

– syncToken:completion:

You can use the sync token (that you receive after initial sync) to get the updated content next time. The sync token fetches only the content that was added after your last sync, and the details of the content that was deleted or updated.

- (void)syncToken:(NSString *)token completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

token

Sync token from where to perform sync

completionBlock

called synchronization is done.

Discussion

 //Obj-C

     NSString *token = @"blt129393939"; //Sync token
     [stack syncToken:token completion:^(SyncStack * _Nullable syncStack, NSError * _Nullable error) {

     }];

 //Swift
     var token = @"blt129393939"; //Sync token
     stack.syncToken(token, completion: { ( syncStack:SyncStack, error: NSError) in

     })

Declared In

Stack.h

– syncOnly:completion:

You can also initialize sync with entries of only specific content types. To do this, use sync With ContentType and specify the content type UID as its value. However, if you do this, the subsequent syncs will only include the entries of the specified content types.

- (void)syncOnly:(NSString *)contentType completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

contentType

uid of classes to be expected.

completionBlock

called synchronization is done.

Discussion

//Obj-C

    NSArray *contentTypeArray = @[@"product", @"multifield"]; //Content type uids that want to sync.
     [stack syncOnly:contentTypeArray completion:^(SyncStack * _Nullable syncStack, NSError * _Nullable error) {

     }];

 //Swift
     let contentTypeArray = ["product", "multifield"]; //Content type uids that want to sync.
     stack.syncOnly(contentTypeArray, completion: { ( syncStack:SyncStack, error: NSError) in

     })

Declared In

Stack.h

– syncFrom:completion:

You can also initialize sync with entries published after a specific date. To do this, use sync Date and specify the start date as its value.

- (void)syncFrom:(NSDate *)date completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

date

date from where sync data is needed.

completionBlock

called synchronization is done.

Discussion

//Obj-C

NSDate *date = [NSDate date]; //date from where synchronization is called [stack syncFrom:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift let date = Date.date() //date from where synchronization is called stack.syncFrom(date, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h

– syncOnly:from:completion:

Perform a synchronization operation on specified classes and from date.

- (void)syncOnly:(NSString *)contentType from:(NSDate *)date completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

contentType

uid of classes to be expected.

date

from where sync data is needed.

completionBlock

called synchronization is done.

Discussion

 //Obj-C

NSArray *contentTypeArray = @[@"product", @"multifield"]; //Content type uids that want to sync.
     NSDate *date = [NSDate date]; //date from where synchronization is called
     [[stack syncOnly:contentTypeArray from:date completion:^(SyncStack * _Nullable syncStack, NSError * _Nullable error) {

     }];

 //Swift
     let date = Date.date() //date from where synchronization is called
     let contentTypeArray = ["product", "multifield"]; //Content type uids that want to sync.
     stack.syncOnly(contentTypeArray, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

     })

Declared In

Stack.h

– syncPublishType:completion:

Use the type parameter to get a specific type of content. You can pass one of the following values: ‘ASSET_PUBLISHED’, ‘ENTRY_PUBLISHED’, ‘ASSET_UNPUBLISHED’, ‘ENTRY_UNPUBLISHED’, ‘ASSET_DELETED’, ‘ENTRY_DELETED’, ‘CONTENT_TYPE_DELETED’.

- (void)syncPublishType:(PublishType)publishType completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

publishType

for which sync is needed.

completionBlock

called synchronization is done.

Discussion

     //Obj-C

     NSDate *date = [NSDate date]; //date from where synchronization is called.

     [[stack syncPublishType:ENTRY_PUBLISHED completion:^(SyncStack * _Nullable syncStack, NSError * _Nullable error) {

     }];

     //Swift

     let date = Date.date() //date from where synchronization is called.

     stack.syncPublishType:ENTRY_PUBLISHED, completion: { ( syncStack:SyncStack, error: NSError) in

     })

Declared In

Stack.h

– syncLocale:completion:

You can also initialize sync with entries of only specific locales. To do this, use sync Locale and specify the locale code as its value. However, if you do this, the subsequent syncs will only include the entries of the specified locales.

- (void)syncLocale:(NSString *)locale completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

locale

for which sync is needed.

completionBlock

called synchronization is done.

Discussion

//Obj-C

[[stack syncLocale:ENGLISH_UNITED_STATES completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift stack.syncLocale(ENGLISH_UNITED_STATES, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h

– syncLocale:from:completion:

Perform a synchronization operation on specified locale and from date.

- (void)syncLocale:(NSString *)locale from:(NSDate *)date completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

locale

for which sync is needed.

date

from where sync data is needed.

completionBlock

called synchronization is done.

Discussion

//Obj-C

NSDate *date = [NSDate date]; //date from where synchronization is called. [[stack syncLocale:ENGLISH_UNITED_STATES from:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift

let date = Date.date() //date from where synchronization is called. stack.syncLocale(ENGLISH_UNITED_STATES, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h

– syncOnly:locale:from:completion:

Perform a synchronization operation on specified classes, locale and from date.

- (void)syncOnly:(NSString *)contentType locale:(NSString *)locale from:(NSDate *BUILT_NULLABLE_P)date completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

contentType

uid of classes to be expected.

locale

for which sync is needed.

date

from where sync data is needed.

completionBlock

called synchronization is done.

Discussion

//Obj-C

NSArray *contentTypeArray = @[@“product”, @“multifield”]; //Content type uids that want to sync.

NSDate *date = [NSDate date]; //date from where synchronization is called.

[[stack syncOnly: contentTypeArray locale:ENGLISH_UNITED_STATES from:date completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift

let contentTypeArray = [“product”, “multifield”]; //Content type uids that want to sync. let date = Date.date() //date from where synchronization is called.

stack.syncOnly(contentTypeArray, locale:ENGLISH_UNITED_STATES, from: date, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h

– syncOnly:locale:from:publishType:completion:

Perform a synchronization operation on specified classes, locale, date and publishType.

- (void)syncOnly:(NSString *)contentType locale:(NSString *)locale from:(NSDate *BUILT_NULLABLE_P)date publishType:(PublishType)publishType completion:(void ( ^ ) ( SyncStack *BUILT_NULLABLE_P syncStack , NSError *BUILT_NULLABLE_P error ))completionBlock

Parameters

contentType

uid of classes to be expected.

locale

for which sync is needed.

date

from where sync data is needed.

publishType

for which sync is needed.

completionBlock

called synchronization is done.

Discussion

//Obj-C

NSArray *contentTypeArray = @[@“product”, @“multifield”]; //Content type uids that want to sync.

NSDate *date = [NSDate date]; //date from where synchronization is called.

[[stack syncOnly: contentTypeArray locale:ENGLISH_UNITED_STATES from:date publishType:ENTRY_PUBLISHED completion:^(SyncStack * Nullable syncStack, NSError * Nullable error) {

}];

//Swift

let contentTypeArray = [“product”, “multifield”]; //Content type uids that want to sync.

let date = Date.date() //date from where synchronization is called.

stack.syncOnly(contentTypeArray, locale:ENGLISH_UNITED_STATES, from: date, publishType:ENTRY_PUBLISHED, completion: { ( syncStack:SyncStack, error: NSError) in

})

Declared In

Stack.h