My Unity 2019.3 project is using the [Unity Mobile Notifications][1] library, version 1.0.3
using Unity.Notifications.iOS;
According to the [Player Settings iOS documentation][2], the "Automatically add capabilities" option (when checked) should add the "Push Notifications" capability to my XCode project. I do not see this behavior occurring.
I tried including the legacy system in my code to nudge the "Automatically add capabilities" feature. No effect.
Debug.Log(UnityEngine.iOS.NotificationServices.deviceToken);
I tried adding the capability with a post-build script. No effect.
public void OnPostprocessBuild(BuildReport report)
{
if (report.summary.platform != BuildTarget.iOS) return;
var file_name = "gamename.entitlements";
var buildPath = report.summary.outputPath;
var proj_path = PBXProject.GetPBXProjectPath(buildPath);
Debug.Log("proj_path: " + proj_path);
var proj = new PBXProject();
proj.ReadFromFile(proj_path);
var target_name = "Unity-iPhone";
var target_guid = proj.GetUnityMainTargetGuid();
string entitlementsFilePath = target_name + "/" + file_name;
var capManager = new ProjectCapabilityManager(proj_path, entitlementsFilePath, target_name, target_guid);
capManager.AddPushNotifications(development: false);
capManager.WriteToFile();
}
I have noticed that there are two entitlement files: "Entitlements.entitlements", and "gamename.entitlements".
"Entitlements.entitlements" has a single entry for SignInWithApple that IS added to the XCode project Capabilities.
"gamename.entitlements" has a single entry for APS Environment that IS NOT added to the XCode project Capabilities.
I suspect these files have something to do with this madness. Please help.
[1]: https://docs.unity3d.com/Packages/com.unity.mobile.notifications@1.0/manual/index.html
[2]: https://docs.unity3d.com/Manual/PlayerSettingsiOS-Other.html
↧