블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2328)N
Unity3D (572)N
Programming (472)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (34)
3DS Max (3)
Game (12)
Utility (116)
Etc (92)
Link (31)
Portfolio (19)
Subject (90)
iOS,OSX (38)
Android (13)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (1)
Memories (19)
Interest (37)
Thinking (36)
한글 (26)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (2)
냥이 (9)
육아 (9)
Total1,346,224
Today30
Yesterday132
Statistics Graph

달력

« » 2019.12
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

공지사항

태그목록

I manage to get it working by a C# script, but since this build setting need an .entitlementfile in your xcode project, first you will need to create a text file called [projectName].entitlement anywhere in your project with this content:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5. <key>aps-environment</key>
  6. <string>development</string>
  7. </dict>
  8. </plist>

Now you can add this script on the Editor folder:

  1. using System.IO;
  2. using JetBrains.Annotations;
  3. using UnityEditor;
  4. using UnityEditor.Callbacks;
  5. using UnityEditor.iOS.Xcode;
  6. using UnityEngine;
  7.  
  8. public class PostProcessBuildScript : ScriptableObject
  9. {
  10. public DefaultAsset entitlementsFile;
  11.  
  12. [PostProcessBuild, UsedImplicitly]
  13. public static void ChangesToXcode(BuildTarget buildTarget, string pathToBuiltProject)
  14. {
  15. // Get project PBX file
  16. var projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
  17. var proj = new PBXProject();
  18. proj.ReadFromString(File.ReadAllText(projPath));
  19. var target = proj.TargetGuidByName("Unity-iPhone");
  20.  
  21. // Create an instance of this ScriptableObject so we can point to its entitlements file
  22. var dummy = CreateInstance<PostProcessBuildScript>();
  23. var entitlementsFile = dummy.entitlementsFile;
  24. DestroyImmediate(dummy);
  25. if (entitlementsFile != null)
  26. {
  27. // Copy the entitlement file to the xcode project
  28. var entitlementPath = AssetDatabase.GetAssetPath(entitlementsFile);
  29. var entitlementFileName = Path.GetFileName(entitlementPath);
  30. var unityTarget = PBXProject.GetUnityTargetName();
  31. var relativeDestination = unityTarget + "/" + entitlementFileName;
  32. FileUtil.CopyFileOrDirectory(entitlementPath, pathToBuiltProject + "/" + relativeDestination);
  33.  
  34. // Add the pbx configs to include the entitlements files on the project
  35. proj.AddFile(relativeDestination, entitlementFileName);
  36. proj.AddBuildProperty(target, "CODE_SIGN_ENTITLEMENTS", relativeDestination);
  37.  
  38. // Add push notifications as a capability on the target
  39. proj.AddBuildProperty(target, "SystemCapabilities", "{com.apple.Push = {enabled = 1;};}");
  40. }
  41.  
  42. // Save the changed configs to the file
  43. File.WriteAllText(projPath, proj.WriteToString());
  44. }
  45. }

After that you just define the entitlementsFile variable for the script in the inspector window and you should now have the push notification activated by default when you build for iOS.

 

 

 

[출처] https://answers.unity.com/questions/1224123/enable-push-notification-in-xcode-project-by-defau.html

 

Enable Push Notification in XCode project by default? - Unity Answers

 

answers.unity.com

 

Posted by blueasa

댓글을 달아 주세요