|
| 1 | +using POGOProtos.Networking.Responses; |
| 2 | +using PokemonGo.RocketAPI; |
| 3 | +using PokemonGo_UWP.Utils; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.IO; |
| 7 | +using System.Linq; |
| 8 | +using System.Runtime.InteropServices.WindowsRuntime; |
| 9 | +using System.Threading.Tasks; |
| 10 | +using Template10.Common; |
| 11 | +using Windows.Foundation; |
| 12 | +using Windows.Foundation.Collections; |
| 13 | +using Windows.UI.Xaml; |
| 14 | +using Windows.UI.Xaml.Controls; |
| 15 | +using Windows.UI.Xaml.Controls.Primitives; |
| 16 | +using Windows.UI.Xaml.Data; |
| 17 | +using Windows.UI.Xaml.Input; |
| 18 | +using Windows.UI.Xaml.Media; |
| 19 | +using Windows.UI.Xaml.Navigation; |
| 20 | + |
| 21 | +// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238 |
| 22 | + |
| 23 | +namespace PokemonGo_UWP.Views |
| 24 | +{ |
| 25 | + /// <summary> |
| 26 | + /// An empty page that can be used on its own or navigated to within a Frame. |
| 27 | + /// </summary> |
| 28 | + public sealed partial class ChallengePage : Page |
| 29 | + { |
| 30 | + public string ChallengeUri; |
| 31 | + private static Client _client; |
| 32 | + public ChallengePage() |
| 33 | + { |
| 34 | + this.InitializeComponent(); |
| 35 | + } |
| 36 | + protected override void OnNavigatedTo(NavigationEventArgs e) |
| 37 | + { |
| 38 | + base.OnNavigatedTo(e); |
| 39 | + ChallengeUri = e.Parameter.ToString(); |
| 40 | + ChallengePanel.Navigate(new Uri(ChallengeUri)); |
| 41 | + } |
| 42 | + |
| 43 | + private void ChallengePanel_LoadCompleted(object sender, NavigationEventArgs e) |
| 44 | + { |
| 45 | + string url = e.Uri.ToString(); |
| 46 | + if (url.StartsWith("unity:")) |
| 47 | + { |
| 48 | + int index = url.IndexOf("unity:"); |
| 49 | + if (index != -1) |
| 50 | + { |
| 51 | + string token = url.Remove(index); |
| 52 | + Verify(token); |
| 53 | + } |
| 54 | + else |
| 55 | + { |
| 56 | + //Error, no token! |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + private async void Verify(string token) |
| 61 | + { |
| 62 | + await VerifyChallenge(token); |
| 63 | + BootStrapper.Current.NavigationService.Navigate(typeof(GameMapPage)); |
| 64 | + } |
| 65 | + private static async |
| 66 | + Task |
| 67 | + <VerifyChallengeResponse> VerifyChallenge(string token) |
| 68 | + { |
| 69 | + return await _client.Misc.VerifyChallenge(token); |
| 70 | + } |
| 71 | + } |
| 72 | +} |
0 commit comments