public async void CallIAP() { String result = String.Empty; await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() => { IAPWrapper iapwrapper = new IAPWrapper(); result = await iapwrapper.Purchase("test").ConfigureAwait(true); var dialog = new MessageDialog(result, "消息提示"); dialog.Commands.Add(new UICommand("确定", cmd => { }, commandId: 0)); dialog.Commands.Add(new UICommand("取消", cmd => { }, commandId: 1)); //设置默认按钮,不设置的话默认的确认按钮是第一个按钮 dialog.DefaultCommandIndex = 0; dialog.CancelCommandIndex = 1; //获取返回值 var result2 = await dialog.ShowAsync(); } ); Debug.Log(result); }
public async Task <String> TaskOnClickAsync() { String statusText = String.Empty; #if !NETFX_CORE Purchase("abc"); #else IAPWrapper iapwrapper = new IAPWrapper(); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { statusText = await iapwrapper.Purchase("abc"); }); //statusText = await iapwrapper.Purchase("abc"); #endif Debug.Log("You have clicked the mouse! " + statusText); return(statusText); }
void OnBtnClick() { if (cost <= 0) { var showed = GADWrapper.ShowRewardedAd( GADWrapper.RewardedAdId.ID_FREE_GOLD, (reward) => MainThreadDispatcher.Instance.Enqueue(() => AddGold(gold)), true, false, 2 ); if (!showed) { GADWrapper.LoadRewardedAd( GADWrapper.RewardedAdId.ID_FREE_GOLD, 2 ); } } else { var id = ""; Action onSuccess = () => { MainThreadDispatcher.Instance.Enqueue(() => AddGold(gold)); }; switch (cost) { case 1: id = IAPWrapper.Const.Consumable.ID_GOLD_1; break; case 2: id = IAPWrapper.Const.Consumable.ID_GOLD_2; break; default: id = IAPWrapper.Const.Consumable.ID_GOLD_3; break; } IAPWrapper.Initiate(false); IAPWrapper.BuyProduct(id, onSuccess, disableAds: removeAds); } }