Skip to content

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;

@end

Method 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 ​

ParameterTypeRequiredDescription
filePathNSString *YesThe file path of the image to save to the system album.

Method Parameters ​

ParameterTypeRequiredDescription
stateHandleid<SUDOPStateHandle>YesThe state handle object, used to manage the current operation state and callbacks.
optionsSUDOPSaveImageToPhotosAlbumOptions *YesThe 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 ​

  1. The business side prepares the image file to save.
  2. Confirm that the image file has been written locally and obtain its corresponding file path.
  3. Create a SUDOPSaveImageToPhotosAlbumOptions object.
  4. Set options.filePath to the local image file path.
  5. Call saveImageToPhotosAlbum:options: to initiate the operation of saving the image to the album.
  6. The SDK reads the image based on the passed path and saves it to the system album.
  7. The save result is typically notified to the business side via the SDK callback or state callback.

Notes ​

  • stateHandle should not be empty; otherwise the SDK may fail to correctly manage the current operation state or callbacks.
  • options should not be empty.
  • filePath should 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.