public async Task <bool> NotificationRegistrationAsync(ProfileRealm profile)
        {
            try
            {
                if (!this._pushNotificationPlatformSpecificService.IsPushNotificationEnabledByDevice())
                {
                    throw new DisabledPushByDeviceException().SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 168);
                }
                string platform = this._pushNotificationHandler.Platform.ToString();
                NotificationMessageType notificationType = NotificationMessageType.All;
                string handle = this._pushNotificationHandler.Token;
                NotificationMessageSource notificationSource = NotificationMessageSource.Kreta;
                TokenData tokenData = this._secureStore.GetTokenData(profile.Id);
                if (tokenData.ExpiresAt <= DateTime.Now)
                {
                    tokenData = await((IAuthDbDataService)Mvx.get_IoCProvider().Resolve <IAuthDbDataService>()).RefreshToken(profile);
                }
                if (tokenData == null)
                {
                    return(false);
                }
                this._tokenInfoRepository.AddOrUpdate(new TokenInfoRealmMapper().To((Ekreta.Mobile.Core.Models.TokenInfo)JsonConvert.DeserializeObject <Ekreta.Mobile.Core.Models.TokenInfo>(TokenDecoder.Decode(tokenData.AccessToken))), (Action <TokenInfoRealm>)null);
                Ekreta.Mobile.Core.Models.PushNotification.PushSettings pushSettings = await this._globalMobileApi.NotificationRegistrationAsync(profile.TokenInfo.InstituteCode, profile.TokenInfo.InstituteUserId, profile.TokenInfo.TutelaryId, platform, handle, (UserRoles)profile.TokenInfo.Role, notificationSource, (int)notificationType, profile.Id);

                PushSettingsRealm pushSettingsRealm = new PushSettingsRealmMapper().To(pushSettings);
                if (pushSettingsRealm != null)
                {
                    this._pushSettingsRepository.AddOrUpdate(pushSettingsRealm, (Action <PushSettingsRealm>)(ps =>
                    {
                        ps.NotificationTypes = (int)notificationType;
                        ps.FirstTimePushRun  = true;
                        ps.UpdateEugyintezes = true;
                        ps.Token             = handle;
                    }));
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings = pushSettingsRealm));
                }
                else if (profile.PushSettings != null)
                {
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings.FirstTimePushRun = true));
                }
                else
                {
                    this.AddOrUpdate(profile, (Action <ProfileRealm>)(p => p.PushSettings = new PushSettingsRealm()
                    {
                        FirstTimePushRun = true
                    }));
                }
                return(pushSettings != null);
            }
            catch (DisabledPushByDeviceException ex)
            {
                ex.SetErrorCode <DisabledPushByDeviceException>("/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 243);
                throw;
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, "ProfileDataService.NotificationRegistrationAsync", "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 75);
                return(false);
            }
        }
        public async Task <bool> NotificationUpdateAsync(
            ProfileRealm profile,
            NotificationMessageType notificationType,
            string token)
        {
            try
            {
                Ekreta.Mobile.Core.Models.PushNotification.PushSettings pushSettings = await this._globalMobileApi.NotificationUpdateAsync(profile.PushSettings.RegistrationId, (int)notificationType, NotificationMessageSource.Kreta, token);

                profile.PushSettings.NotificationTypes = (int)notificationType;
                profile.PushSettings.Token             = token;
                this.AddOrUpdate(profile, (Action <ProfileRealm>)null);
                return(true);
            }
            catch (Exception ex)
            {
                CrossMobileAnalytics.Current.TrackException(ex, (IDictionary <string, string>)null, nameof(NotificationUpdateAsync), "/Users/admin/myagent/macMiniBlack3/_work/2/s/eKreta.Mobile/eKreta.Mobile.Core.Standard/Repository/DataServices/ProfileDbDataService.cs", 269);
                return(false);
            }
        }