gpt4 book ai didi

c# - 如何使用 Unity 为 iOS 应用程序自动设置关联域

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:06:26 25 4
gpt4 key购买 nike

我现在正在使用 Unity 开发一个 iOS 应用程序,我正在尝试设置关联的域,而无需在 xcode 上手动设置它。我相信我可以使用 PostProcessBuild 实现这一点,但我无法理解这一点

public class AvametricIOSBuildPostProcessor
{

static string[] associatedDomains;
[PostProcessBuild]
public static void OnPostprocessBuild (BuildTarget target, string pathToBuiltProject)
{
if (target == BuildTarget.iOS)
OnPostprocessBuildIOS (pathToBuiltProject);
}

private static void OnPostprocessBuildIOS (string pathToBuiltProject)
{

var projectCapabilityManager = new ProjectCapabilityManager(plistPath, plistPath, "Unity-iPhone");
associatedDomains[0] = "applinks:XXXXX";
projectCapabilityManager.AddAssociatedDomains(associatedDomains);


}
}

最佳答案

我通过这样做设法添加了关联域

private static void OnProstProcessBuildIOS(string pathToBuiltProject)
{
//This is the default path to the default pbxproj file. Yours might be different
string projectPath = "/Unity-iPhone.xcodeproj/project.pbxproj";
//Default target name. Yours might be different
string targetName = "Unity-iPhone";
//Set the entitlements file name to what you want but make sure it has this extension
string entitlementsFileName = "my_app.entitlements";

var entitlements = new ProjectCapabilityManager(pathToBuiltProject + projectPath, entitlementsFileName, targetName);
entitlements.AddAssociatedDomains(new string[] { "applinks:myurl.com" });
//Apply
entitlements.WriteToFile();
}

不要忘记提供 .pbxproj 文件的路径,而不是 .plist 或项目文件本身的路径。
确保使用 WriteToFile() 应用更改。

关于 ProjectCapabilityManager 的相关 Unity 文档和 AddAssociatedDomains

关于c# - 如何使用 Unity 为 iOS 应用程序自动设置关联域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47233982/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com