/// <summary> /// Initializes a new instance of the <see cref="NotificationPage" /> class. /// </summary> public NotificationPage() { InitializeComponent(); //this.BindingContext = NotificationDataService.Instance.NotificationViewModel; var data = new EncounterDataService(); this.BindingContext = data.NotificationViewModel; this.notificationViewModel = data.NotificationViewModel; MessagingCenter.Subscribe <object, string[]>(this, App.NotificationBodyReceivedKey, OnMessageReceived); }
protected override void OnStart() { LoadPersistentValues(); var data = new EncounterDataService(); this.BindingContext = data.NotificationViewModel; var status = CrossSecureStorage.Current.GetValue("SignedIn", null); if (status != null && status == "True") { MainPage = new NavigationPage(new BottomNavigationPage()); var name = CrossSecureStorage.Current.GetValue("Name"); var surname = CrossSecureStorage.Current.GetValue("Surname"); var email = CrossSecureStorage.Current.GetValue("Email"); MessagingCenter.Subscribe <UserLoggedIn>(this, "UserLoggedIn", async message => { var userManagementServiceNotification = IoCContainer.GetInstance <IUserManagementService>(); var serverNotifi = await userManagementServiceNotification.GetNotifications(); //var serverNotiList = userManagementServiceNotification; using (SQLiteConnection conn = new SQLiteConnection(App.FilePath)) { conn.DropTable <NotificationDB>(); conn.CreateTable <NotificationDB>(); var notifications = conn.Table <NotificationDB>().ToList(); foreach (var n in serverNotifi) { NotificationDB passingNotification = new NotificationDB(); passingNotification.Body = n.Body; passingNotification.Time = n.Time; conn.Insert(passingNotification); } conn.Close(); } }); IoCContainer.GetInstance <IUserManagementService>().UserLoggedIn(name, surname, email); } else { MainPage = new LoginWithSocialIconPage(); } }