Latest Post

Show progress of the task using SwiftUI ProgressView Flutter Vs React Native which is better? How to adjust SwiftUI text alignment

 Swift Network Service call When internet is turned on ‘

Today We going to start with as Concept call of network service While internet is turn On.
Whenever the user turn Off the internet or wifi is connectivity is not available the App behave Static thus we need to give the popup of network connection to the user . As he turn On’s the internet the user need’s to refers the Screen of the Application Which reduce the User Experience.
whenever We use the URLSession  to make the Service call to get the Data response from the Api’s .if the user has disconnected the Internet the network throws the error. However if we Use the WaitConnectivity in the URLSession  and configuring it with true the network waits for Sometimes and call the Service.

Here We can Create the Wait Connectivity Service

let config = URLSessionConfiguration.default

config.waitsForConnectivity = true

URLSession(configuration: config).dataTask(with: "") { data, response, error in

    if let error = error {



    // use your data here

We can Also use the Default Session timeOut using the following code
public let k_DEFAULT_REQUEST_TIMEOUT = 180.0

let config = URLSessionConfiguration.default

config.timeoutIntervalForRequest = k_DEFAULT_REQUEST_TIMEOUT

URLSession(configuration: config).dataTask(with: "") { data, response, error in

    if let error = error {



    // use your data here

By this we can add the Wait for Connectivity session for the service call or wait session for the particular time interval

Leave a Reply

Your email address will not be published.