0

I am using NMSSH library to upload file to a SFTP server. The file upload works fine as long as the phone is on but whenever I close the screen or minimise the app the upload seems to fail. Can some one please help with this issue. Here is the code i have at the moment.

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            client.delegate = self;
            
            BOOL result = [client sftpUpload:filePath toPath:path];
            if (result) {
                callback(@[]);
            } else {
                if (client._uploadContinue) {
                    NSLog(@"Error uploading file");
                    callback(@[[NSString stringWithFormat:@"Failed to upload %@ to %@", filePath, path]]);
                } else {
                    callback(@[@"Upload canceled"]);
                }
            }
        });

Any help would be greatly appreciated. Thanks in advance.

dogwasstar
  • 852
  • 3
  • 16
  • 31
  • See [Choosing Background Strategies for Your App](https://developer.apple.com/documentation/backgroundtasks/choosing_background_strategies_for_your_app?language=objc). – HangarRash Nov 27 '22 at 07:00
  • I tried using the beginBackgroundTaskWithExpirationHandler but it only lasts for about 30 sec before the endBackgroundUpdateTask gets called. – dogwasstar Nov 28 '22 at 00:16

0 Answers0