How to Detect internet connection of device in Background for both android and iOS(App closed or killed)

Satya 160 Reputation points
2024-10-11T13:10:05.9+00:00

Actually i am saving user data(using Sqlite) in offline mode and whenever device connects to internet a service or task should run the job and sent the offline data through the APII have tried shiny.net jobs and that works only for foreground.

Can anyone please help me on this and share any examples

@Anonymous @Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) @Yonglun Liu (Shanghai Wicresoft Co

Thanks in advance

Developer technologies .NET .NET MAUI
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 77,686 Reputation points Volunteer Moderator
    2024-10-11T16:56:07.86+00:00

    did you read the docs? background tasks are run on the whim of the o/s.

    https://developer.apple.com/documentation/backgroundtasks/choosing-background-strategies-for-your-app

    https://developer.android.com/topic/libraries/architecture/workmanager

    trying putting the device on the charger and see if your background task runs.


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.