yaqoob Active Member Licensed User Longtime User Dec 6, 2017 #1 Hi I am using mqtt for messaging in my application. I have two versions B4A and B4i. The B4i version receives the messages even if the application is running in the background and no messages are lost. B4A only receives messages if the application is running and it is in focus. The messages are lost if the application put the background and running.
Hi I am using mqtt for messaging in my application. I have two versions B4A and B4i. The B4i version receives the messages even if the application is running in the background and no messages are lost. B4A only receives messages if the application is running and it is in focus. The messages are lost if the application put the background and running.
Ricky D Well-Known Member Licensed User Longtime User Dec 6, 2017 #2 Use a service in b4a don't do it in Starter I think. You can tell the service to be sticky or set to foreground. Upvote 0
Use a service in b4a don't do it in Starter I think. You can tell the service to be sticky or set to foreground.
Erel B4X founder Staff member Licensed User Longtime User Dec 6, 2017 #3 yaqoob said: The B4i version receives the messages even if the application is running in the background and no messages are lost Click to expand... There is no such thing. The OS will kill your app after a few minutes. You should use a foreground service with a partial lock. Upvote 0
yaqoob said: The B4i version receives the messages even if the application is running in the background and no messages are lost Click to expand... There is no such thing. The OS will kill your app after a few minutes. You should use a foreground service with a partial lock.
yaqoob Active Member Licensed User Longtime User Dec 6, 2017 #4 Erel said: There is no such thing. The OS will kill your app after a few minutes. You should use a foreground service with a partial lock. Click to expand... Hi Erel, Can you please provide an example. Upvote 0
Erel said: There is no such thing. The OS will kill your app after a few minutes. You should use a foreground service with a partial lock. Click to expand... Hi Erel, Can you please provide an example.
Erel B4X founder Staff member Licensed User Longtime User Dec 6, 2017 #5 There are many related discussions: https://www.b4x.com/android/forum/pages/results/?query=service.startforeground Upvote 0
There are many related discussions: https://www.b4x.com/android/forum/pages/results/?query=service.startforeground
yaqoob Active Member Licensed User Longtime User Dec 6, 2017 #6 Erel said: There are many related discussions: https://www.b4x.com/android/forum/pages/results/?query=service.startforeground Click to expand... I am using the foreground services as below code, but the application loses messages during it is in the background. Private Sub client_MessageArrived (Topic As String, Payload() As Byte) If IsPaused(Chat)=True Then snotif.Initialize snotif.Icon = "logo.png" snotif.Sound = False snotif.Vibrate=False snotif.OnGoingEvent=False snotif.Notify(1) Service.StartForeground(1,snotif) snotif.AutoCancel = True ..... .... Upvote 0
Erel said: There are many related discussions: https://www.b4x.com/android/forum/pages/results/?query=service.startforeground Click to expand... I am using the foreground services as below code, but the application loses messages during it is in the background. Private Sub client_MessageArrived (Topic As String, Payload() As Byte) If IsPaused(Chat)=True Then snotif.Initialize snotif.Icon = "logo.png" snotif.Sound = False snotif.Vibrate=False snotif.OnGoingEvent=False snotif.Notify(1) Service.StartForeground(1,snotif) snotif.AutoCancel = True ..... ....
Erel B4X founder Staff member Licensed User Longtime User Dec 7, 2017 #7 The whole point of push notifications is that you don't need to run your app for the message to arrive. The app will start automatically (the relevant service). If it doesn't work for you then you haven't configured it correctly. Upvote 0
The whole point of push notifications is that you don't need to run your app for the message to arrive. The app will start automatically (the relevant service). If it doesn't work for you then you haven't configured it correctly.