So basicly the app requests for two permissions, for camera and access to photo library. The camera is an AR camera, i can trigger that by having a scene with the camera in it and load it at the beginning. The photo library permission popup comes up when i save a picture. The question is how can i trigger the photo library permission without having to save an image.
I think you’d need to write an iOS Obj-C plugin for your Unity project which calls the requestAuthorization() method of the PHPhotoLibrary object. You’d also need the Photo Library privacy key/value pair in your Xcode project’s property list file for it to work.
Here’s a way to generate plist permissions automatically
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode;
using System;
using System.IO;
//=============================================================================
// This PostProcessor does all annoying Xcode steps automatically for us
//=============================================================================
public class PostProcessor
{
[PostProcessBuild]
public static void OnPostProcessBuild(BuildTarget target, string path)
{
if(target != BuildTarget.iOS) { return; }
string plistPath = Path.Combine(path, "Info.plist");
PlistDocument plist = new PlistDocument();
plist.ReadFromString(File.ReadAllText(plistPath));
PlistElementDict rootDict = plist.root;
rootDict.SetString("NSPhotoLibraryUsageDescription", "Can we save your animations to your photo album?");
rootDict.SetString("NSPhotoLibraryAddUsageDescription", "Can we save your animations to your photo album?");
File.WriteAllText(plistPath, plist.WriteToString());
}
}