Attachments and Media
This section contains some useful attachments and media classes.
- ICAttachment
- ICAudioAttachment
- ICImageAttachment
- ICLocationAttachment
- ICMediaAttachment
- ICVideoAttachment
- ICMediaFileManager
- ICTemplateAttachment
- ICFormTemplateAttachment
- ICGenericTemplateAttachment
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.
Property | Description |
---|---|
@property (nonatomic) NSString *contentType; | The content type of the attachment, such as image, video, audio or location |
ICAudioAttachment
Represents an audio file attachment.
Property | Description |
---|---|
@property (nonatomic) long duration; | The duration of the audio attachment |
ICImageAttachment
Represents an image attachment.
Property | Description |
---|---|
@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.
Property | Description |
---|---|
@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.
Property | Description |
---|---|
@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.
Property | Description |
---|---|
@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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
location | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
location | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
filePath | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Type | Description |
---|---|---|
url | NSURL | The 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:
Parameter | Description |
---|---|
@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:
Parameter | Type | Description |
---|---|---|
typeString | NSString | Specifies 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;
Parameter | Type | Description |
---|---|---|
type | ICTemplateType | Specifies 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:
Property | Description |
---|---|
@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:
Property | Description |
---|---|
@property (nonatomic) NSArray<ICGenericTemplateElement > elements; | The template elements |
Updated about 1 year ago