How can i trigger ios permission requests at beginning of app (682042)

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.

Thanks in advance.

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.

You can request for camera access by using RequestUserAuthorization. As for photo library access, is that some plugin that you’re using?

The documentation to which you linked says that RequestUserAuthorization is for Web Player. Is it interoperable with iOS permissions?

1 Like

Hi Any update for this question?

1 Like

@inkredibl
It looks like UserAuthorization only has cam and mic… What about photo album?

Here are the plist keys. Is there a way to have these be prompted right when the app starts instead of when it’s accessed?

NSPhotoLibraryUsageDescription
NSPhotoLibraryAddUsageDescription

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());
}
}

I need photo permissions request access as well