Exemplo n.º 1
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var acEnabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = acEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = acEnabled;
            AuthEnabledSwitchCell.On        = await Auth.IsEnabledAsync();

            AuthEnabledSwitchCell.IsEnabled = acEnabled;
            RumEnabledSwitchCell.On         = _rumStarted && await RealUserMeasurements.IsEnabledAsync();

            RumEnabledSwitchCell.IsEnabled  = acEnabled;
            EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync();

            EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null;
            if (!Application.Current.Properties.ContainsKey(AccountId))
            {
                SignInInformationButton.Text = "Authentication status unknown";
            }
            else if (Application.Current.Properties[AccountId] is string)
            {
                SignInInformationButton.Text = "User is authenticated";
            }
            else
            {
                SignInInformationButton.Text = "User is not authenticated";
            }
        }
Exemplo n.º 2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var acEnabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = acEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = acEnabled;
            AuthEnabledSwitchCell.On        = await Auth.IsEnabledAsync();

            AuthEnabledSwitchCell.IsEnabled = acEnabled;
            if (!Application.Current.Properties.ContainsKey(AccountId))
            {
                SignInInformationButton.Text = "Authentication status unknown";
            }
            else if (Application.Current.Properties[AccountId] is string)
            {
                SignInInformationButton.Text = "User is authenticated";
            }
            else
            {
                SignInInformationButton.Text = "User is not authenticated";
            }
        }
Exemplo n.º 3
0
 protected async override void OnStart()
 {
     //Ris 5
     //Byron 6
     AppCenter.Start("423df0fd-8da1-4146-840b-d23c6634f75a", typeof(Push));
     bool datos = await Push.IsEnabledAsync();
 }
Exemplo n.º 4
0
        private async Task InitAppCenterPushAsync()
        {
            await InitAppCenterServicesAsync().ConfigureAwait(false);


            //Registrar telefono en base de datos, así activo PUSH en el Dispositivo!
            var idInstalled02 = await Microsoft.AppCenter.AppCenter.GetInstallIdAsync().ConfigureAwait(false);

            string DeviceID = idInstalled02.Value.ToString();

            Analytics.TrackEvent("Device Name", new System.Collections.Generic.Dictionary <string, string>()
            {
                { "Device", DeviceID },
                { Singleton.Instance.User.username, DeviceID }
            });
            Singleton.Instance.User.Device_id = DeviceID;
            Singleton.Instance.User.Phone_OS  = Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS ? "iOS" : "Android";
            await RestClient.Post <Models.userModel>("users/device", Singleton.Instance.User).ConfigureAwait(false);


            ///Habilito Push Notifications
            ///
            Microsoft.AppCenter.AppCenter.Start(typeof(Push));
            await Push.SetEnabledAsync(true).ConfigureAwait(false);

            bool estado_push = await Push.IsEnabledAsync().ConfigureAwait(false);
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var acEnabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = acEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = acEnabled;
            RumEnabledSwitchCell.On         = _rumStarted && await RealUserMeasurements.IsEnabledAsync();

            RumEnabledSwitchCell.IsEnabled  = acEnabled;
            EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync();

            EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null;
            if (userInfo?.AccountId != null)
            {
                SignInInformationButton.Text = "User authenticated";
            }
            else
            {
                SignInInformationButton.Text = "User not authenticated";
            }
        }
Exemplo n.º 6
0
        public void GetEnabled()
        {
            Push.SetEnabledAsync(false).Wait();
            Assert.IsFalse(Push.IsEnabledAsync().Result);

            Push.SetEnabledAsync(true).Wait();
            Assert.IsTrue(Push.IsEnabledAsync().Result);
        }
Exemplo n.º 7
0
        protected override async void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            NotificationsEnabled = await Push.IsEnabledAsync();

            BaseUrl          = Helpers.Constants.BaseUrl;
            ApiManagementKey = Helpers.Constants.ApiManagementKey;
        }
Exemplo n.º 8
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var acEnabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = acEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = acEnabled;
        }
        protected override async void ViewIsAppearing(object sender, EventArgs e)
        {
            base.ViewIsAppearing(sender, e);

            NotificationsEnabled = await Push.IsEnabledAsync();

            BaseUrl                      = Helpers.Constants.BaseUrl;
            ApiManagementKey             = Helpers.Constants.ApiManagementKey;
            AzureADB2CTenant             = Helpers.Constants.Tenant;
            AzureADB2CApplicationId      = Helpers.Constants.ApplicationId;
            AzureADB2CSignUpSignInPolicy = Helpers.Constants.SignUpAndInPolicy;
            AzureADB2CScope              = Helpers.Constants.Scopes[0];
        }
Exemplo n.º 10
0
        private async Task SetupPushNotifications()
        {
            if (!AppCenter.Configured)
            {
                var isEnabled = await Push.IsEnabledAsync();

                if (!isEnabled)
                {
                    await Push.SetEnabledAsync(true);

                    isEnabled = await Push.IsEnabledAsync();
                }

                if (!isEnabled)
                {
                    Analytics.TrackEvent("Issues with enabling push");
                }

                Push.PushNotificationReceived += async(sender, e) =>
                {
                    // Add the notification message and title to the message
                    var summary = $"Push notification received:" +
                                  $"\n\tNotification title: {e.Title}" +
                                  $"\n\tMessage: {e.Message}";

                    // If there is custom data associated with the notification,
                    // print the entries
                    var analyticsData = new Dictionary <string, string>();

                    if (e.CustomData != null)
                    {
                        summary += "\n\tCustom data:\n";
                        foreach (var key in e.CustomData.Keys)
                        {
                            summary += $"\t\t{key} : {e.CustomData[key]}\n";

                            analyticsData.Add(key, e.CustomData[key]);
                        }
                    }

                    analyticsData.Add("title", e.Title);
                    analyticsData.Add("message", e.Message);

                    // Track that notification received
                    Analytics.TrackEvent("Push Received", analyticsData);

                    var snack = DependencyService.Get <IXSnack>();
                    await snack.ShowMessageAsync(e.Title);
                };
            }
        }
        public override async void Init(object initData)
        {
            base.Init(initData);
            NotificationsEnabled = await Push.IsEnabledAsync();

            ThirdPartyLibraries = new ObservableCollection <ThirdPartyLibrary>();
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("CarouselView", "Alex Rainman", "https://github.com/alexrainman/CarouselView"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("Lottie", "AirBnB, Martijn van Dijk", "https://github.com/martijn00/LottieXamarin"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("Corcav.Behaviors", "Corrado Cavalli", "https://github.com/corradocavalli/Corcav.Behaviors"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("Forms Toolkit", "James Montemagno", "https://github.com/jamesmontemagno/xamarin.forms-toolkit"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("FreshMvvm", "Michael Ridland", "https://github.com/rid00z/FreshMvvm"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("Humanizer", "Mehdi Khalili", "https://github.com/Humanizr/Humanizer"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("Refit", "Paul Betts", "https://github.com/paulcbetts/refit"));
            ThirdPartyLibraries.Add(new ThirdPartyLibrary("MvvmHelpers", "James Montemagno", "https://github.com/jamesmontemagno/mvvm-helpers"));
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle bundle)
        {
            ToolbarResource   = Resource.Layout.Toolbar;
            TabLayoutResource = Resource.Layout.Tabbar;
            Microsoft.AppCenter.AppCenter.Start("477babc0-a62f-440c-892f-5c24cf7dcd58", typeof(Analytics), typeof(Crashes), typeof(Push));
            Push.SetSenderId("998482667532");


            var a = Push.IsEnabledAsync();

            base.OnCreate(bundle);

            Forms.Init(this, bundle);

            LoadApplication(new App());
            //Crashes.GenerateTestCrash();
        }
Exemplo n.º 13
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var acEnabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = acEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = acEnabled;
            RumEnabledSwitchCell.On         = _rumStarted && await RealUserMeasurements.IsEnabledAsync();

            RumEnabledSwitchCell.IsEnabled  = acEnabled;
            EventFilterEnabledSwitchCell.On = _eventFilterStarted && await EventFilterHolder.Implementation?.IsEnabledAsync();

            EventFilterEnabledSwitchCell.IsEnabled = acEnabled && EventFilterHolder.Implementation != null;
        }
Exemplo 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 async 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();
            }

            bool EnablePush = await Push.IsEnabledAsync();

            Debug.WriteLine("EnablePush: " + EnablePush);
        }
        protected override async void OnAppearing()
        {
            base.OnAppearing();
            var mcEnabled = await MobileCenter.IsEnabledAsync();

            DistributeEnabledSwitchCell.On = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitchCell.IsEnabled = mcEnabled;
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = mcEnabled;
            if (XamarinDevice.RuntimePlatform == XamarinDevice.Android)
            {
                if (!Application.Current.Properties.ContainsKey(FirebaseEnabledKey))
                {
                    Application.Current.Properties[FirebaseEnabledKey] = false;
                }
                FirebaseAnalyticsEnabledSwitchCell.On = (bool)Application.Current.Properties[FirebaseEnabledKey];
            }
            RumEnabledSwitchCell.On = await RealUserMeasurements.IsEnabledAsync();

            RumEnabledSwitchCell.IsEnabled = mcEnabled;
        }
Exemplo n.º 16
0
        protected override async void UpdateState()
        {
            DistributeEnabledSwitch.CheckedChange -= UpdateDistributeEnabled;
            DistributeEnabledSwitch.Enabled        = true;
            DistributeEnabledSwitch.Checked        = await Distribute.IsEnabledAsync();

            DistributeEnabledSwitch.Enabled = await AppCenter.IsEnabledAsync();

            DistributeEnabledSwitch.CheckedChange += UpdateDistributeEnabled;

            PushEnabledSwitch.CheckedChange -= UpdatePushEnabled;
            PushEnabledSwitch.Enabled        = true;
            PushEnabledSwitch.Checked        = await Push.IsEnabledAsync();

            PushEnabledSwitch.Enabled = await AppCenter.IsEnabledAsync();

            PushEnabledSwitch.CheckedChange += UpdatePushEnabled;

            FirebaseAnalyticsEnabledSwitch.CheckedChange -= UpdateFirebaseAnalyticsEnabled;
            var enableAnalytics = Preferences.SharedPreferences.GetBoolean(Constants.FirebaseAnalyticsEnabledKey, false);

            FirebaseAnalyticsEnabledSwitch.Checked        = enableAnalytics;
            FirebaseAnalyticsEnabledSwitch.CheckedChange += UpdateFirebaseAnalyticsEnabled;
        }
Exemplo n.º 17
0
        async void RefreshPushEnabled(bool _appCenterEnabled)
        {
            PushEnabledSwitchCell.On = await Push.IsEnabledAsync();

            PushEnabledSwitchCell.IsEnabled = _appCenterEnabled;
        }
Exemplo n.º 18
0
 public override async void Init(object initData)
 {
     base.Init(initData);
     Version = $"{CrossVersionTracking.Current.CurrentVersion} (Build {CrossVersionTracking.Current.CurrentBuild})";
     NotificationsEnabled = await Push.IsEnabledAsync();
 }