Skip to content

Save to Camera Roll

Stanislav Osipov edited this page Feb 7, 2021 · 5 revisions

Save any texture to camera roll is fairly simple, and can be accomplished with ISN_PhotoAlbum class. The example below adds the specified image to the user’s Camera Roll album. When used on an iOS device without a camera, this method adds the image to the Saved Photos album rather than to the Camera Roll album.

using SA.iOS.UIKit;
...
Texture2D myImage = GetImage();
ISN_PhotoAlbum.UIImageWriteToSavedPhotosAlbum(image, (result) =>
{
    if (result.IsSucceeded)
        Debug.Log("Image saved");
    else
        Debug.Log("Error: " + result.Error.Message);
});

There is also an ability to save a screenshot out of the box

using SA.iOS.UIKit;
...
ISN_PhotoAlbum.SaveScreenshotToCameraRoll((result) => {
    if (result.IsSucceeded) {
        Debug.Log("screenshot saved saved");
    } else {
        Debug.Log("Error: " + result.Error.Message);
    }
});

Important: Do not forget that you can use Photo Library related API, only after a user has authorized access to Photo Library for your app. If you'll try to use API without authorization, the system will ask for authorization automatically. If a user will allow Photo Library access, you good, otherwise, an operation will be failed and you may not even receive a callback from the method. So it's in your best interest to request user authorization before you attempt to use a Photo Library. Read more about Photo Library authorization here.

About

Foundation

AV Foundation

App Tracking Transparency

Game Kit

Store Kit

UI Kit

Social

Replay Kit

Contacts

AVKit

Photos

App Delegate

User Notifications

MediaPlayer

Core Location

AdSupport

EventKit

CloudKit

Authentication Services

XCode

Knowledge Base

Clone this wiki locally