Пример #1
0
 protected override void OnStart()
 {
     if (!AppCenter.Configured)
     {
         AppCenter.LogLevel                  = LogLevel.Verbose;
         Crashes.SendingErrorReport         += SendingErrorReportHandler;
         Crashes.SendingErrorReport         += SendingErrorReportHandler;
         Crashes.SentErrorReport            += SentErrorReportHandler;
         Crashes.FailedToSendErrorReport    += FailedToSendErrorReportHandler;
         Crashes.ShouldProcessErrorReport    = ShouldProcess;
         Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;
         Crashes.GetErrorAttachments         = GetErrorAttachments;
         Distribute.ReleaseAvailable         = OnReleaseAvailable;
         Push.PushNotificationReceived      += OnPushNotificationReceived;
         AppCenter.Start($"uwp={uwpKey};android={androidKey};ios={iosKey}",
                         typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push));
         AppCenter.GetInstallIdAsync().ContinueWith(installId =>
         {
             AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
         });
         Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
         {
             AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
         });
         Crashes.GetLastSessionCrashReportAsync().ContinueWith(report =>
         {
             AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Exception=" + report.Result?.Exception);
         });
     }
 }
Пример #2
0
        protected override void OnStart()
        {
            #region Handle PushNotificationReceived Event

            if (!AppCenter.Configured)
            {
                Push.PushNotificationReceived += PushOnPushNotificationReceived;
            }

            #endregion

            #region Start the device

            AppCenter.Start($"android=1806a5f4-1633-478a-a20c-b4bd9122b51d;",
                            typeof(Push));

            #endregion

            #region "Save" VS App Center Install Id

            AppCenter.GetInstallIdAsync().ContinueWith(installId =>
            {
                System.Diagnostics.Debug.WriteLine("*********************************************************");
                System.Diagnostics.Debug.WriteLine($"VS App Center InstallId={installId.Result}");
                System.Diagnostics.Debug.WriteLine("*********************************************************");
            });

            #endregion
        }
Пример #3
0
        public App()
        {
            var language = LanguageService.GetCurrentLanguage();

            AppResources.Culture = new CultureInfo(language.GetLanguageCode());

            var savedAppVersion   = Portable.Helpers.Settings.AppVersion;
            var currentAppVersion = DependencyService.Get <IAppVersionProvider>().AppVersion;

            bool overwrite = savedAppVersion != currentAppVersion;

            RealmService.Initialize(overwrite);

            Portable.Helpers.Settings.AppVersion = currentAppVersion;

            this.InitializeComponent();

            // Update Audit on startup
            Task.Run(UpdateService.UpdateAudit);

            AppCenter.Start(
                $"ios={IosAppCenterKey};android={AndroidAppCenterKey};",
                typeof(Analytics),
                typeof(Crashes));

            Console.WriteLine("AuditUpdate. AppCenter InstallId: " + AppCenter.GetInstallIdAsync().Result);

            this.MainPage = new BottomTabbedPage();
        }
Пример #4
0
        private void TriggerIngestion(State state, IList <Log> logs, string batchId)
        {
            // Before sending logs, trigger the sending event for this channel
            if (SendingLog != null)
            {
                foreach (var eventArgs in logs.Select(log => new SendingLogEventArgs(log)))
                {
                    SendingLog?.Invoke(this, eventArgs);
                }
            }

            // If the optional Install ID has no value, default to using empty GUID
            // TODO When InstallId will really be async, we should not use Result anymore
            var rawInstallId = AppCenter.GetInstallIdAsync().Result;
            var installId    = rawInstallId.HasValue ? rawInstallId.Value : Guid.Empty;

            using (var serviceCall = _ingestion.PrepareServiceCall(_appSecret, installId, logs))
            {
                serviceCall.ExecuteAsync().ContinueWith(completedTask =>
                {
                    var ingestionException = completedTask.Exception?.InnerException as IngestionException;
                    if (ingestionException == null)
                    {
                        HandleSendingSuccess(state, batchId);
                    }
                    else
                    {
                        HandleSendingFailure(state, batchId, ingestionException);
                    }
                });
            }
        }
Пример #5
0
        public static async void Run()
        {
            CrossVersionTracking.Current.Track();

            // Crashes.GetErrorAttachment = (report) => ErrorAttachment.AttachmentWithText (CrossVersionTracking.Current.ToString ());
#if __IOS__
            Distribute.DontCheckForUpdatesInDebug();
#endif

            if (!string.IsNullOrEmpty(PrivateKeys.MobileCenter.AppSecret))
            {
                AppCenter.Start(PrivateKeys.MobileCenter.AppSecret,
                                typeof(Analytics),
                                typeof(Crashes),
                                typeof(Distribute));
            }

            // JsonHttpClient.GlobalHttpMessageHandlerFactory = () => new NativeMessageHandler ();

            Settings.RegisterDefaultSettings();
            Settings.SetUomDefaults(CrossVersionTracking.Current.IsFirstLaunchEver);

            var appcenterInstallId = await AppCenter.GetInstallIdAsync();

            Settings.UserReferenceKey = appcenterInstallId?.ToString("N");

#if __ANDROID__
            Settings.VersionNumber = CrossVersionTracking.Current.CurrentVersion;

            Settings.BuildNumber = CrossVersionTracking.Current.CurrentBuild;

            Settings.RandomBackgrounds |= CrossVersionTracking.Current.IsFirstLaunchEver;
#endif
        }
Пример #6
0
        protected override void OnStart()
        {
            if (!AppCenter.Configured)
            {
                AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenter.LogLevel = LogLevel.Verbose;
                AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                // Set callbacks
                Crashes.ShouldProcessErrorReport    = ShouldProcess;
                Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;
                Crashes.GetErrorAttachments         = GetErrorAttachmentsCallback;
                Distribute.ReleaseAvailable         = OnReleaseAvailable;

                // Event handlers
                Crashes.SendingErrorReport      += SendingErrorReportHandler;
                Crashes.SentErrorReport         += SentErrorReportHandler;
                Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler;
                Push.PushNotificationReceived   += PrintNotification;

                AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                if (!StartType.OneCollector.Equals(StartTypeUtils.GetPersistedStartType()))
                {
                    AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
                }

                Distribute.SetInstallUrl("https://install.portal-server-core-integration.dev.avalanch.es");
                Distribute.SetApiUrl("https://api-gateway-core-integration.dev.avalanch.es/v0.1");
                Auth.SetConfigUrl("https://config-integration.dev.avalanch.es");
                Data.SetTokenExchangeUrl("https://token-exchange-mbaas-integration.dev.avalanch.es/v0.1");

                AppCenter.Start(GetTokensString(), typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Auth), typeof(Data));
                if (Current.Properties.ContainsKey(Constants.UserId) && Current.Properties[Constants.UserId] is string id)
                {
                    AppCenter.SetUserId(id);
                }

                // Work around for SetUserId race condition.
                AppCenter.Start(typeof(Push));
                AppCenter.IsEnabledAsync().ContinueWith(enabled =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
                });
                AppCenter.GetInstallIdAsync().ContinueWith(installId =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
                });
                AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion);
                Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
                });
                Crashes.GetLastSessionCrashReportAsync().ContinueWith(task =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace);
                });
            }
        }
Пример #7
0
        private async void RecordSuccessfulLogin(User user, string loginSource)
        {
            App.AuthUserId    = user.Id;
            App.AuthUserEmail = user.Email;
            App.AuthUserName  = user.Name;
            if (user.Email.ToLower() != "*****@*****.**")
            {
                Preferences.Set(Config.Preference_Email, user.Email);
            }

            Analytics.TrackEvent("Successful Login", new Dictionary <string, string> {
                { "Source", loginSource },
                { "UserName", user.Name },
                { "UserEmail", user.Email },
                { "UserId", user.Id.ToString() }
            });
            ErrorDescription = string.Empty;

            user.LastLoginDate  = DateTime.UtcNow;
            user.UpdatedBy      = user.UserName;
            user.UpdatedDate    = DateTime.UtcNow;
            user.InstallationId = (await AppCenter.GetInstallIdAsync()).ToString();

            if (1 == await _dataService.UpdateUser(user))
            {
                await _dataService.QueueAsync(user.Id, QueueableObjects.UserUpdate);

                _dataService.StartSafeQueuedUpdates();
            }
        }
Пример #8
0
        async void OnItemSelected(object sender, SelectedItemChangedEventArgs args)
        {
            var item = args.SelectedItem as Item;

            if (item == null)
            {
                return;
            }

            await Navigation.PushAsync(new ItemDetailPage(new ItemDetailViewModel(item)));

            // Manually deselect item.
            ItemsListView.SelectedItem = null;
            Analytics.TrackEvent("Site visited - " + item.Text);


            System.Guid?installId = await AppCenter.GetInstallIdAsync();

            try
            {
                throw (new Exception("Sharpe!"));
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, new Dictionary <string, string> {
                    { "Filename", "saved_game001.txt" },
                    { "Where", "Reload game" },
                    { "Issue", "Atezzla boy" + installId.ToString() }
                });
            }

            //Crashes.GenerateTestCrash();
        }
Пример #9
0
        private async void RecordSuccessfulPassiveLogin(User user)
        {
            App.AuthUserId    = user.Id;
            App.AuthUserEmail = user.Email;
            App.AuthUserName  = user.Name;

            Analytics.TrackEvent("Successful Login", new Dictionary <string, string> {
                { "Source", "PassiveLogin" },
                { "UserName", user.Name },
                { "UserEmail", user.Email },
                { "UserId", user.Id.ToString() }
            });
            ErrorDescription = string.Empty;

            user.LastLoginDate  = DateTime.UtcNow;
            user.UpdatedBy      = user.UserName;
            user.UpdatedDate    = DateTime.UtcNow;
            user.InstallationId = (await AppCenter.GetInstallIdAsync()).ToString();

            if (1 == await _dataService.UpdateUser(user))
            {
                await _dataService.QueueAsync(user.Id, QueueableObjects.UserUpdate);

                _dataService.StartSafeQueuedUpdates();
            }
        }
Пример #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            PushNotificationSetup();
            AppCenter.Start("438ad34c-9c3b-46c5-8f42-436713b336dc", typeof(Analytics), typeof(Crashes), typeof(Push));


            //System.Guid? installId = AppCenter.GetInstallIdAsync().Result;

            Guid installId;// = null;
            var  idTask = AppCenter.GetInstallIdAsync();

            idTask.ContinueWith((task) =>
            {
                var result = (task as System.Threading.Tasks.Task <Guid?>).Result;
                if (result.HasValue)
                {
                    installId = result.Value;
                }
            });

            //CustomProperties properties = new CustomProperties();
            //properties.Set("usuarioID", 12345);
            //AppCenter.SetCustomProperties(properties);
        }
Пример #11
0
        protected override void OnStart()
        {
            // Handle when your app starts

            #region  Handle push notification

            if (!AppCenter.Configured)
            {
                // Microsoft.AppCenter.Push.Push.PushNotificationReceived += OnPushNotificationReceived;
            }
            #endregion
            #region start app service

            AppCenter.Start("7527047f-67e1-48d5-9e4d-a0bc4294fdf8", typeof(Microsoft.AppCenter.Push.Push));
            #endregion

            #region save app center install Id

            AppCenter.GetInstallIdAsync().ContinueWith(installid =>
            {
                System.Diagnostics.Debug.WriteLine("********************");
                System.Diagnostics.Debug.WriteLine("app center id = " + installid.Result);
                System.Diagnostics.Debug.WriteLine("********************");
            });
            #endregion
        }
Пример #12
0
        private async Task TriggerIngestionAsync(State state)
        {
            using (await _mutex.GetLockAsync(state).ConfigureAwait(false))
            {
                if (!_enabled || !_batchScheduled)
                {
                    return;
                }
                AppCenterLog.Debug(AppCenterLog.LogTag,
                                   $"TriggerIngestion({Name}) pending log count: {_pendingLogCount}");
                _batchScheduled = false;
                if (_sendingBatches.Count >= _maxParallelBatches)
                {
                    AppCenterLog.Debug(AppCenterLog.LogTag,
                                       $"Already sending {_maxParallelBatches} batches of analytics data to the server");
                    return;
                }
            }

            // Get a batch from storage
            var logs    = new List <Log>();
            var batchId = await _storage.GetLogsAsync(Name, _maxLogsPerBatch, logs).ConfigureAwait(false);

            if (batchId != null)
            {
                using (await _mutex.GetLockAsync(state).ConfigureAwait(false))
                {
                    _sendingBatches.Add(batchId, logs);
                    _pendingLogCount -= logs.Count;
                }
                try
                {
                    // Before sending logs, trigger the sending event for this channel
                    if (SendingLog != null)
                    {
                        foreach (var log in logs)
                        {
                            AppCenterLog.Debug(AppCenterLog.LogTag, $"Invoke SendingLog event for channel '{Name}'");
                            SendingLog?.Invoke(this, new SendingLogEventArgs(log));
                        }
                    }

                    // If the optional Install ID has no value, default to using empty GUID
                    var installId = await AppCenter.GetInstallIdAsync().ConfigureAwait(false) ?? Guid.Empty;

                    var ingestionCall = _ingestion.Call(_appSecret, installId, logs);
                    using (await _mutex.GetLockAsync(state).ConfigureAwait(false))
                    {
                        _calls.Add(ingestionCall);
                    }
                    ingestionCall.ContinueWith(call => HandleSendingResult(state, batchId, call));
                    CheckPendingLogs(state);
                }
                catch (StorageException)
                {
                    AppCenterLog.Warn(AppCenterLog.LogTag, "Something went wrong sending logs to ingestion");
                }
            }
        }
Пример #13
0
        public static async void Setup()
        {
            // This should come before AppCenter.Start() is called
            // Avoid duplicate event registration:
            if (!AppCenter.Configured)
            {
                Push.PushNotificationReceived += async(sender, e) =>
                {
                    // If the notification contains message data, handle it as such
                    if (e.CustomData.ContainsKey("conversationId"))
                    {
                        Message notifiedMessage = new Message();
                        notifiedMessage.id             = int.Parse(e.CustomData["id"]);
                        notifiedMessage.conversationId = int.Parse(e.CustomData["conversationId"]);
                        notifiedMessage.text           = e.CustomData["text"];
                        notifiedMessage.timestamp      = new CustomDateTime(DateTime.Parse(e.CustomData["timestamp"]));

                        if (conversationController != null)
                        {
                            if (conversationController.conversation != null && conversationController.conversation.id == notifiedMessage.conversationId)
                            {
                                if (!conversationController.conversationMessages.Contains(notifiedMessage))
                                {
                                    conversationController.conversationMessages.Insert(0, notifiedMessage);
                                }
                            }
                        }
                        else
                        {
                            if (messageThreadsListPageController != null)
                            {
                                List <Conversation> localConversation    = new List <Conversation>(messageThreadsListPageController.conversationList);
                                Conversation        conversationToUpdate = localConversation.Find(conversation =>
                                                                                                  conversation.id == notifiedMessage.conversationId);

                                if (conversationToUpdate != null)
                                {
                                    conversationToUpdate.messages.Insert(0, notifiedMessage);
                                    messageThreadsListPageController.conversationList.Clear();
                                    messageThreadsListPageController.conversationList.AddRange(localConversation);
                                }
                                else
                                {
                                    await messageThreadsListPageController.ReloadConversations();
                                }
                            }
                        }

                        DependencyService.Get <IToast>().ShortAlert("You have received a message");
                    }
                };
            }
            AppCenter.Start("android=95e48718-8158-4eef-ab58-fac02629e859;" +
                            "ios=14d06e7a-6ff3-4e01-8838-59cbb905dbc2;",
                            typeof(Analytics), typeof(Crashes), typeof(Push));
            var id = await AppCenter.GetInstallIdAsync();

            System.Diagnostics.Debug.WriteLine(id.ToString());
        }
Пример #14
0
        protected override void OnStart()
        {
            if (!AppCenter.Configured)
            {
                AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenter.LogLevel = LogLevel.Verbose;
                AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                // Set callbacks
                Crashes.ShouldProcessErrorReport    = ShouldProcess;
                Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;
                Crashes.GetErrorAttachments         = GetErrorAttachmentsCallback;
                Distribute.ReleaseAvailable         = OnReleaseAvailable;

                // Event handlers
                Crashes.SendingErrorReport      += SendingErrorReportHandler;
                Crashes.SentErrorReport         += SentErrorReportHandler;
                Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler;
                Push.PushNotificationReceived   += PrintNotification;

                AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                var updateTrack = TrackUpdateUtils.GetPersistedUpdateTrack();
                if (updateTrack != null)
                {
                    Distribute.UpdateTrack = updateTrack.Value;
                }
                if (Current.Properties.TryGetValue(Constants.AutomaticUpdateCheckKey, out object persistedObject) && !(bool)persistedObject)
                {
                    Distribute.DisableAutomaticCheckForUpdate();
                }
                AppCenter.Start(GetTokensString(), typeof(Analytics), typeof(Crashes), typeof(Distribute));
                if (Current.Properties.ContainsKey(Constants.UserId) && Current.Properties[Constants.UserId] is string id)
                {
                    AppCenter.SetUserId(id);
                }

                // Work around for SetUserId race condition.
                AppCenter.Start(typeof(Push));
                AppCenter.IsEnabledAsync().ContinueWith(enabled =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
                });
                AppCenter.GetInstallIdAsync().ContinueWith(installId =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
                });
                AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion);
                Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
                });
                Crashes.GetLastSessionCrashReportAsync().ContinueWith(task =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace);
                });
            }
        }
Пример #15
0
 protected override void OnAppearing()
 {
     base.OnAppearing();
     if (InstallIdLabel != null)
     {
         InstallIdLabel.Text = AppCenter.GetInstallIdAsync().Result?.ToString();
     }
 }
        private async Task CheckAppCenterValuesAsync()
        {
            var id = await AppCenter.GetInstallIdAsync();

            if (id.HasValue)
            {
                UUID = id.ToString();
            }
        }
Пример #17
0
        public void GetInstallId()
        {
            var fakeInstallId = Guid.NewGuid();

            _settingsMock.Setup(settings => settings.GetValue(AppCenter.InstallIdKey, It.IsAny <Guid>())).Returns(fakeInstallId);
            var installId = AppCenter.GetInstallIdAsync().Result;

            Assert.IsTrue(installId.HasValue);
            Assert.AreEqual(installId.Value, fakeInstallId);
        }
Пример #18
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            AppCenter.Start("5a1cc2b3-6765-4680-ae41-2c6f9c50bd66",
                            typeof(Analytics), typeof(Crashes), typeof(LogLevel));
            AppCenter.LogLevel = LogLevel.Verbose;                       //Verbose logging of events whilst in BETA
            System.Guid?installId = await AppCenter.GetInstallIdAsync(); //Get the UID of the app which is reporting

            //   new Controls.LoginPage().Show();
            //   new Views.Quotes().Show();
            new MainWindow().Show();
        }
Пример #19
0
        public void GetNewInstallId()
        {
            AppCenter.Configure("appsecret");

            _settingsMock.ResetCalls();

            var installId = AppCenter.GetInstallIdAsync().Result;

            Assert.IsTrue(installId.HasValue);
            Assert.IsNotNull(installId.Value);
            _settingsMock.Verify(settings => settings.SetValue(AppCenter.InstallIdKey, It.IsNotNull <Guid?>()), Times.Once());
        }
        /// <summary>
        /// Returns an 8 character unique key. This is designed to be used as an anonymous User ID
        /// </summary>
        /// <returns></returns>
        public async Task <string> GetSupportKeyAsync()
        {
            if (!string.IsNullOrWhiteSpace(supportKey))
            {
                return(supportKey);
            }

            return(supportKey =
                       (await AppCenter.GetInstallIdAsync() ?? Guid.NewGuid())
                       .ToString()
                       .Substring(0, 8));
        }
Пример #21
0
        /// <summary>
        /// スキャンページに遷移する
        /// </summary>
        /// <returns></returns>
        private async Task ViewScanPageAsync()
        {
            try
            {
                // Box名を保存
                (Application.Current as App).BoxId = edtBoxName.Text;

                // インジケータを表示
                SetIndicator(true);

                // カメラでQRコードを撮影する
                var scanner    = DependencyService.Get <IQrScanningService>();
                var scanResult = await scanner.ScanAsync();

                if (scanResult != null)
                {
                    (Application.Current as App).BoxId = scanResult.Text;
                }

                // デバイスIDを取得
                var deviceId = await AppCenter.GetInstallIdAsync();

                // 取引開始
                var api        = new CartApiService();
                var cartResult = await api.CartStartAsync(new CartStart
                {
                    BoxId    = (Application.Current as App).BoxId,
                    DeviceId = deviceId.ToString()
                });

                // 取引開始で商品カートへ遷移
                if (cartResult != null && /*cartResult.IsSuccess*/ !string.IsNullOrEmpty(cartResult.CartId))
                {
                    (Application.Current as App).CartId = cartResult.CartId;
                    await this.Navigation.PushAsync(new RegisterPage(deviceId.Value.ToString(), false));
                }
                else
                {
                    await this.DisplayAlert("SmartRetail", $"買い物を開始できません\n{cartResult.ErrorMessage}", "OK");

                    // 取引開始できない場合はログインへ戻る
                    await this.Navigation.PopAsync();
                }

                //インジケータを隠す
                SetIndicator(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #22
0
        public async Task Init()
        {
            if (await CheckAppCenter())
            {
                //https://docs.microsoft.com/en-us/appcenter/sdk/other-apis/xamarin#identify-installations//
                System.Guid?installId = await AppCenter.GetInstallIdAsync();

                if (installId != null)
                {
                    _installId = (Guid)installId;
                }
            }
        }
Пример #23
0
        private async Task GetAppInstallID()
        {
            try
            {
                System.Guid?installId = await AppCenter.GetInstallIdAsync();

                GlobalStaticFields.InstallID = installId;
            }
            catch (Exception ex)
            {
                var log = ex;
            }
        }
Пример #24
0
        protected override void OnStart()
        {
            if (!AppCenter.Configured)
            {
                AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenter.LogLevel = LogLevel.Verbose;
                AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                // Set callbacks
                Crashes.ShouldProcessErrorReport    = ShouldProcess;
                Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;
                Crashes.GetErrorAttachments         = GetErrorAttachments;
                Distribute.ReleaseAvailable         = OnReleaseAvailable;

                // Event handlers
                Crashes.SendingErrorReport      += SendingErrorReportHandler;
                Crashes.SentErrorReport         += SentErrorReportHandler;
                Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler;
                Push.PushNotificationReceived   += PrintNotification;

                AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                var appSecrets = GetAppSecretDictionary();
                AppCenter.Start($"uwp={appSecrets[XamarinDevice.UWP]};android={appSecrets[XamarinDevice.Android]};ios={appSecrets[XamarinDevice.iOS]}", typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Auth), typeof(Data));
                if (Current.Properties.ContainsKey(Constants.UserId) && Current.Properties[Constants.UserId] is string id)
                {
                    AppCenter.SetUserId(id);
                }

                // Work around for SetUserId race condition.
                AppCenter.Start(typeof(Push));
                AppCenter.IsEnabledAsync().ContinueWith(enabled =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
                });
                AppCenter.GetInstallIdAsync().ContinueWith(installId =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
                });
                AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion);
                Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
                });
                Crashes.GetLastSessionCrashReportAsync().ContinueWith(task =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.StackTrace=" + task.Result?.StackTrace);
                });
            }
        }
        async private void SignUpBtn_ClickedAsync(object sender, EventArgs e)
        {
            // Verifico que todos los campos tengan contenido
            if (string.IsNullOrEmpty(_EntryUserFirstName.Text) ||
                string.IsNullOrEmpty(_EntryUserLastName.Text) ||
                string.IsNullOrEmpty(_EntryEmail.Text) ||
                string.IsNullOrEmpty(_EntryPassword.Text) ||
                string.IsNullOrEmpty(_EntryGroupCode.Text))
            {
                _LabelAllFields.IsVisible = true;
                return;
            }
            else
            {
                _LabelAllFields.IsVisible = false;
            }

            // Llamo el servicio encargado de crear la cuenta
            UserServices userServices = new UserServices();
            UserToken    userToken    = new UserToken();


            // Implemento un Loading para el Login
            using (UserDialogs.Instance.Loading("Validando...", null, null, true, MaskType.Black))
            {
                // Consigo el ID de Instalacion
                System.Guid?installId = await AppCenter.GetInstallIdAsync();

                userToken = await userServices.UserSignUp(_EntryUserFirstName.Text,
                                                          _EntryUserLastName.Text,
                                                          _EntryEmail.Text,
                                                          _EntryPassword.Text,
                                                          _EntryGroupCode.Text,
                                                          installId.ToString());
            }

            // Reviso si encontre mensajes de error
            if (!userToken.IsSuccessStatusCode)
            {
                // Usuario y/o contraseña no corresponde
                await DisplayAlert("Oppssss", userToken.message, "OK");

                return;
            }

            // Guardo el token en el dispositivo
            GeneralServices.SaveCredentialsMethod(userToken.token, false);

            // Ingreso al usuario en la plataforma e ingreso el menu principal
            Application.Current.MainPage = new MasterMenu();
        }
Пример #26
0
        private async Task <HttpClient> CreateClientAsync()
        {
            var client = new HttpClient
            {
                BaseAddress = new Uri(Secrets.AppServiceEndpoint)
            };
            var authResult = await SilentLoginAsync();

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("BEARER", authResult.AccessToken);
            client.DefaultRequestHeaders.Add("X-Platform", Xamarin.Forms.Device.RuntimePlatform);
            client.DefaultRequestHeaders.Add("X-DeviceId", (await AppCenter.GetInstallIdAsync())?.ToString());

            return(client);
        }
Пример #27
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var countryCode = RegionInfo.CurrentRegion.TwoLetterISORegionName;
            var userID      = AppCenter.GetInstallIdAsync();

            ThemeManager.Current.ThemeSyncMode = ThemeSyncMode.SyncAll;
            ThemeManager.Current.ChangeTheme(Current, FASTER.Properties.Settings.Default.theme);

            AppCenter.SetCountryCode(countryCode);
            AppCenter.SetUserId($"{Environment.UserName}_{Environment.MachineName}_{Environment.UserDomainName}_{userID}");
            Analytics.SetEnabledAsync(true);
            AppCenter.Start("257a7dac-e53c-4bec-b672-b6b939ed5d1e", typeof(Analytics), typeof(Crashes));
        }
Пример #28
0
        private async void LoadCheckData()
        {
            if (!Logic.IsInternet())
            {
                DependencyService.Get <IMessage>().ShortAlert(Constants.No_Internet);
                return;
            }

            try
            {
                ChangeLoading(true);
                await Task.Delay(10);

                UserData = await Store.UserClass.Get();

                chatCheck.IsToggled    = UserData.ChatRoomNotification;
                commentCheck.IsToggled = UserData.CommentNotification;

                if (string.IsNullOrEmpty(UserData.AppCenterID) || UserData.Logger == null || UserData.Key == null)
                {
                    Guid?installId = await AppCenter.GetInstallIdAsync();

                    UserData.AppCenterID = installId.Value.ToString();
                    UserData.Logger      = Logic.GetDeviceInformation();
                    if (UserData.Key == null)
                    {
                        UserData.Key = new List <string>();
                        UserData.Key.Insert(0, await Logic.GetKey());
                    }

                    ChangeLoading(true);
                    await Task.Delay(10);

                    await Store.UserClass.Update(UserData);
                }
                ChangeLoading(false);
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex, Logic.GetErrorProperties(ex));
                ChangeLoading(false);
            }
            finally
            {
                loading = false;
                ChangeLoading(false);
            }
        }
Пример #29
0
        public void GetInstallId()
        {
            AppCenter.Configure("appsecret");

            var fakeInstallId = Guid.NewGuid();

            _settingsMock.ResetCalls();
            _settingsMock.Setup(settings => settings.GetValue(AppCenter.InstallIdKey, It.IsAny <Guid>())).Returns(fakeInstallId);

            var installId = AppCenter.GetInstallIdAsync().Result;

            Assert.IsTrue(installId.HasValue);
            Assert.AreEqual(installId.Value, fakeInstallId);
            _settingsMock.Verify(settings => settings.GetValue(AppCenter.InstallIdKey, It.IsAny <Guid>()),
                                 Times.Once());
        }
Пример #30
0
        protected override void OnStart()
        {
            if (!AppCenter.Configured)
            {
                AppCenterLog.Assert(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenter.LogLevel = LogLevel.Verbose;
                AppCenterLog.Info(LogTag, "AppCenter.LogLevel=" + AppCenter.LogLevel);
                AppCenterLog.Info(LogTag, "AppCenter.Configured=" + AppCenter.Configured);

                // Set callbacks
                Crashes.ShouldProcessErrorReport    = ShouldProcess;
                Crashes.ShouldAwaitUserConfirmation = ConfirmationHandler;
                Crashes.GetErrorAttachments         = GetErrorAttachments;
                Distribute.ReleaseAvailable         = OnReleaseAvailable;

                // Event handlers
                Crashes.SendingErrorReport      += SendingErrorReportHandler;
                Crashes.SentErrorReport         += SentErrorReportHandler;
                Crashes.FailedToSendErrorReport += FailedToSendErrorReportHandler;
                Push.PushNotificationReceived   += PrintNotification;

                AppCenterLog.Assert(LogTag, "AppCenter.Configured=" + AppCenter.Configured);
                AppCenter.SetLogUrl("https://in-integration.dev.avalanch.es");
                Distribute.SetInstallUrl("https://install.portal-server-core-integration.dev.avalanch.es");
                Distribute.SetApiUrl("https://api-gateway-core-integration.dev.avalanch.es/v0.1");
                Auth.SetConfigUrl("https://config-integration.dev.avalanch.es");
                Data.SetTokenExchangeUrl("https://token-exchange-mbaas-integration.dev.avalanch.es/v0.1");
                AppCenter.Start($"uwp={UwpKey};android={AndroidKey};ios={IosKey}", typeof(Analytics), typeof(Crashes), typeof(Distribute), typeof(Push), typeof(Auth), typeof(Data));
                AppCenter.IsEnabledAsync().ContinueWith(enabled =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.Enabled=" + enabled.Result);
                });
                AppCenter.GetInstallIdAsync().ContinueWith(installId =>
                {
                    AppCenterLog.Info(LogTag, "AppCenter.InstallId=" + installId.Result);
                });
                AppCenterLog.Info(LogTag, "AppCenter.SdkVersion=" + AppCenter.SdkVersion);
                Crashes.HasCrashedInLastSessionAsync().ContinueWith(hasCrashed =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.HasCrashedInLastSession=" + hasCrashed.Result);
                });
                Crashes.GetLastSessionCrashReportAsync().ContinueWith(task =>
                {
                    AppCenterLog.Info(LogTag, "Crashes.LastSessionCrashReport.Exception=" + task.Result?.Exception);
                });
            }
        }