public static UAConfig LoadConfig()
        {
            try {
                if (File.Exists(filePath))
                {
                    using (Stream fileStream = File.OpenRead(filePath)) {
                        XmlSerializer serializer = new XmlSerializer(typeof(UAConfig));
                        UAConfig      config     = (UAConfig)serializer.Deserialize(fileStream);
                        config.Migrate();
                        config.Validate();
                        cachedInstance = config;
                    }
                }
            } catch (Exception e) {
                UnityEngine.Debug.Log("Failed to load UAConfig: " + e.Message);
                File.Delete(filePath);
            }

            if (cachedInstance == null)
            {
                cachedInstance = new UAConfig();
            }

            return(new UAConfig(cachedInstance));
        }
        public static void SaveConfig(UAConfig config)
        {
            config.Validate();
            using (Stream fileStream = File.Open(filePath, FileMode.Create)) {
                XmlSerializer serializer = new XmlSerializer(typeof(UAConfig));
                serializer.Serialize(fileStream, config);
            }

            cachedInstance = config;
        }
 static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
 {
     if (deletedAssets.Select(s => s.ToLower()).Any(s => s.Contains("airship") || s.Contains("airship_config")))
     {
         if (UAConfig.LoadConfig().Apply())
         {
             UnityEngine.Debug.Log("Created Urban Airship config.");
             AssetDatabase.Refresh();
         }
     }
 }
        public static void OnPostProcessBuild(BuildTarget target, string buildPath)
        {
            if (!UAConfig.LoadConfig().IsValid)
            {
                EditorUtility.DisplayDialog("Urban Airship", "Urban Airship not configured. Set the app credentials in Window -> Urban Airship -> Settings", "OK");
            }

#if UNITY_IOS
            if (target == BuildTarget.iOS)
            {
                UpdatePbxProject(buildPath + "/Unity-iPhone.xcodeproj/project.pbxproj", buildPath);
                UpdateProjectPlist(buildPath + "/Info.plist");
            }
#endif

            UnityEngine.Debug.Log("Finished Urban Airship post build steps.");
        }
        public UAConfig(UAConfig config)
        {
            this.ProductionAppKey = config.ProductionAppKey;
            this.ProductionAppSecret = config.ProductionAppSecret;
            this.ProductionLogLevel = config.ProductionLogLevel;

            this.DevelopmentAppKey = config.DevelopmentAppKey;
            this.DevelopmentAppSecret = config.DevelopmentAppSecret;
            this.DevelopmentLogLevel = config.DevelopmentLogLevel;

            this.InProduction = config.InProduction;

            this.NotificationPresentationOptionAlert = config.NotificationPresentationOptionAlert;
            this.NotificationPresentationOptionBadge = config.NotificationPresentationOptionBadge;
            this.NotificationPresentationOptionSound = config.NotificationPresentationOptionSound;

            this.GCMSenderId = config.GCMSenderId;
            this.AndroidNotificationAccentColor = config.AndroidNotificationAccentColor;
            this.AndroidNotificationIcon = config.AndroidNotificationIcon;
        }
        public UAConfig(UAConfig config)
        {
            this.ProductionAppKey    = config.ProductionAppKey;
            this.ProductionAppSecret = config.ProductionAppSecret;
            this.ProductionLogLevel  = config.ProductionLogLevel;

            this.DevelopmentAppKey    = config.DevelopmentAppKey;
            this.DevelopmentAppSecret = config.DevelopmentAppSecret;
            this.DevelopmentLogLevel  = config.DevelopmentLogLevel;

            this.InProduction = config.InProduction;

            this.NotificationPresentationOptionAlert = config.NotificationPresentationOptionAlert;
            this.NotificationPresentationOptionBadge = config.NotificationPresentationOptionBadge;
            this.NotificationPresentationOptionSound = config.NotificationPresentationOptionSound;

            this.ProductionFCMSenderId          = config.ProductionFCMSenderId;
            this.DevelopmentFCMSenderId         = config.DevelopmentFCMSenderId;
            this.AndroidNotificationAccentColor = config.AndroidNotificationAccentColor;
            this.AndroidNotificationIcon        = config.AndroidNotificationIcon;
        }
Exemple #7
0
        void OnGUI()
        {
            minSize = new Vector2(800, 640);

            CreateSection("Production", () => {
                config.ProductionAppKey      = EditorGUILayout.TextField("App Key", config.ProductionAppKey);
                config.ProductionAppSecret   = EditorGUILayout.TextField("App Secret", config.ProductionAppSecret);
                config.ProductionLogLevel    = (UAConfig.LogLevel)EditorGUILayout.EnumPopup("Log level:", config.ProductionLogLevel);
                config.ProductionFCMSenderId = EditorGUILayout.TextField("Android FCM Sender ID:", config.ProductionFCMSenderId);
            });


            CreateSection("Development", () => {
                config.DevelopmentAppKey      = EditorGUILayout.TextField("App Key", config.DevelopmentAppKey);
                config.DevelopmentAppSecret   = EditorGUILayout.TextField("App Secret", config.DevelopmentAppSecret);
                config.DevelopmentLogLevel    = (UAConfig.LogLevel)EditorGUILayout.EnumPopup("Log level:", config.DevelopmentLogLevel);
                config.DevelopmentFCMSenderId = EditorGUILayout.TextField("Android FCM Sender ID:", config.DevelopmentFCMSenderId);
            });

            CreateSection("In Production", () => {
                config.InProduction = EditorGUILayout.Toggle("inProduction", config.InProduction);
            });

            CreateSection("Android Notifications", () => {
                config.AndroidNotificationAccentColor = EditorGUILayout.TextField("Notification Accent Color", config.AndroidNotificationAccentColor);
                config.AndroidNotificationIcon        = EditorGUILayout.TextField("Notification Icon", config.AndroidNotificationIcon);

                GUILayout.Space(5);

                GUILayout.Label("Notification icon must be the name of a drawable in the project, e.g., " +
                                "app_icon, ic_dialog_alert. Drawables can be added " +
                                "in either the Assets/Plugins/Android/urbanairship-resources/res/drawable* directory or by " +
                                "providing a new Android library project.", EditorStyles.wordWrappedMiniLabel);
            });

            CreateSection("iOS Foreground Presentation Options", () => {
                config.NotificationPresentationOptionAlert = EditorGUILayout.Toggle("Alert", config.NotificationPresentationOptionAlert);
                config.NotificationPresentationOptionBadge = EditorGUILayout.Toggle("Badge", config.NotificationPresentationOptionBadge);
                config.NotificationPresentationOptionSound = EditorGUILayout.Toggle("Sound", config.NotificationPresentationOptionSound);
            });

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Cancel"))
            {
                Close();
            }

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Save"))
            {
                try {
                    config.Validate();

                    UnityEngine.Debug.Log("Saving Urban Airship config.");

                    config.Apply();
                    UAConfig.SaveConfig(config);

                    AssetDatabase.Refresh();
                    Close();
                } catch (Exception e) {
                    EditorUtility.DisplayDialog("Urban Airship", "Unable to save config. Error: " + e.Message, "Ok");
                }
            }

            GUILayout.FlexibleSpace();
        }
Exemple #8
0
 void OnEnable()
 {
     config = UAConfig.LoadConfig();
 }
        public static void SaveConfig(UAConfig config)
        {
            config.Validate ();
            using (Stream fileStream = File.Open (filePath, FileMode.Create)) {
                XmlSerializer serializer = new XmlSerializer (typeof(UAConfig));
                serializer.Serialize (fileStream, config);
            }

            cachedInstance = config;
        }
        public static UAConfig LoadConfig()
        {
            try {
                if (File.Exists (filePath)) {
                    using (Stream fileStream = File.OpenRead (filePath)) {
                        XmlSerializer serializer = new XmlSerializer (typeof(UAConfig));
                        UAConfig config = (UAConfig)serializer.Deserialize (fileStream);
                        config.Validate ();
                        cachedInstance = config;
                    }
                }
            } catch (Exception e) {
                UnityEngine.Debug.Log ("Failed to load UAConfig: " + e.Message);
                File.Delete (filePath);
            }

            if (cachedInstance == null) {
                cachedInstance = new UAConfig ();
            }

            return new UAConfig (cachedInstance);
        }
 void OnEnable()
 {
     config = UAConfig.LoadConfig ();
 }