question

khurram avatar image
khurram asked Jeffrey Blattman edited

Foreground service not loading new orders properly

Hi,


we have an online ordering app and we have developed a native app which is installed in our clover devices which is listening for all new coming orders and sending them for print.

In each location we have two clover devices for each marchent again same marchent id.

to fix the duplicate printing issues we made a checkbox in our app that only that device will print order which will have checkbox enabled.

now the problem is that It’s very random that sometime one device is loading orders properly and sometimes other one. It’s very rare that both of the devices loading orders at same time. let say I have print check enabled on device A and it won’t load order and device B does then that order is never getting printed.

Please help me that what can be the problem?

Clover Android SDK
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

David Marginian avatar image David Marginian ♦♦ commented ·

You are going to need to provide a lot more specifics about how your app is working for us to provide any help. Are you relying on Clover order sync or do you send your own notifications? How is your service notified of order changes?

0 Likes 0 ·
khurram avatar image khurram David Marginian ♦♦ commented ·

We are using a foreground service which keep refreshing after every 20 seconds and once we get a new order it just send the order for printing.

But now the problem is as our app always stays in background and after some time our foreground service is getting killed and after that it never know about the new orders and we never get prints.

0 Likes 0 ·

1 Answer

·
Jeffrey Blattman avatar image
Jeffrey Blattman answered Jeffrey Blattman edited
We are using a foreground service which keep refreshing after every 20 seconds and once we get a new order it just send the order for printing.
But now the problem is as our app always stays in background and after some time our foreground service is getting killed and after that it never know about the new orders and we never get prints.

You can't guarantee that a service runs forever in Android. A possible reasonable design might be to use work manager to schedule a task that checks periodically.

There are limitations on how often tasks can be executed. For example, if you schedule periodically the minimum interval is 15 minutes. I've read you can use a one-time task, then schedule it again it finishes what whatever interval you want. In my experience, the OS will start throttling your tasks if you try to run them frequently. It's something you'll have play around with and see how it goes. Maybe you could try a hybrid where you loop with a foreground service for a short period (minutes), then schedule a task and check less frequently.


10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community