Exemple #1
0
        public void VerifyCarrierCountry()
        {
            const string CountryCode = "US";

            MobileCenter.SetCountryCode(CountryCode);

            var device = Task.Run(() => new DeviceInformationHelper().GetDeviceInformationAsync()).Result;

            Assert.AreEqual(device.CarrierCountry, CountryCode);
        }
 /// <summary>
 ///     Initializes the singleton application object.  This is the first line of authored code
 ///     executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     // Set the country before initialization occurs so Mobile Center can send the field to the backend
     // Note that the country code provided does not reflect the physical device location, but rather the
     // country that corresponds to the culture it uses. You may wish to retrieve the country code using
     // a different means, such as device location.
     MobileCenter.SetCountryCode(RegionInfo.CurrentRegion.TwoLetterISORegionName);
     InitializeComponent();
     Suspending += OnSuspending;
 }
Exemple #3
0
 /// <summary>
 /// 为应用增加额外功能
 /// </summary>
 private void PrepareExtraFunction()
 {
     try
     {
         MobileCenter.Start(GlobalValue.MobileCenterKey, typeof(Analytics));
         MobileCenter.SetCountryCode(GlobalizationPreferences.HomeGeographicRegion);
     }
     catch (Exception e)
     {
         LogHelper.WriteLine(e);
     }
 }
        public void SetCountryCode()
        {
            const string CountryCode              = "US";
            int          informationInvalidated   = 0;
            EventHandler OnInformationInvalidated = delegate { informationInvalidated++; };

            DeviceInformationHelper.InformationInvalidated += OnInformationInvalidated;
            MobileCenter.SetCountryCode(CountryCode);
            MobileCenter.SetCountryCode("INVALID");
            DeviceInformationHelper.InformationInvalidated -= OnInformationInvalidated;
            Assert.AreEqual(informationInvalidated, 1);
        }
Exemple #5
0
        public void SetCountryCode()
        {
            var informationInvalidated = false;

            void InformationInvalidated(object sender, EventArgs e)
            {
                informationInvalidated = true;
            }

            DeviceInformationHelper.InformationInvalidated += InformationInvalidated;
            MobileCenter.SetCountryCode("US");
            DeviceInformationHelper.InformationInvalidated -= InformationInvalidated;
            Assert.AreEqual(informationInvalidated, true);
        }
Exemple #6
0
        /// <summary>
        /// 최종 사용자가 응용 프로그램을 정상적으로 시작할 때 호출됩니다. 다른 진입점은
        /// 특정 파일을 여는 등 응용 프로그램을 시작할 때
        /// </summary>
        /// <param name="e">시작 요청 및 프로세스에 대한 정보입니다.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            #region for Mobile Center
            // Get the user's geographic region and its two-letter identifier for this region.
            var geographicRegion = new Windows.Globalization.GeographicRegion();
            var code             = geographicRegion.CodeTwoLetter;

            //MobileCenter.LogLevel = LogLevel.Verbose;
            MobileCenter.SetCountryCode(code);
            MobileCenter.Start("f7981365-4bfc-4008-a33e-e293fa5e575d", typeof(Analytics), typeof(Crashes));
            #endregion

#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                //this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;

            // 창에 콘텐츠가 이미 있는 경우 앱 초기화를 반복하지 말고,
            // 창이 활성화되어 있는지 확인하십시오.
            if (rootFrame == null)
            {
                //MVVM 초기화
                GalaSoft.MvvmLight.Threading.DispatcherHelper.Initialize();
                FontHelper.FontDAO = SimpleIoc.Default.GetInstance <FontDAO>();

                // 탐색 컨텍스트로 사용할 프레임을 만들고 첫 페이지로 이동합니다.
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: 이전에 일시 중지된 응용 프로그램에서 상태를 로드합니다.
                }

                // 현재 창에 프레임 넣기
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    //이전에 풀스크린으로 끝났었다면 강제로 종료시킴
                    if (IsMobile)
                    {
                        var cv = ApplicationView.GetForCurrentView();
                        if (cv.IsFullScreenMode)
                        {
                            cv.ExitFullScreenMode();
                        }
                    }
                    // 탐색 스택이 복원되지 않으면 첫 번째 페이지로 돌아가고
                    // 필요한 정보를 탐색 매개 변수로 전달하여 새 페이지를
                    // 구성합니다.
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // 현재 창이 활성 창인지 확인
                Window.Current.Activate();
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Push.PushNotificationReceived += (sender, es) => {
                // Add the notification message and title to the message
                var summary = $"Push notification received:" +
                              $"\n\tNotification title: {es.Title}" +
                              $"\n\tMessage: {es.Message}";

                // If there is custom data associated with the notification,
                // print the entries
                if (es.CustomData != null)
                {
                    summary += "\n\tCustom data:\n";
                    foreach (var key in es.CustomData.Keys)
                    {
                        summary += $"\t\t{key} : {es.CustomData[key]}\n";
                    }
                }

                // Send the notification summary to debug output
                System.Diagnostics.Debug.WriteLine(summary);
            };
            MobileCenter.LogLevel = LogLevel.Verbose;
            // TODO: 1.2 - Ensure we use ALL of the window space.  That means we have to make sure we follow the safe area of the screen!
            // ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

            // TODO: 5.1 - If we want a ten foot view, we probably want color safe colors as well.  This dictionary solves that for default styles.
            //if (App.IsTenFoot)
            //{
            //    // use TV colorsafe values
            //    this.Resources.MergedDictionaries.Add(new ResourceDictionary
            //    {
            //        Source = new Uri("ms-appx:///TvSafeColors.xaml")
            //    });
            //}
            //MobileCenter code
            //MobileCenter.SetLogUrl("https://in-staging-south-centralus.staging.avalanch.es");
            MobileCenter.SetCountryCode("China");
            MobileCenter.Start("84599058-77f7-4801-9e62-bdbb7bf7293d", typeof(Analytics), typeof(Crashes), typeof(Push));
            //Analytics.Enabled = true;

            var installid = MobileCenter.GetInstallIdAsync();

            System.Diagnostics.Debug.WriteLine("InstallId=" + installid.Result.ToString());
            Push.CheckLaunchedFromNotification(e);


            ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;

            if (titleBar != null)
            {
                Color titleBarColor = (Color)App.Current.Resources["SystemChromeMediumColor"];
                titleBar.BackgroundColor       = titleBarColor;
                titleBar.ButtonBackgroundColor = titleBarColor;
            }

            MainPage shell = Window.Current.Content as MainPage;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (shell == null)
            {
                // Create a AppShell to act as the navigation context and navigate to the first page
                shell = new MainPage();

                // Set the default language
                shell.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

                shell.AppFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // Should load state from previous run
                }
            }

            // Place our app shell in the current Window
            Window.Current.Content = shell;

            if (shell.AppFrame.Content == null)
            {
                // When the navigation stack isn't restored, navigate to the first page
                // suppressing the initial entrance animation.
                shell.AppFrame.Navigate(typeof(AllPresidentsView), e.Arguments, new Windows.UI.Xaml.Media.Animation.SuppressNavigationTransitionInfo());
            }

            // Ensure the current window is active
            Window.Current.Activate();

            ApplicationView.GetForCurrentView().SetPreferredMinSize(new Size(320, 200));
        }