I wish to download large file (about: 500MB) from server.
The server is implemented by us server with gRPC command that works as follows. The user request for file and then the app receives byte stream which added to file.
In Android I am using background persistent notification with service, and opening new thread on this service until the download completes. The user can exit the app and the OS will not kill persistent notification service.
What is the equivalent for background downloading for iOS. I checked the URLSessionDownloadTask but I do not think it will work with gRPC.
What is your solution for downloading big data with iOS?
Related
I am implementing PWA with a service worker, utilizing Background Sync and IndexedDB in uploading images while user is offline.
So it is working! While offline on uploading an image, nativeFile is pushed to IndexedDB and a unique tag is registered for background sync. After bringing up network to online, the background sync called my function to upload the file from indexedDB to server. That happens when my browser is open.
HOWEVER, in the scenario where uploading while being offline. Then restart the browser and go online, no background sync is triggered after opening it.
Is this how supposed background sync will work? only when browser is open? or am I doing something wrong?
I'm trying to understand how I can send my offline data to the server when the device is online.
Can this be achieved without having the user to open the app, and send the data immediately when the device is connected to the Internet in background?
One viable approach would utilise file uploads with a "background session".
What it requires is a file that represents your Core Data objects. When you have that, create a NSURLSession object with a background configuration using static function backgroundSessionConfigurationWithIdentifier(_:).
When you schedule a task with the background session, it will be executed by the system in the background, even when your app is terminated. The system only tries to download the file when it has a connection.
For more information see Using NSURLSession and Handling iOS Background Activity.
There are a few configuration options (NSURLSessionConfiguration) which may seem important in your case, too:
discretionary and sessionSendsLaunchEvents
I've been using AFNetworking 2.0 on my iOS App to regularly send HTTP requests and get data from a server and it works fine. But I needed to download a big file from time to time from this server (the same) so I decided to use NSURLSessionDownloadTask for that purpose.
The issue I have is that during a background downloading, and while my App is still in foreground, all the requests sent by the App using AFNetworking timeout.
On the server side, I can see that on the 25 simultaneous sockets that can be opened, one is taken by the background downloading and the rest is available so the server is still able to receive HTTP requests.
Any idea?
I am developing an app of feeds, that fetches feed from server and display to users for read. It working fine when app starts but i want to load data in background when is suspended or terminate(in both case). As we can create IntentService in android and with a AlarmManager we can start that service after a every fixed hours (for ex. 3 hours), so whenever user comes to online he will be able to see latest data without waiting fetch for new feeds.
I have read Background Transfer Service & NSURLSession with silent remote notification but i could not understand how this will help me to achieve my objective.
When getting a remote notification how can i resume a NSURLSessionDataTask form AppDelegate.m file because we can't use delegate there.
Please help me to sort out this issue. Googling from last 2 days but didn't get success to achieve this.
You need to use Background Fetch instead of Background Transfer. Main purpose of Background Transfer is uploading or downloading files while when app in background state.
I have web service which i want to use to upload image to the server, web service proxy classes generated by wsdl2objc it uses NSOperation to perform soap calls. Suppose during the upload process i press the home button and application enters the background mode, what will be in that case? will the upload process terminate? or process will complete anyway.
By default, the OS will freeze your app in the background. When that happens, the remote server will probably close the connection after a while because your app doesn't respond.
You can avoid that by wrapping your upload code in a background task (with the methods beginBackgroundTaskWithExpirationHandler: and endBackgroundTask:), in which case the OS will let your app run in the background for another 10 minutes to finish its work.