public override async Task Init() { if (inAppPurchase == null) { lock (syncRoot) if (inAppPurchase == null) { inAppPurchase = DependencyService.Get <IInAppPurchase>(); inAppPurchase.OnProductsRetrieved += InAppPurchase_OnProductsRetrieved; inAppPurchase.OnProductPurchased += InAppPurchase_OnProductPurchased; inAppPurchase.OnTransactionFailed += InAppPurchase_OnTransactionFailed; inAppPurchase.OnValidationFailed += InAppPurchase_OnValidationFailed; } if (CurrentNetworkStatus != NetworkStatus.NotReachable) { await requestProductData(); } else { return; } } await base.Init(); }
public MainScreenViewModel() { _storage = ServiceLocator.Current.GetInstance <IInternalStorage> (); if (Device.RuntimePlatform == Device.Android) { _inapp = ServiceLocator.Current.GetInstance <IInAppPurchase> (); } _codeManager = ServiceLocator.Current.GetInstance <CodeManager> (); _refreshManager = ServiceLocator.Current.GetInstance <RefreshManager> (); _codeStorageManager = ServiceLocator.Current.GetInstance <CodeStorageManager> (); _cityNames = new List <string> (Constants.CityList.Keys); var savedPin = _storage.RetrieveString(Constants.Pin); PIN = (string.IsNullOrEmpty(savedPin)) ? Constants.DefaultPin : savedPin; var savedCity = _storage.RetrieveString(Constants.City); SelectedCity = (string.IsNullOrEmpty(savedCity)) ? Constants.DefaultCity : savedCity; var savedProject = _storage.RetrieveString(Constants.Project); SelectedProject = (string.IsNullOrEmpty(savedProject)) ? Constants.DefaultProject : savedProject; var savedKey1 = _storage.RetrieveString(Constants.Key1); Prefix1 = (string.IsNullOrEmpty(savedKey1)) ? Keyboard._0_0_Text : savedKey1; var savedKey2 = _storage.RetrieveString(Constants.Key2); Prefix2 = (string.IsNullOrEmpty(savedKey2)) ? Keyboard._0_1_Text : savedKey2; var savedKey3 = _storage.RetrieveString(Constants.Key3); Prefix3 = (string.IsNullOrEmpty(savedKey3)) ? Keyboard._0_2_Text : savedKey3; var savedKey4 = _storage.RetrieveString(Constants.Key4); Prefix4 = (string.IsNullOrEmpty(savedKey4)) ? Keyboard._0_3_Text : savedKey4; var savedKey5 = _storage.RetrieveString(Constants.Key5); Prefix5 = (string.IsNullOrEmpty(savedKey5)) ? Keyboard._0_4_Text : savedKey5; Code = string.Empty; RefreshEnabled = true; _codeManager.ChangeCode += ChangeCode; _refreshManager.ScrollChanged += OnSrollChanged; _codeStorageManager.ConnectedChanged += ConnectedChanged; Paid = (Device.RuntimePlatform != Device.Android) || _storage.RetrieveBool(Constants.Paid); Load(); if (Device.RuntimePlatform == Device.Android) { LoadProducts(); } }
static InAppPurchase() { ActivityServer.Instance.UpdateManager.InitStaticImpl(typeof(InAppPurchase), typeof(InAppPurchaseDefautImpl), o => { mImpl = (IInAppPurchase)o; }); }