/// <summary> /// The refresh agent is run when a user taps refresh on an item in the wallet, or when it has been viewed enough for the agent to deem it refreshable. /// The sorts of things you might want to do here include: /// 1) Update the transaction history for the item /// 2) Update the logo, contact information, and other metadata for the item /// 3) Update the status message to inform the user of required actions or present them with useful information. /// </summary> /// <param name="args">The args contain the list of wallet items that are currently being refreshed. This way, if there are multiple services/items in the /// wallet, you'll know which ones the user is looking at, and hence which ones need to be updated.</param> protected override async void OnRefreshData(RefreshDataEventArgs args) { // Iterate through each wallet item that requires a refresh. foreach (WalletItem item in args.Items) { WalletTransactionItem card = item as WalletTransactionItem; if (card != null) { // In this example, we're performing a fake transaction worth 5 points each time the Wallet Agent runs. We are also displaying // 1 random deal from the mock web services deals as the status message with a deep link to the deal in the application itself. // In the wallet UI, you can force the referesh agent to run by opening an item, expanding the application menu (the "..." at the bottom right), // and choosing "refresh". int newBalance = MockWebService.WebService.PerformMockTransaction(card); card.DisplayAvailableBalance = newBalance + " points"; Coupon deal = MockWebService.WebService.GetRelevantDealForUser(); card.Message = "You might be interested in " + deal.Description + " Click here to check it out!"; card.MessageNavigationUri = new Uri("/CouponView.xaml?ID=" + deal.ID, UriKind.Relative); await card.SaveAsync(); } } NotifyComplete(); }
/// <summary> /// The refresh agent is run when a user taps refresh on an item in the wallet, or when it has been viewed enough for the agent to deem it refreshable. /// The sorts of things you might want to do here include: /// 1) Update the transaction history for the item /// 2) Update the logo, contact information, and other metadata for the item /// 3) Update the status message to inform the user of required actions or present them with useful information. /// </summary> /// <param name="args">The args contain the list of wallet items that are currently being refreshed. This way, if there are multiple services/items in the /// wallet, you'll know which ones the user is looking at, and hence which ones need to be updated.</param> /// </remarks> protected override async void OnRefreshData(RefreshDataEventArgs args) { Random rand = new Random(); foreach (WalletItem item in args.Items) { WalletTransactionItem card = item as WalletTransactionItem; if (card != null) { int i = rand.Next(5, 50); card.Message = i.ToString() + " TrianglePoints has been added!"; card.MessageNavigationUri = new Uri("/TriangleBucksDeal.xaml?Added=" + i.ToString(), UriKind.Relative); await card.SaveAsync(); } } foreach (WalletItem item in args.Items) { PaymentInstrument card = item as PaymentInstrument; if (card != null) { if (card.Id == "Credit") { card.Message = "New statement available"; card.MessageNavigationUri = new Uri("/AccountPage.xaml", UriKind.Relative); await card.SaveAsync(); } } } NotifyComplete(); }
protected override void OnRefreshData(RefreshDataEventArgs args) { foreach (WalletItem item in args.Items) { item.SetUserAttentionRequiredNotification(true); } base.OnRefreshData(args); NotifyComplete(); }