public static void UpdateManifest()

in Facebook.Unity.Editor/android/ManifestMod.cs [113:214]


        public static void UpdateManifest(string fullPath)
        {
            string appId = FacebookSettings.AppId;

            if (!FacebookSettings.IsValidAppId)
            {
                Debug.LogError("You didn't specify a Facebook app ID.  Please add one using the Facebook menu in the main Unity editor.");
                return;
            }

            XmlDocument doc = new XmlDocument();
            doc.Load(fullPath);

            if (doc == null)
            {
                Debug.LogError("Couldn't load " + fullPath);
                return;
            }

            XmlNode manNode = FindChildNode(doc, "manifest");
            XmlNode dict = FindChildNode(manNode, "application");

            if (dict == null)
            {
                Debug.LogError("Error parsing " + fullPath);
                return;
            }

            string ns = dict.GetNamespaceOfPrefix("android");

            // add the unity login activity
            XmlElement unityLoginElement = CreateUnityOverlayElement(doc, ns, UnityLoginActivityName);
            ManifestMod.SetOrReplaceXmlElement(dict, unityLoginElement);

            // add the unity dialogs activity
            XmlElement unityDialogsElement = CreateUnityOverlayElement(doc, ns, UnityDialogsActivityName);
            ManifestMod.SetOrReplaceXmlElement(dict, unityDialogsElement);

            XmlElement unityGamingFriendFinderElement = CreateUnityOverlayElement(doc, ns, UnityGamingServicesFriendFinderActivityName);
            ManifestMod.SetOrReplaceXmlElement(dict, unityGamingFriendFinderElement);


            ManifestMod.AddAppLinkingActivity(doc, dict, ns, FacebookSettings.AppLinkSchemes[FacebookSettings.SelectedAppIndex].Schemes);

            ManifestMod.AddSimpleActivity(doc, dict, ns, DeepLinkingActivityName, true);
            ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameRequestActivityName);
            ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameGroupCreateActivityName);
            ManifestMod.AddSimpleActivity(doc, dict, ns, UnityGameGroupJoinActivityName);

            // add the app id
            // <meta-data android:name="com.facebook.sdk.ApplicationId" android:value="\ fb<APPID>" />
            XmlElement appIdElement = doc.CreateElement("meta-data");
            appIdElement.SetAttribute("name", ns, ApplicationIdMetaDataName);
            appIdElement.SetAttribute("value", ns, "fb" + appId);
            ManifestMod.SetOrReplaceXmlElement(dict, appIdElement);

            // enable AutoLogAppEventsEnabled by default
            // <meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="true"/>
            string autoLogAppEventsEnabled = FacebookSettings.AutoLogAppEventsEnabled.ToString().ToLower();
            XmlElement autoLogAppEventsEnabledElement = doc.CreateElement("meta-data");
            autoLogAppEventsEnabledElement.SetAttribute("name", ns, AutoLogAppEventsEnabled);
            autoLogAppEventsEnabledElement.SetAttribute("value", ns, autoLogAppEventsEnabled);
            ManifestMod.SetOrReplaceXmlElement(dict, autoLogAppEventsEnabledElement);

            // enable AdvertiserIDCollectionEnabled by default
            // <meta-data android:name="com.facebook.sdk.AdvertiserIDCollectionEnabled" android:value="true"/>
            string advertiserIDCollectionEnabled = FacebookSettings.AdvertiserIDCollectionEnabled.ToString().ToLower();
            XmlElement advertiserIDCollectionEnabledElement = doc.CreateElement("meta-data");
            advertiserIDCollectionEnabledElement.SetAttribute("name", ns, AdvertiserIDCollectionEnabled);
            advertiserIDCollectionEnabledElement.SetAttribute("value", ns, advertiserIDCollectionEnabled);
            ManifestMod.SetOrReplaceXmlElement(dict, advertiserIDCollectionEnabledElement);

            // Add the facebook content provider
            // <provider
            //   android:name="com.facebook.FacebookContentProvider"
            //   android:authorities="com.facebook.app.FacebookContentProvider<APPID>"
            //   android:exported="true" />
            XmlElement contentProviderElement = CreateContentProviderElement(doc, ns, appId);
            ManifestMod.SetOrReplaceXmlElement(dict, contentProviderElement);

            // Remove the FacebookActivity since we can rely on it in the androidsdk aar as of v4.12
            // (otherwise unity manifest merge likes fail if there's any difference at all)
            XmlElement facebookElement;
            if (TryFindElementWithAndroidName(dict, FacebookActivityName, out facebookElement))
            {
                dict.RemoveChild(facebookElement);
            }

            // Save the document formatted
            XmlWriterSettings settings = new XmlWriterSettings
            {
                Indent = true,
                IndentChars = "  ",
                NewLineChars = "\r\n",
                NewLineHandling = NewLineHandling.Replace
            };

            using (XmlWriter xmlWriter = XmlWriter.Create(fullPath, settings))
            {
                doc.Save(xmlWriter);
            }
        }