4

Scenario 1. I used this code for downloading files from Dropbox using Dropbox SDK.

-(void)downloadFile:(DBMetadata*)file
{
    if (!file.isDirectory)
    {
        NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *localPath = [documentsPath stringByAppendingPathComponent:file.filename];

        [[self restClientForDownload] loadFile:file.path intoPath:localPath];

    }

}

Scenario 2. Whenever I want to play the songs from Documents directory. it won't play when iPhone is getting Password Locked. Current song also stopped with in fraction of seconds.

iTag
  • 409
  • 3
  • 19
  • You want to proceed playing audio when your app goes to background? – Volker Mar 03 '14 at 19:19
  • ya.. i want to proceed playing audio or download the files from cloud. but i need to access the documents directory when iPhone locked? @Volker – iTag Mar 03 '14 at 19:28
  • Is background modes turned on? – danh Mar 03 '14 at 19:31
  • ya. i turned on it XCODE -> CAPABILITIES-> under Background modes. The options i checked 1. Audio&airplay,2.BackgroundFetch – iTag Mar 03 '14 at 19:32
  • 1
    Sounds like the file was saved with the `NSFileProtection` attribute set to `NSFileProtectionComplete`. – Austin Mar 03 '14 at 19:51
  • Ya. I tired with Data Protection in Xcode. I used the Attributes like NSFileProtectionComplete. Whenever I download the files from cloud, I set this Attribute to that particular file. But it also won't Work. @Austin – iTag Mar 04 '14 at 04:38
  • @Ranjith http://stackoverflow.com/questions/15425968/play-video-in-background-using-avplayer try this – ChenSmile Mar 04 '14 at 04:50
  • This issue was Fixed with help of NSFileProtection API. Thanks @Austin – iTag Nov 06 '14 at 04:45

1 Answers1

1

It's not possible. However, you can "prevent" your phone from locking when your app is running. [UIApplication sharedApplication].idleTimerDisabled = YES should do it.

Sishu
  • 1,510
  • 1
  • 21
  • 48
  • I tired this not working when phone is getting locked. If i downloading any content using nsurl session & playing any songs from documents directory. @Bullet Raja – iTag Apr 07 '14 at 06:51
  • if u r using the these kind of task then phone will not locked till ur app is open and u can access ur document directory easily once u have done just set [UIApplication sharedApplication].idleTimerDisabled = NO – Sishu Apr 07 '14 at 06:52