This is not currently an issue as much as a curiosity and perhaps something that will help others. I have been struggling for several days to get the licensing library to work correctly. It works correctly on the first / second times the app is launched. After that, it sticks with a cached licensed response. It doesn't matter if you set the testing response in the console to "not licensed."
I resolved this by setting the salt parameter to a random value (see below).
The tutorial for the licensing library says:
I interpreted that to mean that you just don't change the value from that random string in your code from one run to the next. Here is the original:
Anyway, my new code works, and responds to the changes to the status in the Play Console. Sorry if I have misunderstood something.
Thanks,
Jack
I resolved this by setting the salt parameter to a random value (see below).
B4X:
'this was written by Erel in a different context
Sub GenerateRandomString (Length As Int) As String
Dim su As StringUtils
Dim bytes(Length) As Byte
Private secureRandom1 As SecureRandom
secureRandom1.GetRandomBytes(bytes)
Return su.EncodeBase64(bytes).SubString2(0, Length)
End Sub
Sub CheckLicense
Dim bc As BCrypt
Dim hash As String = bc.hashpw(GenerateRandomString(10),bc.gensalt)
lc.Initialize("lc", GetDeviceId, publicKey, hash.GetBytes("UTF8"))
' lc.SetVariableAndValue("test2", "abd")
lc.CheckAccess
End Sub
The tutorial for the licensing library says:
The Salt parameter should be an array of bytes with some random values (the values should be the same on each run).
I interpreted that to mean that you just don't change the value from that random string in your code from one run to the next. Here is the original:
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim lc As LicenseChecker
Dim p As PhoneId
lc.Initialize("lc", p.GetDeviceId, publicKey, "kljdflkf".GetBytes("UTF8"))
lc.SetVariableAndValue("test_1", "some secret value")
lc.CheckAccess
End Sub
Anyway, my new code works, and responds to the changes to the status in the Play Console. Sorry if I have misunderstood something.
Thanks,
Jack