powered by Jive Software

Running Smack as Background Service

I have just finished writing a basic chat app and is working fine, thanks to Smack library (and developers for sure). Now I have requirement where user can opt in settings to keep the app running even after closing the main app.

I have checked a lot of threads where Sticky service is suggested. But since Android 8 (API 26) the OS terminates such services when app goes into background, which means this suggestion does not work. And according to this old but I believe still relevant, we should avoid foreground service. Moreover, putting sticky notification required by Google for foreground is annoying.

So what is post-Oreo solution for Smack Background service?
Thank You!

,

Seems we are left with Workmanager or Foreground services. Would like to hear recommendation on what is the new normal on this one since we still have apps powered by Smack

Ref: https://stackoverflow.com/a/51239248/709683

In my limited experience the only suitable solution is a sticky foreground service.
On devices with newer Android users can disable the sticky notification if you make use of Notification Channels.

1 Like

I guess they have added support for push notifications.

https://issues.igniterealtime.org/browse/SMACK-738

Hi Shynu,
Can you explain how does this going to help resolve my issue?

Hi,
how is that possible, please explain

Which message are you referring to?

mtangoo,
The Android and IOS devices will eventually Suspend the application running in backgroud for Battery Optimization. Push Notification from Google FCM and Apple notification center will wake up the application if required.

XMPP server having device Data like “DeviceToken” will tell Google FCM which will then tell the Device OS to wake up the suspended app, and ready to receive and talk with XMPP server.

Smack Developers may have implemented these feature.
XMPP server like Openfire have recently released the Push notification plugin which may work with smack library.

Links:
https://developers.google.com/web/ilt/pwa/introduction-to-push-notifications

https://www.igniterealtime.org/projects/openfire/plugin-archive.jsp?plugin=pushnotification

2 Likes

Thank you so much for this reply. My issue is finally resolved.

This topic was automatically closed 62 days after the last reply. New replies are no longer allowed.