Esempio n. 1
0
        protected override void OnNewIntent(Android.Content.Intent intent)
        {
            NotificationCenter.NotifyNotificationTapped(intent);
            Push.CheckLaunchedFromNotification(this, intent);

            base.OnNewIntent(intent);
        }
Esempio n. 2
0
        protected override async Task OnLaunchApplicationAsync(LaunchActivatedEventArgs args)
        {
            await Container.Resolve <DocumentManager>().LoadDataAsync();

            Push.CheckLaunchedFromNotification(args);
            NavigationService.Navigate("Main", null);
        }
Esempio n. 3
0
        private async Task OnLaunchedAsync(LaunchActivatedEventArgs e)
        {
            var path = string.Empty;

            // Handle all the activation protocols that could occur
            if (!string.IsNullOrEmpty(e.TileId))
            {
                path = e.Arguments;
            }

            // If this is just a pre launch, don't
            // actually set the content to the frame.
            if (e.PrelaunchActivated)
            {
                return;
            }

            // Handle notifications
            Push.CheckLaunchedFromNotification(e);

            // Track app use
            SystemInformation.TrackAppUse(e);

            // Create / Get the main shell
            await InitializeShellAsync(path);
        }
Esempio n. 4
0
        protected override void OnNewIntent(Intent intent)
        {
            Plugin.LocalNotification.Platform.Droid.LocalNotificationService.NotifyNotificationTapped(intent);

            base.OnNewIntent(intent);

            Push.CheckLaunchedFromNotification(this, intent);
        }
        private void EvaluateActivationArgs()
        {
            // Initially started?
            if (!Data_Manager2.Classes.Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
            {
                PerformInitialStartSetup();

                ROOT_FRAME.Navigate(typeof(AddAccountPage), typeof(ChatPage));
            }
            else if (ACTIVATION_ARGS is ProtocolActivatedEventArgs protocolActivationArgs)
            {
                Logger.Info("App activated by protocol activation with: " + protocolActivationArgs.Uri.ToString());

                // If we're currently not on a page, navigate to the main page:
                ROOT_FRAME.Navigate(typeof(ChatPage), UriUtils.parse(protocolActivationArgs.Uri));
            }
            else if (ACTIVATION_ARGS is ToastNotificationActivatedEventArgs toastActivationArgs)
            {
                Logger.Info("App activated by toast with: " + toastActivationArgs.Argument);
                // If empty args, no specific action (just launch the app):
                if (string.IsNullOrEmpty(toastActivationArgs.Argument))
                {
                    Logger.Warn("Toast activation with no argument!");
                    if (ROOT_FRAME.Content is null)
                    {
                        ROOT_FRAME.Navigate(typeof(ChatPage));
                    }
                    else
                    {
                        ROOT_FRAME.Navigate(typeof(ChatPage));
                    }
                }
                else
                {
                    ROOT_FRAME.Navigate(typeof(ChatPage), ToastActivationArgumentParser.parseArguments(toastActivationArgs.Argument));
                }
                if (ROOT_FRAME.BackStack.Count == 0)
                {
                    ROOT_FRAME.BackStack.Add(new PageStackEntry(typeof(ChatPage), null, null));
                }
            }
            else if (ACTIVATION_ARGS is LaunchActivatedEventArgs launchActivationArgs)
            {
                Push.CheckLaunchedFromNotification(launchActivationArgs);

                // If launched with arguments (not a normal primary tile/applist launch)
                if (launchActivationArgs.Arguments.Length > 0)
                {
                    Logger.Debug(launchActivationArgs.Arguments);
                    // TODO: Handle arguments for cases = launching from secondary Tile, so we navigate to the correct page
                    //throw new NotImplementedException();
                }

                // If we're currently not on a page, navigate to the main page
                ROOT_FRAME.Navigate(typeof(ChatPage));
            }
        }
Esempio n. 6
0
        /// <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)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            MobileCenter.LogLevel = LogLevel.Verbose;
            MobileCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
            Push.PushNotificationReceived += PushNotificationReceivedHandler;
            MobileCenter.Start("42f4a839-c54c-44da-8072-a2f2a61751b2", typeof(Analytics), typeof(Crashes), typeof(Push));
            Push.CheckLaunchedFromNotification(e);

            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Esempio n. 7
0
        /// <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 async void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            Frame rootFrame = Window.Current.Content as Frame;
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
            MobileCenter.Start("bc8e0447-700a-4e68-a274-4cab46a9eac2", typeof(Analytics), typeof(Push));
            Push.CheckLaunchedFromNotification(e);
            eclassUID = await GetUserIdAsync();

            if (eclassUID == null)
            {
                eclassUID = null;
            }
        }
        /// <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)
        {
#if DEBUG
            if (Debugger.IsAttached)
            {
                DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            var rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                Xamarin.Forms.Forms.Init(e);

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            Push.CheckLaunchedFromNotification(e);
        }
Esempio n. 9
0
        /// <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)
        {
            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                // you'll need to add `using System.Reflection;`
                List <Assembly> assembliesToInclude = new List <Assembly>();

                //Now, add all the assemblies your app uses
                assembliesToInclude.Add(typeof(SfRatingRenderer).GetTypeInfo().Assembly);

                // replaces Xamarin.Forms.Forms.Init(e);
                Xamarin.Forms.Forms.Init(e, assembliesToInclude);


                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();

            // Best place to call this method
            Push.CheckLaunchedFromNotification(e);
        }
Esempio n. 10
0
        /// <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)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                DebugSettings.EnableFrameRateCounter = true;
            }
#endif
            BackgroundExecutionManager.RemoveAccess();
            BackgroundExecutionManager.RequestAccessAsync().AsTask().Wait();
            BGTask.RegisterBackgroundTask("", "task", new SystemTrigger(SystemTriggerType.InternetAvailable, false), new SystemCondition(SystemConditionType.InternetAvailable));

            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
            }
            // Ensure the current window is active
            Window.Current.Activate();
            Push.CheckLaunchedFromNotification(e);
        }
Esempio n. 11
0
 protected override void OnNewIntent(Intent intent)
 {
     base.OnNewIntent(intent);
     Push.CheckLaunchedFromNotification(this, intent);
 }
Esempio n. 12
0
        /// <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.SetEnabledAsync(true);
            Frame rootFrame = Window.Current.Content as Frame;

            // This should come before AppCenter.Start() is called
            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);
            };
            AppCenter.SetLogUrl("https://in-staging-south-centralus.staging.avalanch.es");
            AppCenter.SetCountryCode("cn");
            AppCenter.Start("998a35d1-d603-433d-aa99-41f82674c64f", typeof(Distribute), typeof(Analytics), typeof(Crashes), typeof(Push));
            Push.CheckLaunchedFromNotification(e);

            var installId = AppCenter.GetInstallIdAsync();

            System.Diagnostics.Debug.WriteLine("InstallId=" + installId.Result); //+

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Esempio n. 13
0
        private async Task onActivatedOrLaunchedAsync(IActivatedEventArgs args)
        {
            // Sets the log level:
            initLogLevel();

            // Register background tasks:
            Logger.Info("Registering background tasks...");
            await BackgroundTaskHelper.registerToastBackgroundTaskAsync();

            Logger.Info("Finished registering background tasks.");

            // Init all db managers to force event subscriptions:
            initAllDBManagers();

            // Set default background:
            if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
            {
                Settings.setSetting(SettingsConsts.CHAT_EXAMPLE_BACKGROUND_IMAGE_NAME, "light_bulb.jpeg");
            }
            // Loads all background images into the cache:
            BackgroundImageCache.loadCache();

            // Setup push server connection:
            if (!Settings.getSettingBoolean(SettingsConsts.DISABLE_PUSH))
            {
                Push_App_Server.Classes.PushManager.init();
            }

            isRunning = true;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page:
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (args.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (args is ToastNotificationActivatedEventArgs)
            {
                var toastActivationArgs = args as ToastNotificationActivatedEventArgs;
                Logger.Info("App activated by toast with: " + toastActivationArgs.Argument);
                // If empty args, no specific action (just launch the app)
                if (string.IsNullOrEmpty(toastActivationArgs.Argument))
                {
                    if (rootFrame.Content == null)
                    {
                        if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
                        {
                            rootFrame.Navigate(typeof(AddAccountPage), "App.xaml.cs");
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(ChatPage), "App.xaml.cs");
                        }
                    }
                }
                else
                {
                    rootFrame.Navigate(typeof(ChatPage), ToastActivationArgumentParser.parseArguments(toastActivationArgs.Argument));
                }
                if (rootFrame.BackStack.Count == 0)
                {
                    rootFrame.BackStack.Add(new PageStackEntry(typeof(ChatPage), null, null));
                }
            }
            else if (args is LaunchActivatedEventArgs)
            {
                var launchActivationArgs = args as LaunchActivatedEventArgs;

                Push.CheckLaunchedFromNotification(launchActivationArgs);

                // If launched with arguments (not a normal primary tile/applist launch)
                if (launchActivationArgs.Arguments.Length > 0)
                {
                    Logger.Debug(launchActivationArgs.Arguments);
                    // TODO: Handle arguments for cases = launching from secondary Tile, so we navigate to the correct page
                    //throw new NotImplementedException();
                }

                // If we're currently not on a page, navigate to the main page
                if (rootFrame.Content == null)
                {
                    if (!Settings.getSettingBoolean(SettingsConsts.INITIALLY_STARTED))
                    {
                        rootFrame.Navigate(typeof(AddAccountPage), "App.xaml.cs");
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(ChatPage), "App.xaml.cs");
                    }
                }
            }

            // Set requested theme:
            string       themeString = Settings.getSettingString(SettingsConsts.APP_REQUESTED_THEME);
            ElementTheme theme       = ElementTheme.Dark;

            if (themeString != null)
            {
                bool b = Enum.TryParse(themeString, out theme);
            }
            RootTheme = theme;

            Window.Current.Activate();

            // Connect to all clients:
            ConnectionHandler.INSTANCE.connectAll();
        }
Esempio n. 14
0
        /// <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)
        {
            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;

                // beim Store Build werden die Assemblies aus Nuget Packages nicht richtig mitgeladen, hiermit behoben
                var rendererAssemblies = new[]
                {
                    // Die nicht im Projekt benötigten Renderer können entfernt werden
                    typeof(CartesianChartRenderer).GetTypeInfo().Assembly,
                    typeof(LegendRenderer).GetTypeInfo().Assembly,
                    typeof(PieChartRenderer).GetTypeInfo().Assembly,
                    typeof(PieLabelRenderer).GetTypeInfo().Assembly,
                    typeof(CardActionViewRenderer).GetTypeInfo().Assembly,
                    typeof(ChatListViewRenderer).GetTypeInfo().Assembly,
                    typeof(ListViewRenderer).GetTypeInfo().Assembly,
                    typeof(TreeViewRenderer).GetTypeInfo().Assembly,
                    typeof(ItemsControlRenderer).GetTypeInfo().Assembly,
                    typeof(AutoCompleteLabelRenderer).GetTypeInfo().Assembly,
                    typeof(AutoCompleteRenderer).GetTypeInfo().Assembly,
                    typeof(ButtonRenderer).GetTypeInfo().Assembly,
                    typeof(CalendarRenderer).GetTypeInfo().Assembly,
                    typeof(DataFormRenderer).GetTypeInfo().Assembly,
                    typeof(EntryRenderer).GetTypeInfo().Assembly,
                    typeof(MaskedInputRenderer).GetTypeInfo().Assembly,
                    typeof(SegmentedControlRenderer).GetTypeInfo().Assembly,
                    typeof(TimePickerItemViewRenderer).GetTypeInfo().Assembly,
                    typeof(BorderRenderer).GetTypeInfo().Assembly,
                    typeof(CheckBoxRenderer).GetTypeInfo().Assembly,
                    typeof(ScrollViewRenderer).GetTypeInfo().Assembly,
                    typeof(SideDrawerRenderer).GetTypeInfo().Assembly,
                    typeof(SlideViewLabelRenderer).GetTypeInfo().Assembly,
                    typeof(SlideViewRenderer).GetTypeInfo().Assembly,
                    typeof(TabViewHeaderItemRenderer).GetTypeInfo().Assembly,
                    typeof(ZXingBarcodeImageViewRenderer).GetTypeInfo().Assembly,
                    typeof(ZXingScannerViewRenderer).GetTypeInfo().Assembly,
                    typeof(WriteableBitmapRenderer).GetTypeInfo().Assembly,
                    typeof(PixelDataRenderer).GetTypeInfo().Assembly,
                    typeof(SvgRenderer).GetTypeInfo().Assembly,
                    typeof(SKCanvasViewRenderer).GetTypeInfo().Assembly,
                    typeof(SKGLViewRenderer).GetTypeInfo().Assembly
                };

                Forms.Init(e, rendererAssemblies);
                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }

            // Azure Mobile Center Push Notifizierungen
            Push.CheckLaunchedFromNotification(e);

            if (e.Arguments != null)
            {
                var customData = ParseLaunchString(e.Arguments);

                if (customData != null)
                {
                    foreach (var data in customData)
                    {
                        Logging.Log.LogInfo("NotificationData: " + data.Key + ": " + data.Value);
                    }

                    ProjectViewModelBase.PushReceived(customData);
                }
            }
        }
Esempio n. 15
0
        /// <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)
        {
            Frame rootFrame = Window.Current.Content as Frame;

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

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (e.PrelaunchActivated == false)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainPage), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();

                // This should come before MobileCenter.Start() is called
                Push.PushNotificationReceived += (sender, e2) =>
                {
                    var content = new ToastContent()
                    {
                        Visual = new ToastVisual()
                        {
                            BindingGeneric = new ToastBindingGeneric
                            {
                                Children =
                                {
                                    new AdaptiveText()
                                    {
                                        Text         = e2.Title,
                                        HintMaxLines = 1
                                    },

                                    new AdaptiveText()
                                    {
                                        Text = e2.Message
                                    },
                                }
                            }
                        }
                    };

                    var toast = new ToastNotification(content.GetXml());
                    ToastNotificationManager.CreateToastNotifier().Show(toast);
                };

                MobileCenter.Start("f93448a8-9f34-46ea-86f9-f90e436f9504", typeof(Push));
                Push.CheckLaunchedFromNotification(e);
            }
        }
Esempio n. 16
0
        /// <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)
        {
            // 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
            Push.SetEnabledAsync(true);
            // This should come before MobileCenter.Start() is called
            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);
            };
            AppCenter.LogLevel = LogLevel.Verbose;
            //MobileCenter.SetLogUrl("https://in-staging-south-centralus.staging.avalanch.es");
            AppCenter.SetCountryCode("zh");
            AppCenter.Start("d5685f8f-19aa-41d2-a71d-4e2c7cbe3852", typeof(Analytics), typeof(Crashes), typeof(Push));
            var installId = AppCenter.GetInstallIdAsync();

            Push.CheckLaunchedFromNotification(e);

            CustomProperties properties = new CustomProperties();

            properties.Set("color", "blue").Set("score", 10).Set("now", DateTime.UtcNow);
            AppCenter.SetCustomProperties(properties);

            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));
        }
Esempio n. 17
0
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
            Log.Trace("OnLaunched");
            DispatcherHelper.Initialize();
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                Log.Trace("rootFrame != null");
                rootFrame = new Frame();
                rootFrame.NavigationFailed += OnNavigationFailed;
                if (e != null)
                {
                    if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                    {
                        //TODO: Загрузить состояние из ранее приостановленного приложения
                    }
                }
                AppCenter.Start("96c77488-34ce-43d0-b0d3-c4b1ce326c7f", typeof(Analytics), typeof(Push), typeof(Crashes));
                AppCenter.LogLevel = LogLevel.Verbose;
                CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                //try
                //{
                //    StaticContent.IsPro = await StoreService.IsBuyPro();
                //    //StaticContent.IsPro = true;
                //}catch(Exception eee)
                //{
                //    //await ContentDialogService.Show(new ExceptionDialog("Ошибка при получении лицензии", "АУЕ БЛЯ", eee));
                //    StaticContent.IsPro = false;
                //}

                var appView = ApplicationView.GetForCurrentView();
                appView.TitleBar.ButtonBackgroundColor         = Colors.Transparent;
                appView.TitleBar.ButtonInactiveBackgroundColor = Colors.Transparent;

                StaticContent.LocalFolder = ApplicationData.Current.LocalFolder;
                if (await StaticContent.LocalFolder.TryGetItemAsync("Playlists") != null)
                {
                    Log.Trace("Set playlistFolder");
                    StaticContent.PlaylistsFolder = await StaticContent.LocalFolder.GetFolderAsync("Playlists");
                }

                if (await StaticContent.LocalFolder.TryGetItemAsync("Covers") != null)
                {
                    Log.Trace("Set CoversFolder");

                    StaticContent.CoversFolder = await StaticContent.LocalFolder.GetFolderAsync("Covers");
                }

                if (await StaticContent.LocalFolder.TryGetItemAsync("ConfigApp.json") != null)
                {
                    var file = await StaticContent.LocalFolder.GetFileAsync("ConfigApp.json");

                    var fileString = await FileIO.ReadTextAsync(file);

                    var config = JsonConvert.DeserializeObject <ConfigApp>(fileString);
                    StaticContent.Config = config;
                }

                var settings = ApplicationData.Current.LocalSettings;



                try
                {
                    Windows.Storage.ApplicationDataCompositeValue composite =
                        (Windows.Storage.ApplicationDataCompositeValue)settings.Values["themeApp"];

                    if (composite == null)
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.Black;
                    }
                    else
                    {
                        var theme = (int)settings.Values["themeApp"];
                        if (theme == 0)
                        {
                            appView.TitleBar.ButtonForegroundColor = Colors.Black;
                        }
                        else
                        {
                            appView.TitleBar.ButtonForegroundColor = Colors.White;
                        }
                    }
                }catch
                {
                    var theme = (int)settings.Values["themeApp"];
                    if (theme == 0)
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.Black;
                    }
                    else
                    {
                        appView.TitleBar.ButtonForegroundColor = Colors.White;
                    }
                }


                try
                {
                    if (InternetService.Connected)
                    {
                        StaticContent.IsAuth = await AuthService.IsAuth();

                        if (StaticContent.IsAuth)
                        {
                            await AuthService.AutoAuth();
                        }
                    }
                    else
                    {
                        StaticContent.IsAuth = false;
                    }
                }catch (Exception ee)
                {
                    StaticContent.IsAuth = false;
                }


                Log.Trace("Размещение фрейма в текущем окне.");
                Window.Current.Content = rootFrame;
            }

            if (e != null)
            {
                if (e.PrelaunchActivated == false)
                {
                    if (rootFrame.Content == null)
                    {
                        if (await StaticContent.LocalFolder.TryGetItemAsync("RunApp.json") == null)
                        {
                            var runFile = await StaticContent.LocalFolder.CreateFileAsync("RunApp.json");

                            var model = new RunApp()
                            {
                                CodeName   = "Test",
                                FirstStart = true,
                                RunUpdate  = true
                            };

                            var json = JsonConvert.SerializeObject(model);
                            await FileIO.WriteTextAsync(runFile, json);

                            rootFrame.Navigate(typeof(Views.WelcomeView), null);
                        }
                        else
                        {
                            rootFrame.Navigate(typeof(Views.MainFrameView), null);
                        }
                    }
                }
            }
            else
            {
                if (rootFrame.Content == null)
                {
                    if (await StaticContent.LocalFolder.TryGetItemAsync("RunApp.json") == null)
                    {
                        var runFile = await StaticContent.LocalFolder.CreateFileAsync("RunApp.json");

                        var model = new RunApp()
                        {
                            CodeName   = "Test",
                            FirstStart = true,
                            RunUpdate  = true
                        };

                        var json = JsonConvert.SerializeObject(model);
                        await FileIO.WriteTextAsync(runFile, json);

                        rootFrame.Navigate(typeof(Views.WelcomeView), null);
                    }
                    else
                    {
                        rootFrame.Navigate(typeof(Views.MainFrameView), null);
                    }
                }
            }


            Window.Current.Activate();
            SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;
            Push.CheckLaunchedFromNotification(e);
        }