Attachments and Media

This section contains some useful attachments and media classes.

ICAttachment

The base class for message attachments exposes elements common to all types of attachments.
Attachments can be present on both incoming and outgoing messages.

PropertyDescription
@property (nonatomic) NSString *contentType;The content type of the attachment, such as image, video, audio or location

ICAudioAttachment

Represents an audio file attachment.

PropertyDescription
@property (nonatomic) long duration;The duration of the audio attachment

ICImageAttachment

Represents an image attachment.

PropertyDescription
@property (nonatomic) UIImage *preview;The preview thumbnail as a UIImage

ICLocationAttachment

Represents location data that may be attached to a message.

Location data is comprised of latitude and longitude.

PropertyDescription
@property (nonatomic) double longitude;The longitude of the location
@property (nonatomic) double latitude;The latitude of the location

ICMediaAttachment

Base class for message attachments which exposes data common to all types of the media files.

PropertyDescription
@property (nonatomic) NSString *mediaId;The ID of the media attachment hosted within the Webex Connect platform
@property (nonatomic, readonly) long size;The size of the media in bytes
@property (nonatomic, readonly) NSURL *url;The URL to where the media is located
@property (nonatomic) NSURL *filePath;The local file path

ICVideoAttachment

Represents an attachment that contains video data.

PropertyDescription
@property (nonatomic) UIImage *preview;The preview thumbnail as a UIImage
@property (nonatomic) long duration;The duration of the video

ICMediaFileManager

The following new Method added in this class ICMediaFileManager.

regenerateMediaURL: completionHandler

Regenerates new media URL for given Media URL upon checking expiry.

Syntax: + (void)regenerateMediaURL:(NSURL *)url completionHandler:(void(^)(NSURL *mediaURL, NSError *error))completionHandler;

Parameters:

ParameterTypeDescription
urlNSURLThe media URL to which new url regenerates.
completionHandler(NSURL mediaURL, NSError error)completionHandler that will be call once the new media URL is generated.

Manages the process of uploading and downloading content for media file attachments.

isProcessing

Informs if the manager is currently downloading or uploading a file.

Syntax: + (BOOL)isProcessing;

Return Value: Returns YES if the manager is currently downloading/uploading a file, NO otherwise

uploadFileFromLocation

Uploads a file from a URL

Syntax: + (void)uploadFileFromLocation:(NSURL *)location progressHandler:(void(^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progressHandler completionHandler:(void(^)(NSString *mediaId, NSError *error))completionHandler;

Parameters:

ParameterTypeDescription
locationNSURLThe URL of the local file
progressHandler(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite)A progressHandler that will inform on the current progress of the upload
completionHandler(NSString mediaId, NSError error)A completionHandler that will be call once the file is uploaded with the associated mediaId

isFileUploadingFromLocation

Checks if the manager is currently uploading a file from a local URL.

Syntax: + (BOOL)isFileUploadingFromLocation:(NSURL *)location;

Parameters:

ParameterTypeDescription
locationNSURLThe local URL of the file

Return Value: Returns YES if the file is currently being uploaded

addObserverForFileAtPath

Observes the upload of a file.

Syntax: + (void)addObserverForFileAtPath:(NSURL *)filePath completionHandler:(void(^)(NSError *error))completionHandler;.

Parameters:

ParameterTypeDescription
filePathNSURLThe filePath of the file that is being observed
completionHandler(NSError *error)A completionHandler that will be called once the file is uploaded

downloadFileAtURL :progressHandler :completionHandler

Downloads a file from a URL if needed else retrieve a file locally if already downloaded or queue the completionHandler if the file associated to the URL is already being downloaded.

Syntax: + (void)downloadFileAtURL:(NSURL *)url progressHandler:(void(^)(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead))progressHandler completionHandler:(void(^)(NSData *contentOfFile, NSURL *filePath, NSError *error))completionHandler;

Parameters:

ParameterTypeDescription
urlNSURLThe URL of the file
progressHandler(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead)A progressHandler that will be called when ever the download manager downloads few bytes
completionHandler(NSData contentOfFile, NSURL filePath, NSError *error)A completionHandler that will be call once the file is downloaded

isFileDownloadingAtURL

Checks if the manager is currently downloading a file at a URL.

Syntax: + (BOOL)isFileDownloadingAtURL:(NSURL *)url;

Parameters:

ParameterTypeDescription
urlNSURLThe URL of the file that will be checked

Return Value: Returns YES if the file is currently being downloaded.

contentOfFileForURL

Retrieves the content of a file associated to a URL.

Syntax: + (void)contentOfFileForURL:(NSURL *)url completionHandler:(void(^)(NSData *contentOfFile))completionHandler;

Parameters:

ParameterTypeDescription
urlNSURLThe URL associated to the content
completionHandler(NSData *contentOfFile)A completion that will be called with the content if the content exists, nil otherwise

filePathForURL

Retrieves the filePath where the content of the file at the passed URL is stored.

Syntax: + (NSURL *)filePathForURL:(NSURL *)url;

Parameters:

ParameterTypeDescription
urlNSURLThe URL where the content has been retrieved

Return Value: Returns the filePath where the content is locally located.

fileExistsForURL

Checks if a file exists for a URL.

Syntax: + (BOOL)fileExistsForURL:(NSURL *)url;

Parameters:

ParameterTypeDescription
urlNSURLThe URL to be checked

Return Value: Returns YES if the file exists, NO otherwise.

Classes

The following new classes added in this version of SDK.

ICTemplateAttachment

This class exposes the data related to a Template Attachment.

Properties:

ParameterDescription
@property (
nonatomic) ICTemplateType templateType;
The Type of the Template
@property (
nonatomic) NSString *templateID;
The ID of the Template
@property (
nonatomic) NSString *reference;
The template reference

Methods:

typeFromString:typeString:

This method Converts the Field Type String to ICTemplateType.

Syntax: + (ICTemplateType)typeFromString:(NSString *)typeString;

Parameters:

ParameterTypeDescription
typeStringNSStringSpecifies the template type

Return Value: Returns the ICTemplateType value equals to typeString passed to this method.

Sample Code:

ICTemplateType templateType  = [ICTemplateAttachment typeFromString:@”form”];

stringFromType:type:

This method Converts the ICTemplateType to String.

Syntax: + (NSString *)stringFromType:( ICTemplateType)type;

ParameterTypeDescription
typeICTemplateTypeSpecifies the template type

Return Value: Returns the string value equals to ICTemplateType passed to this method.

Sample Code:

NSString *templateType  = [ICTemplateAttachment stringFromType: ICTemplateTypeForm];

ICFormTemplateAttachment

This class exposes the data related to a Form Template.

Properties:

PropertyDescription
@property (nonatomic) NSString *formTitle;The Form Title
@property (nonatomic) NSArray *formFields;The Form Fields

ICGenericTemplateAttachment

This class exposes the data related to generic template attachment.

Properties:

PropertyDescription
@property (nonatomic)
NSArray<ICGenericTemplateElement > elements;
The template elements