I have a strange problem with in-app purchase in Windows Store App.
When I upload app to the Store I see a pop-up like this:
But when I run in on my local machine, from release mode and using CurrentApp
everything seems to be OK, I see checking price in Store:
Also the funny thing is that there is no difference when I am using CurrentApp or CurrentAppSimulator.
Please tell me what am I doing wrong?
Code for checking is commonly known:
public async Task<bool> IsPurchased(string featureName)
{
var applicationInformation = CurrentApp.LicenseInformation;
if (applicationInformation.ProductLicenses[featureName].IsActive)
{
return true;
}
else
{
await CurrentApp.RequestProductPurchaseAsync(featureName);
return applicationInformation.ProductLicenses[featureName].IsActive;
}
}
I had to delete all content from bin folder, clean solution and rebuild it.
Aftere these operation everything works OK.
Related
I am using Uno Platform to make an app which access a specific folder inside the user's Documents library from a game (BeamNG.drive). I want the app to read all the mod files inside this folder to be able to edit and display them to users on startup. I installed the Nito.Mvvm.Async Package to help me bind everything to the UI.
Here's part of the method that loads the mod files from the Documents folder:
public static async Task<List<Mod>> GetModList()
{
StorageFolder documents = await KnownFolders.DocumentsLibrary.GetFolderAsync("BeamNG.drive");
IReadOnlyList<StorageFile> fileList = await documents.GetFilesAsync();
List<Mod> foundModsList = new();
foreach (StorageFile file in fileList)
{
//...
}
return foundModsList;
}
Here's the code on MainPage.xaml.cs inside the Shared project in my solution, based on code from this answer
public NotifyTask<ObservableCollection<Mod>> ModsData { get; }
public MainPage()
{
InitializeComponent();
ModsData = NotifyTask.Create(InitModData());
}
private static async Task<ObservableCollection<Mod>> InitModData()
{
return new(await ModManager.GetModList());
}
The GetModList() method is called, but the GetFolderAsync("BeamNG.drive") method never returns, and the app keeps running normally (not UI freezes or anything). If I add a breakpoint in that line, Visual Studio stops there normally. But if I press "Step Over", instead of continuing on that method, VS jumps to this line...
return new(await ModManager.GetModList());
...then this one:
ModsData = NotifyTask.Create(InitModData());
Using ConfigureAwait(false) in any of the calls using await doesn't help anything. I'm really not sure what is going on and I suspect that Nito.Mvvm.Async might have something to do with it (considering its last update was in 2017) but I'm really not sure.
From your question it seems this problem occurs under .NET 5 - meaning targeting WebAssembly or Skia targets of Uno Platform. Under Uno, the KnownFolders type is not yet supported, so accessing DocumentLibrary is not possible. If you want to have this supported, please file an issue on Uno Platform GitHub.
In case of UWP, to access the Documents library, you need to declare a special capability in app manifest (see Docs). However, it is a restricted capability and it is quite likely that if you utilize it, the app will not pass Microsoft Store certification. Instead, it is recommended to use FolderPicker instead and let the user decide on the location when files are stored, or to use ApplicationData.Current.LocalFolder to store the data for the app privately.
The environment I'm using might sound a bit messed up, so I will try to explain it at best.
I'm doing some experimental things with Electron. Right now, I have a simple .dll written in C# with using .NET Standard 2.0 as the base. On Electron's side, I'm using electron-edge-js, which, I think, works fine because I'm able to communicate with both of them.
So basic process goes like this,
I'm building my C# code to get my .dll's (I'm also adding reference dlls as well). Putting them into the same folder with Electron project. Starting the project to see how they did.
The problem lies at .dll's code. I'm using the following simple code,
public string RegisterUser(string username, string userkey) {
try {
RegistryKey key;
if (Microsoft.Win32.Registry.CurrentUser == null) return "Current user is null";
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(#"SOFTWARE\Test\TestFunctions");
if (key == null) return "Key is null";
key.SetValue("uid", username);
key.SetValue("upsw", userkey);
key.Close();
return "Done";
} catch (Exception e) {
return e.ToString();
}
}
However, whenever I call this method, it always returns "Current user is null" no matter what. I tried building my .exe and running it as administrator as well. I checked the privileges in Regedit as well. They all seem fine. I'm having a kinda hard time for such an easy code. A little help would be amazing, thanks!
Hello: I've been wrestling a bit with getting my app to authenticate. I've deployed the APK to my Galaxy and the following happens: Unity game opens, "Connecting to..." dialog appears, "Google Play" green dialog appears, dialog disappears with loading indicator and then I get a "false" result.
I have the following in Start():
PlayGamesPlatform.Activate();
PlayGamesPlatform.DebugLogEnabled = true;
AuthenticateGoogle();
And the following in AuthenticateGoogle():
private bool AuthenticateGoogle()
{
isAuthorized = false;
Social.localUser.Authenticate((bool result) => {
isAuthorized = result;
if (!result)
{
GameObject.Find("errText").GetComponent<Text>().text = result.ToString();
}
});
return isAuthorized;
}
I created a new Keystore using the Unity UI, entered the password and built the .APK. I then created a new application in the Google Play Console and uploaded the .APK to it. I next created a new Game Service and linked the app, allowing it to Trust the application. I created a leaderboard. I ensured my user is in the Testing section. Lastly I copied the XML from the Get resources section under leaderboard to my Unity project and built the project, copying to my phone.
Any ideas? Any other things I can do to troubleshoot authentication versus a true/false result?
I assume that you are testing it on your android phone.
You should try adding this to your android mainfest:
<activity android:name="com.google.games.bridge.NativeBridgeActivity" android:theme="#android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
You can create custom mainfest in Assets/Plugins/Android/AndroidMainfest.xml
Add yourself to testers on Google Play Console (if the app is in beta) and download it directly through google play. (not test build and run)
To track errors like this you can use a tool https://assetstore.unity.com/packages/tools/log-viewer-12047 It's simple to use and you can understand what went wrong. Hope it'll help :)
EDIT:
I'm using different method, but it shouldn't make a difference:
public bool ConnectToGoogleServices()
{
if (!isConnectedToGoogleServices)
{
{
Social.localUser.Authenticate(success =>
{
isConnectedToGoogleServices = success;
});
}
}
return isConnectedToGoogleServices;
}
I have a usb connected MSR reader and i am trying to get it by using the sample codes proveded in here. This works fine but the problem is when i add the same code to my app it doesn't work. GetDefaultAsync returns null.
private static MagneticStripeReader _reader = null;
public static async void StartRead()
{
if (await CreateDefaultMagneticStripeReaderObject())
{
....
}
}
private static async Task<bool> CreateDefaultMagneticStripeReaderObject()
{
if (_reader == null)
{
_reader = await MagneticStripeReader.GetDefaultAsync();
if (_reader == null)
return false;
}
return true;
}
My code is like above, very similer to sample but it doesnt work. Also i've added the device capability of pointOfService. So that is not the case.
I was in the exact same situation and I spent the last 5 hours, finally I know what was going on. You are missing a capability in the Package.appxmanifest
'pointOfService' is the capability you want to include. This capability does not show in the UI and therefore I could not find any difference between my broken project and Microsoft's sample project. You can not add that capability using the UI. You have to manually add it by modifying the XML file.
The sample project by Microsoft have it too
https://github.com/Microsoft/Windows-universal-samples/blob/master/Samples/MagneticStripeReader/cs/Package.appxmanifest#L53
Make sure the card reader is in HID mode and not Keyboard emulation mode. That was one of my problems.
To do this is really wonky. MagTek has a ActiveX control on their website to assist us... because ActiveX is awful, you can only use it with InternetExplorer (it won't even work with Edge.)
go here in IE: https://www.magtek.com/changemode/
Enable active X when it pops up, and you can change from hid to keyboard and back.
I had this problem so I thought I'd post the answer since I couldn't find the solution anywhere.
First problem: when calling CurrentApp.RequestProductPurchaseAsync() I would get "Can't find item in catalog ; We looked but can't find the item you wanted to buy" or error 805a0194.
Second problem: Couldn't find a way to get if my purchase was active or not.
Solution to problem one: go to your Package.appxmanifest and right click then hit view code. if your app was already published like mine was go to the dashboard and get the AppId from the Windows Phone dashboard->apps->YourApp->Details. Paste that id into the PhoneProductId field in the Package.appxmanifest. Now your in app purchases should work as long as you published the product in the store and product id you supplied to the method matches.
Solution to Problem 2: I used this bit of code to see if the purchase was active:
private async Task<bool> GetLicenseStatus(string id)
{
try
{
var result = await CurrentApp.GetProductReceiptAsync(id);
}
catch //user didnt buy
{
return false;
}
return true;
}