Play Store Billing : Get last subscription renewal date - java

I am currently trying to fix the following edge case in my app, without using the "Google Play Android Developer API" :
User buys Subscription(e.g. 1st of January)
Several Subscription renewals occur
User cancels his subscription(e.g. on the 15th of March)
User still has access to the subscription content, until the next billing period (e.g the 1st of March)
I am having difficulties doing so because whenever I call the queryPurchases() on my BillingClient object I always get the same data for orderId (Google states that the order ID should change based on the renewal recurrance number link ) and purchaseTime stay the same, no matter if queryPurchases(SkuType.SUBS) is called while the subscription is active or canceled (same behaviour occurs if I call the queryPurchaseHistoryAsync(). I would love to solve this issue without having to mess with the "Google Play Android Developer API".Using it seems a bit overkill for something as simple as getting the date of the last successful subscription renewal or just how many successful renewals there were.

Related

Advanced filtering of a list with typo-tolerance, counting, user-specific etc.?

I am building an Android application, later on maybe also an iOS version of the app and a web application. I have a list, for example in this way:
City Name
State
Counter Clicked
More columns
Dallas
Texas
4
…
Boston
Massachusetts
3
…
New York City
New York
1
…
San Francisco
California
3
…
San Diego
California
3
…
Seattle
Washington
10
…
Boise
Idaho
0
…
I am searching for a solution how to meet the following requirements:
The list and its data are always up to date and transferred from a backend system (Google Firebase) when the user is online.
The solution needs to work on iOS / Android devices and if possible also on a website.
Typing in "D" only "Dallas" should be displayed.
Typing in "S" Seattle, San Diego, and San Francisco should be displayed in this order, because of the "Counter Clicked" value (the higher the value, the more relevant is the result)
Typing in "S" also Dallas, Boston, Boise should be displayed in this order (regarding "Counter Clicked") after the words beginning with "S", because they are containing the letter "S" within the word.
The "Counter Clicked" is handled per user. So the City Name can be selected and every time the user selects the city name, the "counter clicked" should be increased by 1.
The filter service should be offline ready, so the "Counter Clicked" should be handled on the device. I am not quite sure if it makes sense to upload the data back to the Firebase backend server, what do you think?
It would be great to have a typo tolerance. So for example typing "Bostn" or "Sen" (tolerance by one letter) "Boston" or "San …" should be displayed.
I will also have the possibility to have a facet filter so that I can filter before typing for one of the "State"s of the USA.
I am interested in a professional solution if this is available on the market, otherwise, I need to build it for myself.
I am building an Android application, later on maybe also an iOS version of the app and a web application.
You can achieve that using Firebase because:
Firebase is a platform developed by Google for creating mobile (iOS and Android) and web applications.
I am searching for a solution how to meet the following requirements
To answer your questions, I will use Cloud Firestore which is:
Cloud Firestore is a flexible, scalable database for mobile, web, and server development from Firebase and Google Cloud. Like Firebase Realtime Database, it keeps your data in-sync across client apps through real-time listeners and offers offline support for mobile and web so you can build responsive apps that work regardless of network latency or Internet connectivity.
Let's get started:
The list and its data are always up to date and transferred from a backend system (Google Firebase) when the user is online.
You have the answer right above, "it keeps your data in-sync across client apps through realtime listeners". So your data will always up to date.
The solution needs to work on iOS / Android devices and if possible also on a website.
It will, as Firebase is a cross-platform solution.
Typing in "D" only "Dallas" should be displayed.
You can achieve that in a very simple way, by using Query's startAt() method:
Creates and returns a new Query that starts at the provided fields relative to the order of the query.
So you query should look in code like this:
ref.collection("cities").orderBy("cityName").startAt(name).endAt(name + "\uf8ff");
You can also check the docs for that, and see my answer from the following article:
How to filter Firestore data cheaper?
Typing in "S" Seattle, San Diego, and San Francisco should be displayed in this order, because of the "Counter Clicked" value (the higher the value, the more relevant is the result)
To solve this, you can use Query's orderBy(String field, Query.Direction direction) method:
Creates and returns a new Query that's additionally sorted by the specified field, optionally in descending order instead of ascending.
So you can display those cities according to the number of the "Counter Clicked".
Typing in "S" also Dallas, Boston, Boise should be displayed in this order (regarding "Counter Clicked") after the words beginning with "S", because they are containing the letter "S" within the word.
Unfortunately, Firestore does not support full-text search. The official documentation regarding the full-text search in Cloud Firestore is up to date and stands for Algolia.
For Android, please see my answer from the following post:
Is it possible to use Algolia query in FirestoreRecyclerOptions?
Or:
Is there a way to search sub string at Firestore?
The "Counter Clicked" is handled per user. So the City Name can be selected and every time the user selects the city name, the "counter clicked" should be increased by 1.
This can be very simply achieved using FieldValue.increment(1) as explained in my answer from the following post:
What is the recommended way of saving durations in Firestore?
The filter service should be offline ready, so the "Counter Clicked" should be handled on the device. I am not quite sure if it makes sense to upload the data back to the Firebase backend server, what do you think?
According to the official documentation regarding Access data offline:
Cloud Firestore supports offline data persistence.
For Android and iOS, offline persistence is enabled by default.
For the web, offline persistence is disabled by default. To enable persistence, call the enablePersistence method.
So you have support for three platforms, and yes, it makes sense to upload the data to the server because in that way you'll always have consistent data.
It would be great to have a typo tolerance. So for example typing "Bostn" or "Sen" (tolerance by one letter) "Boston" or "San …" should be displayed.
That's nothing built-in Firestore that can help you with that. What you can do, is to create an additional field of type array and search within it. So that array might have typos like that "Bostn" or "Bston".
I will also have the possibility to have a facet filter so that I can filter before typing for one of the "State"s of the USA.
That's also nothing already built-in Firestore, but you can implement for sure something like that. Most likely you might consider defining some filters and use them before typing.
I am interested in a professional solution if this is available on the market, otherwise, I need to build it for myself.
For sure Firebase can help you achieve what you want, so I hope I was able to provide the best solutions for that.

Send an email (or any message) once and only once inside a retryable operation

I have a program that is charging a user's credit card. The card is charged via a 3rd party API. When I get a response from the 3rd party API, I update the internal representation of the user's balance. Once the user's balance is updated a receipt is sent to the user via email.
There is a small chance that some server error (e.g. unexpected power outage) could occur between charging a user's card and updating the internal representation of their balance. To protect against this, I've made the entire payment process idempotent so it can be retried without double charging the user but will definitely update the user's internal balance. The only issue is with sending the receipt. There is no way (that I can think of) to make this operation idempotent. Currently, I'm sending an email only of the balance update actually changes anything, but of course the server could fail between the balance update and sending the receipt, leading to a situation where the receipt will never be sent. How do people typically address this problem?
I've marked this question as language-agnostic because it seems to be a general problem with sending messages, but I'm using Java and AWS's Simple Email Service for this so it would be great to get answers using those technologies.
When we have done this before, We used a flag in the object that was set when the notification was sent so that the loop wouldnt send the email if the flag had been set for that transaction/id

Google Play Game Services - Custom Notification / Welcome Back

I have been looking all over the internet, but can't find my answer.
Is there a way to show the user that they are signed in to the GPGS.
The first time you sign in you'll get a notification, what will say "Welcome < name >"
But when you open the app the next time nothing is shown.
Is there a way to show a Welcome Back notification? For iOS it is possible: noted just above Step 9:
https://developers.google.com/games/services/ios/quickstart?hl=en#step_9_add_a_sign-out_button
Any ideas?
If you want the official Welcome Back Notification (the one that shows when a user is authenticated for the first time, or after having been signed out... not just disconnected), there are a few approaches that I use. (this is based on using the GameHelper Class as supplied by Google)
1) When a user quits the game by actually using a control that tells me they have left because they wanted to quit (i.e. not because of a phone call interrupt, or user hits the home button) I have had my apps just sign out of Play Services. This causes the user to have to sign in the next time around (which you can either do for them programmatically, or use the Google Sign in button), which causes the "Welcome Back" to flash. (make sure you use a way to track that they were logged in, as I believe Google wants users to use a button to sign in, if they signed out on their own volition)
2) I have forced the current sign in session to logout upon app startup, which means the same thing, user has to login (whether by app design or Google Button)
3) On app startup, wait for the onSignInSucceeded (which is triggered, but no auto Welcome Back) and show your own "You are Still Signed In" Toast message.
The part you mention above for iOS:
If you run your application again, you should now see a "Welcome back!" notification when you start the game. This is being powered by the GPGManager. At this point, your application and Game services are authorized and ready to go! You're now ready to earn achievements, load save games from the cloud, display social leaderboards, and so on.
Is actually implemented the same way for us... if your user hasn't been connected for a while, and their session has expired... the Welcome Back popup will be displayed when GameHelper re-initiates the connection (Something like 24 hours... I haven't done enough tests to find out exactly when Google tosses the current session credentials)

How can you send the exact number of notification (the number next to your apps) to facebook instead of each time we make a request?

I'm trying to have more control on the number we have next to our apps for the user, How can we just send the exact number to show instead of sending notification that increment that number each time.
Basically the current behavior is :
Friend ask for something or give me a gift it increase the number
If another friend send me something its increase the number.
When I log to the game all the counter is reset.
Wanted behavior :
When I log to the game and i go see only one friend on the counter for this friend is reset.
We are currently using facebook-java-api but we will probably merge to restfb soon.
But if you know how to do it in any language it will probably help.
The old dashboard api support the set_count method that can reset to 0 or put the value you want for your apps.
See http://developers.facebook.com/docs/reference/rest/dashboard.setCount/
However the facebook-java-api don't support setCount but the newer restFB does so we need to update our apps to the new api.
EDIT: Note that you and extend the BasicClient and create a custom IFacebook Method with facebook-java-api it`s not clean but it do the trick utils we upgrade to a new facebook api.

Activation codes

I am not sure what shall i put as Title for this Question, But I am here looking for help.
I work in a company which makes desktop based application on CORE JAVA Platform.
We provide an ACTIVATION CODE to activate our software.
The concept of activation is -
User enters the Activation code --> software hits our server and download all the required files --> activation completed.
Once in a day, our software hits our server to check if the activation code has been expired.
Problem-
We have a new client which doesn't have a regular internet connection. Somehow they agreed to provide internet connection for one time-
User enters the Activation code --> software hits our server and download all the required files --> activation completed.
but after that no internet connection. I can stop the software to check with server about expiry Date of activation code.
But the problem with me is-
1) How do I check whether the Activation code has actually expired? ( Activation code is valid for 1 year only)
2) If after expiry If user enters a new Activation code, how do I check this is a valid activation code with 1 year validity?
1) you can store the registration date and compare it against the system date. of course then users can temper with the date. I used to have some software that always stored the last date it had seen, and if one moved the date to the past, it complained and insta-expired. you could do something like this but of course it's never as safe as talking to a server.
2) create a format for your activation key that contains a new key as well as the previous key. so the first key is, say, A, which is good for talking to a server and checking if A is okay. A new key might look like AB meaning "I replace A, add another year of activation, and am called B, so in a year, we'll need a key like BC". You'll have to think a bit about how to encode this securely, but I'm pretty confident it can work (for example, you can encrypt B with A, then B can only be used on a machine with activation code A).

Categories