I tested our app on iOS 10.3
In previous versions, our app was fine.
Our app saves the streamed video as mp4 video file having korean filename in the Document folder in the App.
and then moves it to the video album after saving. It was normal.
But In this version when it have korean file name, Save file is fine, but It can not moved to album.
Does anyone have this problem? Below is our test code.
If it is a 10.3 issue, please fix it.
Or Do you have any recommendation method for fixing this problem?
File Creation Method .
NSString *cameraName = self.currentCamera.name;
NSString *path = [NSString stringWithFormat:@"%@_rec_%@.mp4", cameraName, [self createCurrentDateString]];
const char *filename = [path UTF8String];
mFd = open(filename, O_CREAT /| O_LARGEFILE*/ | O_TRUNC | O_RDWR, 00666);
Save To Album Method
- (void) saveFileToAlbumWithPath:(NSString*) directory path:(NSString*)path {
__block PHFetchResult *photosAsset;
__block PHAssetCollection *collection;
__block PHObjectPlaceholder *placeholder;
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.predicate = [NSPredicate predicateWithFormat:@"title = %@", directory];
collection = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum
subtype:PHAssetCollectionSubtypeAny
options:fetchOptions].firstObject;
[[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{
PHAssetChangeRequest *assetRequest;
/
if([directory isEqualToString:HOMECAME_RECORD]){
assetRequest = [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:[NSURL fileURLWithPath:path]];
}else{
assetRequest = [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:[NSURL fileURLWithPath:path]];
}
placeholder = [assetRequest placeholderForCreatedAsset];
photosAsset = [PHAsset fetchAssetsInAssetCollection:collection options:nil];
PHAssetCollectionChangeRequest *albumChangeRequest = [PHAssetCollectionChangeRequest changeRequestForAssetCollection:collection assets:photosAsset];
[albumChangeRequest addAssets:@[placeholder]];
} completionHandler:^(BOOL success, NSError *error) {
if (success) {
dispatch_async(dispatch_get_main_queue(), ^{
if([directory isEqualToString:HOMECAME_RECORD]){
[self.view makeToast:commonStr(@"toast_monitoring_saved_recording_file") duration:2.0f position:CSToastPositionBottom];
} else {
[self.view makeToast:commonStr(@"toast_monitoring_saved_screenshot") duration:2.0f position:CSToastPositionBottom];
}
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
if([directory isEqualToString:HOMECAME_RECORD]){
[self.view makeToast:commonStr(@"toast_monitoring_fail_saved_recording") duration:2.0f position:CSToastPositionBottom];
} else {
[self.view makeToast:commonStr(@"toast_monitoring_fail_saved_screenshot") duration:2.0f position:CSToastPositionBottom];
}
});
NSLog(@"Failed to save media file error :%@", error);
}
}];
}