Screenshot on ios don't show in IPad gallery

hi,
i need to make a button to make screenshot on ipad, so it will be wisible in device album.

for now i make screenshot by execute command "shot, but it save it in game directory, so it is not visible in album

is there a possibility to make it in blueprints so it will work?

I’m having a similar issue. Any help would be appreciated.

Hi, me too looking for the same issue.

Somebody, please help us to sort this out.

Thank you very much.

I had the same need in a project. Currently, I did not find a blueprint node to this.
So I wrote a simple blueprint callable method in a C++ class.
I use RequestScreenshot from FScreenshotRequest | Unreal Engine Documentation to take the screenshot.
To define the save path, you need to know that the Camera Roll on iOS is at /private/var/mobile/Media/DCIM/

So, using this path plus the file name you want to the image will do what you want.
Your method can be as simple as this:

void ATakeScreenshot::TakeScreenshot()
{
	FString filename = "/private/var/mobile/Media/DCIM/Image.png";
	FScreenshotRequest::RequestScreenshot(filename, false, true);
}

Note that I am using Actor as my base class.

And in your header file you will have:

UFUNCTION(BlueprintCallable, Category = "Take Screenshot")
void TakeScreenshot();

It’s really basic C++.
Take a look here:

In my case, I created a Blueprint class based on this C++ class (which is based on the Actor class) and I put it in my map as an Actor, being able call TakeScreenshot from it.

greeint #andreischwingel,

thank you very much for your generous sharing. I am not a programmer, therefore I am totally no idea of how to start from your method.

Could you please kindly record a simple video for this ? your kindness will be very much appreciated. Thank you very much

hi
#andreischwingel

Can you please provide a more details step by step tutorial on how to do it.

I am still desperate looking for the solution. Thanks

Hi ansonkit.

In the end we used a different solution. For some reason we did not have the time to understand, this solution did not work for the most recent versions of Unreal Engine and iOS.

What we ended doing is:

  1. We created a C++ class with a blueprint callable method that calls FScreenshotRequest::RequestScreenshot. This time we did not use a custom path, just a filename, “Image.png”, and we let Unreal save the screenshot on its default folder. As return from this method, we get the path, calling FScreenshotRequest::GetFilename, so we know where the screenshot is saved (“/YourProjectName/Saved/Screenshots/IOS/Image.png”).

  2. In this same class we created another blueprint callable method only to check if the screenshot is ready (it takes miliseconds, but it’s not instantly done). This can be done with FPaths::FileExists, using the path from the previous method.

  3. Then we created another blueprint callable method to call an Objective-C method. Well, that’s the tricky part, but that’s what worked for us. When we learned that is possible to mix Objective-C code inside the .cpp file, we decided to use a iOS native method to save the screenshot to the album. The method is UIImageWriteToSavedPhotosAlbum. It needs a UIImage as parameter and for that we created an UIImage with imageWithContentsOfFile, passing that path from step 1.

For this third step, you need to know how to call a native iOS method from a .cpp file. What helped us was this two links:

How to access iOS photo library / use Objective-C properly? - Plugins - Epic Developer Community Forums - we actually created our solution based on this one

Accessing iOS SDK possible? - Mobile - Epic Developer Community Forums - Michael Noland explanation

  1. Finally, back to Unreal Editor, we created an Actor with this class, put it in our map, created a reference to it on the level blueprint, and call the C++ methods from it.
  1. Because we are always using the same filename to the screenshot, we need to delete it after saving it to iOS album, so it’s not mistaken by FPaths::FileExists. For this we used FPlatformFileManager::Get().GetPlatformFile().DeleteFile.

In the end, it looked like this:
Screenshooter.cpp

#include "Screenshooter.h"

#if PLATFORM_IOS
#include "IOSAppDelegate.h"
#import <Foundation/Foundation.h>
#endif

#if PLATFORM_IOS

@interface Screenshooter()
@end

@implementation Screenshooter

+ (Screenshooter*)GetDelegate
{
    static Screenshooter* Singleton = [[Screenshooter alloc] init];
    return Singleton;
}

-(void)saveShot
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    
    NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"/<YourProjectName>/Saved/Screenshots/IOS/Image.png"];
    
    UIImage *image = [UIImage imageWithContentsOfFile:filePath];
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
}

+(void)saveScreenshotNative
{
    [[ScreenshotEncoder GetDelegate] performSelectorOnMainThread:@selector(saveShot) withObject:nil waitUntilDone : NO];
}

@end
#endif
  
bool AScreenshooter::IsScreenshotDone(FString savePath)
{
    return FPaths::FileExists(*savePath);
}

FString AScreenshooter::RequestNewScreenshot()
{
    FString filename = "Image.png";
    FScreenshotRequest::RequestScreenshot(filename, false, false);
    return FScreenshotRequest::GetFilename();
}
  
void AScreenshooter::SaveNativeScreenshot()
{
#if PLATFORM_IOS
    [Screenshooter saveScreenshotNative];
#endif
}

Screenshooter.h

#pragma once

#if PLATFORM_IOS
#import <UIKit/UIKit.h>

@interface ScreenshotEncoder : UIViewController <UINavigationControllerDelegate>
@end
#endif

#include "GameFramework/Actor.h"
#include "Screenshooter.generated.h"

UCLASS()
class YOURPROJECT_API AScreenshooter : public AActor
{
    GENERATED_BODY()
    
public:
    AScreenshooter();
    virtual void BeginPlay() override;
    virtual void Tick( float DeltaSeconds ) override;
    
    UFUNCTION(BlueprintCallable, Category = "Screenshooter")
    bool IsScreenshotDone(FString savePath);
    
    UFUNCTION(BlueprintCallable, Category = "Screenshooter")
    FString RequestNewScreenshot();
    
    UFUNCTION(BlueprintCallable, Category = "Screenshooter")
    void DeleteCurrentImage();
    
    UFUNCTION(BlueprintCallable, Category = "Screenshooter")
    void SaveNativeScreenshot();
};

Hi andreischwingel ,

thank you very much for the reply and solution.

I will try it later and let you know the outcome.

thanks

Hi andreischwingel ,

thank you very much for the solution.

and i already try and copy what you have here,but is come out 15 of error.

can you help me?

thanks

because i no a programmer, so did you have any simple tutorial to show how it work~~thank very much,i will precious it

Hi andreischwingel ,
Did you have the full finishing of the function, i would to buy with you.
Because i need it urgent. please relpy me as fast you can,
i precious it,thank you

Hi! I was traveling and could not answer.
I don’t have the full project anymore. But I will reproduce the steps I wrote above and send you the project someway.

thank you so much for your reply and kindness of sharing.

If you have skype, please add me

Hope to hear from you soon. Thank you.

Received with many thanks. Will try it later.

Thank you very much,

I sent you an email with the example project attached.

Hi. By chance, anyone knows if Epic implemented a solution so we dont have to use C/C++ (due I am actually working with a PC Computer to the Ipad, so its seems I need a mac to develop code to test to the ipad and unfortunatelly I dont have one)

Regards

Has anyone managed to figure this out yet? I’d really like to find out how to take a screen shot in app and have it saved to the camera roll too. I can’t code yet either :wink:

#Keepitvisual
can you tell me how to save it to camera roll :open_mouth: Please :smiley: