Can we create a background service?

9 posts, 0 answers
  1. TonyG
    TonyG avatar
    239 posts
    Member since:
    Feb 2006

    Posted 04 Dec 2014 Link to this post

    I'm a long-time Telerik user, just getting started with the Platform. It looks like questions about background processes, services, etc go back to Icenium. But I don't see anything recent on the topic.

    What's the latest on this? Is there an example of a project created with AppBuilder which continues to run in the background on a device after another application has taken the foreground? An example would be a chat app that continues to poll for new inbound messages, updating the Notification area when a message is available. Or an app to log the changing GPS location while another app is running.

    Would such a solution be cross-platform, or do we need three code sets to support Android, iOS, and WindowsPhone?

    Would this require NativeScript?

    Thanks.
  2. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 09 Dec 2014 Link to this post

    Hi TonyG,

    Thank you for bringing the issue.

    Unfortunately, at this stage we do not have such examples. Nevertheless, this is something that we will definitely consider for the near future.

    What I can suggest you, is to check this forum thread, where a working sample about integrating the BackgroundGeoLocation plugin is provided. As for developing a background service as a whole, I believe there is no plugin that unites the approaches for all the platforms (iOS, Android and WP). Still, you can look at this article about Background Fetch in order to implement this on iOS. For Android, I would suggest this stackoverflow thread, where most of the possible plugins are listed.

    With the above said, I believe the answer to you second question depends a lot on the requirements of the background service. In other words, the solution can be cross-platform, sharing one code base for basic, or already developed scenarios (like the GeoLocation). Still for more complicated background tasks you may need different code sets.

    Finally, this won't require NativeScript, as you should be able to achieve the functionality in hybrid application with the help of custom plugins that utilize the needed native parts.

    I hope this helps.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  3. Tayger
    Tayger avatar
    61 posts
    Member since:
    Jan 2015

    Posted 06 Jun in reply to Kaloyan Link to this post

    While checking background services in general I stumbled into this thread. This post was started in 2014 then I saw the sentence "Nevertheless, this is something that we will definitely consider for the near future." from Kaloyan. Did something happen in between? I also checked Teleriks base for background services but couldn't find all I need:

    - Getting GPS coordinates in background
    - Using a third party service for pub/sub (sending/receiving messages) in backgroun

    Is there already a "universal" solution (NativeJS, Cordova Plugin) that could meet these requirements? I need it for an App built with Javascript. 

    Regards

  4. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 09 Jun Link to this post

    Hi Tayger,

    I think that you can benefit from the latest and most stable implementation of the Cordova Background GeoLocation plugin. It is capable of executing a callback function on iOS and WP devices in order to send data to the server. As for Android, the data is synced automatically.

    About receiving messages on the device while the app is in the background, you can use Push Notifications, as explained here. This will also allow you to execute certain login in the background after such notification is received on the device.

    I hope this helps.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  5. Tayger
    Tayger avatar
    61 posts
    Member since:
    Jan 2015

    Posted 10 Jun in reply to Kaloyan Link to this post

    Thank you for your answer! Background Geolocation is truly an option. Concerning Push Notification I probably can't use it for my idea. I need to handle the received (technical) messages in background inside the App. That can be solved by a realtime network service. I will find a way... 
  6. Kaloyan
    Admin
    Kaloyan avatar
    872 posts

    Posted 15 Jun Link to this post

    Hi Tayger,

    I am happy my suggestions have helped. Please, let us know if we can be of further assistance.

    Regards,
    Kaloyan
    Telerik
     

    Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

     
  7. Kaminszakr
    Kaminszakr avatar
    3 posts
    Member since:
    Jul 2016

    Posted 19 Jul Link to this post

    Try to start the service in separate thread, so that when you will destroy your activity the service will not be affected. It will run without any interruption. Also, in the service return Service.START_STICKYfrom onStartCommand(intent, flags, startId) to make sure that the service is re-created if it is killed by the system
  8. Kaminszakr
    Kaminszakr avatar
    3 posts
    Member since:
    Jul 2016

    Posted 19 Jul Link to this post

    Try to start the service in separate thread, so that when you will destroy your activity the service will not be affected. It will run without any interruption. Also, in the service return Service.

  9. Barak
    Barak avatar
    1 posts
    Member since:
    Aug 2016

    Posted 12 Aug Link to this post

    Very interesting suggestion. Thank you...
Back to Top