public static void ResolveAdapters()
    {
        // Check status of each network and resolve if enabled
        foreach (TDNetwork network in TDSettings.getInstance().networks)
        {
            Debug.Log("Adapter: " + network.name + "- Android: " + network.mavenAdapterDependency + " Enabled: " + network.androidEnabled + " - iOS: " + network.iOSEnabled);

            if (network.iOSEnabled)
            {
                FetchiOSPod("Tapdaq/" + network.cocoapodsAdapterDependency, TAPDAQ_IOS_VERSION, network.sdkTargetVersion.iOS);
            }

            if (network.androidEnabled)
            {
                List <String> repositories = new List <string>();
                repositories.Add(TAPDAQ_REPOSITORY);

                if (network.mavenNetworkRepository != null)
                {
                    repositories.Add(network.mavenNetworkRepository);
                }
                FetchAndroid(network.mavenAdapterDependency + TAPDAQ_ANDROID_VERSION, repositories);
            }
        }
    }
Ejemplo n.º 2
0
 public static void Log(object obj)
 {
     if (TDSettings.getInstance().isDebugMode)
     {
         Debug.Log(obj);
     }
 }
Ejemplo n.º 3
0
 public static void LogException(System.Exception obj)
 {
     if (TDSettings.getInstance().isDebugMode)
     {
         Debug.LogException(obj);
     }
 }
        public static void FixAndroidManifest()
        {
            if (!File.Exists(androidManifestDestinationPath))
            {
                if (File.Exists(androidManifestCopyPath) && Directory.Exists(TDPaths.TapdaqAndroidPath))
                {
                    FileUtil.CopyFileOrDirectory(androidManifestCopyPath, androidManifestDestinationPath);
                    AssetDatabase.Refresh();
                }
            }

            AddAdMobId(TDSettings.getInstance().admob_appid_android);
        }
    private static void SetPListProperties(string pathToBuiltProject)
    {
        var plistPath = pathToBuiltProject + "/Info.plist";
        var plist     = new PlistDocument();

        plist.ReadFromString(File.ReadAllText(plistPath));
        var rootDict = plist.root;

        foreach (TDNetwork network in TDNetwork.AllNetworks)
        {
            if (network.name == "AdColony" && network.iOSEnabled)
            {
                rootDict.SetString("NSMotionUsageDescription", "Some ad content may require access to accelerometer for interactive ad experience.");
                rootDict.SetString("NSPhotoLibraryUsageDescription", "Some ad content may require access to the photo library.");
                rootDict.SetString("NSCalendarsUsageDescription", "Some ad content may create a calendar event.");
                rootDict.SetString("NSCameraUsageDescription", "Some ad content may access camera to take picture.");
            }
        }

        var transportSecurityKey = "NSAppTransportSecurity";

        if (rootDict [transportSecurityKey] == null)
        {
            rootDict.CreateDict(transportSecurityKey);
        }

        var appTransportSecurity = rootDict [transportSecurityKey].AsDict();

        appTransportSecurity.SetBoolean("NSAllowsArbitraryLoads", true);

        if (TDSettings.getInstance().admob_appid_ios.Length > 0)
        {
            rootDict.SetString("GADApplicationIdentifier", TDSettings.getInstance().admob_appid_ios);
        }

        //SKAdNetworkIds
        List <TDKeyValuePair> skAdNetworkIds = TDSettings.getInstance().skAdNetworkIds;

        if (skAdNetworkIds.Count > 0)
        {
            PlistElementArray skAdNetworkItemsArray = rootDict.CreateArray("SKAdNetworkItems");
            foreach (TDKeyValuePair pair in skAdNetworkIds)
            {
                PlistElementDict itemDict = skAdNetworkItemsArray.AddDict();
                itemDict.SetString("SKAdNetworkIdentifier", pair.getValue());
            }
        }

        // Write to file
        File.WriteAllText(plistPath, plist.WriteToString());
    }
Ejemplo n.º 6
0
        public override void OnInspectorGUI()
        {
            foldoutStyle           = EditorStyles.foldout;
            foldoutStyle.fontStyle = FontStyle.Bold;

            serializedObject.Update();

            GUILayout.Label("You must have an App ID and Client Key to use Tapdaq", EditorStyles.boldLabel);

            if (GUILayout.Button("Visit Tapdaq.com"))
            {
                Application.OpenURL("https://tapdaq.com/dashboard/apps");
            }

            GUILayout.Label("Current version:", EditorStyles.boldLabel);
            GUILayout.Label("Unity plugin: \t" + TDSettings.pluginVersion);

            GUILayout.Space(15);

            DrawSeparator(2);

            GUILayout.Space(15);

            GUILayout.Label("App Settings", EditorStyles.boldLabel);

            settings.ios_applicationID = EditorGUILayout.TextField("iOS Application ID", settings.ios_applicationID);
            settings.ios_clientKey     = EditorGUILayout.TextField("iOS Client Key", settings.ios_clientKey);
            settings.admob_appid_ios   = EditorGUILayout.TextField("iOS AdMob AppId", settings.admob_appid_ios);

            GUILayout.Space(20);

            settings.android_applicationID = EditorGUILayout.TextField("Android Application ID", settings.android_applicationID);
            settings.android_clientKey     = EditorGUILayout.TextField("Android Client Key", settings.android_clientKey);
            settings.admob_appid_android   = EditorGUILayout.TextField("Android AdMob AppId", settings.admob_appid_android);

            GUILayout.Space(15);

            settings.autoReloadAds = EditorGUILayout.Toggle("Auto-reload Ads", settings.autoReloadAds);

            GUILayout.Space(15);

            settings.isDebugMode = EditorGUILayout.Toggle("Debug Mode?", settings.isDebugMode);

            GUILayout.Space(15);

            // SKAdNetworkIds

            //GUILayout.Label("SKAdNetworkIds", EditorStyles.boldLabel, GUILayout.MaxWidth(100));
            showSKAdNetworkIds = EditorGUILayout.Foldout(showSKAdNetworkIds, "SKAdNetworkIds", foldoutStyle);
            if (showSKAdNetworkIds)
            {
                GUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Name", GUILayout.MaxWidth(120));
                EditorGUILayout.LabelField("ID", GUILayout.MaxWidth(120));
                GUILayout.EndHorizontal();

                List <TDKeyValuePair> skAdNetworkIdsList = new List <TDKeyValuePair>(TDSettings.getInstance().skAdNetworkIds);

                foreach (TDKeyValuePair pair in skAdNetworkIdsList)
                {
                    GUILayout.BeginHorizontal();
                    EditorGUILayout.TextField(pair.getKey(), GUILayout.MaxWidth(120));
                    EditorGUILayout.TextField(pair.getValue(), GUILayout.MaxWidth(120));
                    if (GUILayout.Button("Remove", GUILayout.Width(75)))
                    {
                        //Invoke remove
                        skAdNetworkIdsList.Remove(pair);
                        TDSettings.getInstance().skAdNetworkIds = skAdNetworkIdsList;
                        skAdNetworkIdKey = skAdNetworkIdValue = null;
                        return;
                    }
                    GUILayout.EndHorizontal();
                }

                GUILayout.BeginHorizontal();

                string placeholderKey = "SKAdNetworkId";
                int    keyCount       = skAdNetworkIdsList.Count;

                while (skAdNetworkIdsList.Find(f => f.getKey() == placeholderKey + keyCount) != null)
                {
                    keyCount++;
                }

                if (String.IsNullOrEmpty(skAdNetworkIdKey) || skAdNetworkIdsList.Find(f => f.getKey() == skAdNetworkIdKey) != null)
                {
                    skAdNetworkIdKey = placeholderKey + keyCount;
                }

                skAdNetworkIdKey   = EditorGUILayout.TextField(skAdNetworkIdKey, GUILayout.MaxWidth(120));
                skAdNetworkIdValue = EditorGUILayout.TextField(skAdNetworkIdValue, GUILayout.MaxWidth(120));
                if (GUILayout.Button("Add", GUILayout.Width(75)))
                {
                    if (String.IsNullOrEmpty(skAdNetworkIdValue))
                    {
                        EditorUtility.DisplayDialog("Error", "SKAdNetworkId value is null or empty", "OK");
                    }
                    else if (skAdNetworkIdsList.Find(f => f.getKey() == skAdNetworkIdKey) != null)
                    {
                        EditorUtility.DisplayDialog("Error", "SKAdNetworkId key already exists", "OK");
                    }
                    else
                    {
                        //Invoke Add
                        TDKeyValuePair pair = new TDKeyValuePair(skAdNetworkIdKey, skAdNetworkIdValue);
                        skAdNetworkIdsList.Add(pair);
                        TDSettings.getInstance().skAdNetworkIds = skAdNetworkIdsList;
                        skAdNetworkIdValue = "";
                    }
                }
                TDSettings.getInstance().skAdNetworkIds = skAdNetworkIdsList;
                GUILayout.EndHorizontal();
            }

            GUILayout.Space(15);

            ShowTestDevices();

            GUILayout.Space(15);

            // Adapters
            DrawSeparator(2);

            GUILayout.Space(10);

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Network", EditorStyles.boldLabel, GUILayout.MaxWidth(100));
            GUILayout.Label("iOS", EditorStyles.boldLabel, GUILayout.MaxWidth(100));
            GUILayout.Label("Android", EditorStyles.boldLabel, GUILayout.MaxWidth(100));
            GUILayout.EndHorizontal();

            EditorGUI.BeginChangeCheck();
            foreach (TDNetwork network in TDSettings.getInstance().networks)
            {
                GUILayout.Space(10);

                GUILayout.BeginHorizontal();
                GUILayout.Label(network.name, GUILayout.MaxWidth(100));
                if (network.cocoapodsAdapterDependency != null)
                {
                    network.iOSEnabled = EditorGUILayout.Toggle("", network.iOSEnabled, GUILayout.MaxWidth(100));
                }
                if (network.mavenAdapterDependency != null)
                {
                    network.androidEnabled = EditorGUILayout.Toggle(network.androidEnabled, GUILayout.MaxWidth(100));
                }
                GUILayout.EndHorizontal();
            }
            EditorGUI.EndChangeCheck();

            GUILayout.EndVertical();

            GUILayout.Space(25);

            ShowButton("Save Adapters", 130, Color.white, () => {
                SaveAdapters();

                // Save settings
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(settings);
                }
            });
        }