I have a situation in which I have to update video details on facebook, that update needs two different calls, now my problem is
If any of the call fails, then what should I do?
I dont want to show user partially updated data, neither I want to retry as that might fail again if it failed already.
Only solution I think is to make a new call that will revert that previous call change, but that doesnt seems to be a nice solution.
Can someone suggest a better approach?
It's a difficult situration.
Prior to making any API calls you should do anything you can to check for possible reasons why the calls may fail ahead of time - like missing authentication or authorization.
I agree that it is best practice not to show the user partially updated data, so you have a few options depending on what kind of failure you are up against.
If it fails with a network-like error you could just attempt a single retry to the 2nd endpoint.
Otherwise I'd recommend rolling back. If your rollback call fails, you should inform your user that some data has changed and could not be rolled back. If the error is a network error again you could create a queuejob to run later for rolling back the changes.
In any event, you should inform your user.
Related
I hope this makes a bit sense, basically, I have this feature in my app for tracking calories which consists of having this page that only appears the first time you use the feature and it asks you to add personal details (so it can make the right calculations), after that you get faced with a simple page that tracks your nutrition with a button for the user to insert the meals he has eaten, this page has to save the inserted data (via firebase) and then restart from 0 each and every day.
my first problem is I don't know how I make the page that only appears one time to save personal data(to be more precise I don't know how to make only appears the first time). and the second problem is how do I make the app automatically sends the given data at the end of each day?
interface in normal state, interface when adding the meals
hopefully, this 2 images will help you get a better grasp of what am trying to explain
don't worry am not looking for someone to straight up solve it all for me, I just need some orientation about what type of things/functions I need to do to solve these 2 problems
While #Narendra_Nath's answer might work, please note that is not a bulletproof solution. Why? Because a SharedPreferences doesn't persist across app uninstalls. This means that your user can install and uninstall the app and see the page as much as they want. So if you indeed want a user to see a screen only once, then you should consider storing that data in a database. Please note that SQLite isn't also a solution because when a user uninstalls the app, everything that is stored locally is wiped out. So what's the solution?
The best way to solve this would be to store the data in the cloud, either in Cloud Firestore or in the Realtime Database. So you can set a boolean variable and always check against it.
If you however intend to implement Firebase Authentication, then another solution would be to display the screen when your users are authenticated for the first time. So even if they will try to sign in on another device, install and uninstall the app, they won't be able to see the screen again.
Regarding the second problem, you should consider using Cloud Function for Firebase. It's the most elegant solution. If you want to somehow schedule an operation, then you should consider using Cloud Scheduler, as explained in my answer in the following post:
Is it not possible to have a code in the background who will be called every 24h?
Make the page that only appears one-time -> store a value in the shared preferences "isInfoShownToUser -> false" then do a check when the app starts to check if this value is false or true. If it is false show the "take the info" page .. then turn the value to false in the shared preferences.
How do I make the app automatically send data -> Use a Workmanager implementation to send data to the server (Firebase) at a particular time ..
Or use a implementation like the first one which uploads the data to the server just once everyday
I was trying to write a load testing script, I have created one as well but the users I am passing are all not performing the transactions, I have used correlation to capture the UUID of users and have passed this UUID in all of the samplers, now when we are logged in the last user that comes from the login only that iser execute the transactions for 'n' number of times. Please can anyone tell me why this is happening and what can be the solution.
Your question is not very clear hence I can only provide a generic piece of advice:
Run your test with 2 virtual users and 2 iterations and inspect request and response details using View Results Tree listener, this way you will be able to ensure that your test is doing what it is supposed to be doing and if not - identify where the problem is
Check that all correlated/parameterized variables have their anticipated values using Debug Sampler
Check that there are no any suspicious entries in jmeter.log file
If after all you will still experience issues include comprehensive details into your question covering:
JMeter configuration
Expected behaviour (preferably with request/response details from the network tab of the real browser)
Actual behaviour (preferably with request/response details from the View Results Tree listener)
In-app messages work well in test mode, but seem to be very unreliable in production. I made campaigns with "Modals" as the message layout. The simplest possible messages, without any pictures. If I set countries as the targets, no messages seem to be shown in the target countries.
I have 2 campaigns without any country targets and those messages get shown, but still just sometimes. The first of these campaigns informs the user they have an opportunity to reach Level 1.
The message get shown about 50% of the times it should be shown (once per device). Sometimes the message get shown so quickly that it just flashes by, so it is impossible to read the text. It closes before the user closes it. The second of these campaigns inform the user when they have reached Level 1. It is the same result as described above here.
My calls to logEvent are from methods, which are directly called from the onresume method in the Main activity of the app. They are called according to certain conditions, not every time onresume is called. My calls look for instance like this:
FirebaseAnalytics.getInstance(this).logEvent("gyro_access", Bundle.EMPTY);
What can be done to make the In-app messages work in a reliable way in production?
I got this to work now. I used this method instead to trigger the messages:
FirebaseInAppMessaging.getInstance().triggerEvent()
I also updated Gradle, so the latest version of com.google.firebase:firebase-inappmessaging-display was used.
So the solution to my problem was either using the triggerEvent-method or updating Gradle.
I am using S3 Lifecycle Rule to move objects to Glacier. Since objects will be moved to glacier storage I need to make sure my application RDS is also
updated with similar details.
As per my discussion over this thread AWS Lambda for objects moved to glacier, there is no way currently to generate SQS notification to get notified about object being moved to glacier.
Also, as per my understanding currently Lifecycle rule will be evaluated once in a day, but there is not specific time when this will happen in a day. If there was i was planning to have a scheduler which will run after that and update status of archived objects in RDS.
Is there a way that you can suggest which will be close enough to sync this status changes between AWS & RDS?
Let me know your feedback or if you need more information on this to understand use case.
=== My Current approach is as per below.
Below is exact flow that I have implemented, please review and let me know if there is anything that could have been done in better way.
When object is uploaded to system I am marking it with status Tagged and also capturing creation date. My Lifecycle rule is configured with 30 days from creation. So, I have a scheduler which calculates difference between today's date and object creation date for all objects with status Tagged, and check if diff is greater than equal to 30. If so, it updates status to Archived.
If user performs any operation on object with status Archived, we explicitly check in s3 whether object is actually moved to glacier or not. If not we perform operation requested. If moved to glacier we initiate restore process and wait for restore to finish to initiate operation requred.
I appreciate your thoughts and would like to hear your inputs on above approach that i have taken.
Regards.
If I wanted to implement this, I would set the storage class of the object inside my database as "Glacier/Archived" at the beginning of the day it is supposed to transition.
You already know your lifecycle policies, and, as part of object metadata, you also know the creation time of each object. Then it becomes a simple query, which can be scheduled to run every night at 12:00 AM.
You could further enhance your application by defining an algorithm that checks if an object has transitioned to Glacier today, at the moment when object access is requested, it would go and explicitly check if it is actually transitioned or not. If it is marked as Glacier/Archive for more than a day, then checking is no longer required.
Of course, if for any reason, the above solution doesn't work for you, it is possible to write a scanner application to continuously check the status of those objects that are supposed to transition at "DateTime.Today" and are not marked as Glacier/Archive yet.
I am making a game for Android/iOS. I have recently got daily quest to work nicely, the only problem is I can't figure out when I should save quest progress.
I don't want to make a servercall everytime you do something in the game that could effect quest progress.
Say for example your quest is "win 3 games", I was thinking of just putting quest progress in preferences until you completed the quest, but that can lead to a bunch of unwanted behaviour if you exit the game when your progress is for example 2/3.
Is there a smart way to go about this or do I just have to make a servercall and save directly into db every time you do something that can effect a daily quest?
As far as I know there is no way to do it when the user exits the app?
Is there a smart way to go about this or do I just have to make a
servercall and save directly into db every time you do something that
can effect a daily quest?
iQue, make a server call every time and validate the data they are sending you (did they really achieve what they're claiming?), users can root the device or modify the game client, so this is the only correct way to do it.
As far as I know there is no way to do it when the user exits the app?
If you want to do anything when the app is exited on Libgdx, there is again only one correct (in the spirit of Libgdx) way to do it and it's not mentioned in the other answers, as you can write this cross-platform without delving into Android/iOS specifics: override the dispose method of your main game class (ApplicationListener).
Is there a smart way to go about this or do I just have to make a
servercall and save directly into db every time you do something that
can effect a daily quest?
I'd choose server call.
As far as I know there is no way to do it when the user exits the app?
There are onPause, onDestroy methods in android. You can use SharedPreferences and when user exit the app, delete that data.
But whatever you do, never trust the client data. Always try to validate data in server.
I would save it as soon as something changes. Your server will probably be able to handle this and you don't need to mess around with platform specific stuff.
If you really want to avoid this for some reason you would have to look at the platform specific ways to execute code just before the app exits. On iOS this seems to be applicationDidEnterBackground() on Android you can use onDestroy() .