saveImageToPhotosAlbum
Overview
saveImageToPhotosAlbum:options: saves an image at the specified path to the device's system photo album.
The caller needs to pass the local image file path via SUDOPSaveImageToPhotosAlbumOptions. Based on the passed filePath, the SDK reads the image and performs the operation of saving it to the album.
Type Declaration
objectivec
@interface SUDOPSaveImageToPhotosAlbumOptions : NSObject
@property(nonatomic, strong) NSString *filePath;
@endMethod Declaration
objectivec
/**
Saves an image to the device's photo album.
@param stateHandle The state handle object that manages the operation state and callbacks.
@param options The options configuration for saving the image to the photo album.
*/
- (void)saveImageToPhotosAlbum:(id<SUDOPStateHandle>)stateHandle
options:(SUDOPSaveImageToPhotosAlbumOptions *)options;Parameters
SUDOPSaveImageToPhotosAlbumOptions
| Parameter | Type | Required | Description |
|---|---|---|---|
filePath | NSString * | Yes | The file path of the image to save to the system album. |
Method Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
stateHandle | id<SUDOPStateHandle> | Yes | The state handle object, used to manage the current operation state and callbacks. |
options | SUDOPSaveImageToPhotosAlbumOptions * | Yes | The configuration object for saving the image to the album, containing the image file path. |
Example
objectivec
id<SUDOPStateHandle> stateHandle = self.stateHandle;
SUDOPSaveImageToPhotosAlbumOptions *options = [[SUDOPSaveImageToPhotosAlbumOptions alloc] init];
options.filePath = @"/var/mobile/Containers/Data/Application/xxx/Documents/example.png";
[self saveImageToPhotosAlbum:stateHandle options:options];Process Flow
- The business side prepares the image file to save.
- Confirm that the image file has been written locally and obtain its corresponding file path.
- Create a
SUDOPSaveImageToPhotosAlbumOptionsobject. - Set
options.filePathto the local image file path. - Call
saveImageToPhotosAlbum:options:to initiate the operation of saving the image to the album. - The SDK reads the image based on the passed path and saves it to the system album.
- The save result is typically notified to the business side via the SDK callback or state callback.
Notes
stateHandleshould not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.optionsshould not be empty.filePathshould not be empty and should point to a real, existing local image file.- Before calling, it is recommended to confirm that the file path is accessible, to avoid save failures caused by the file not existing or lacking read permission.
- Before saving to the system album, ensure the App already has album write permission.
- If the system has not yet granted album write permission, the business side should trigger the authorization flow or handle the failure callback according to the actual integration.
- This method has no synchronous return value; the save result should be based on the SDK callback or the system save result.
