Pankti Patel
Pankti Patel

Reputation: 178

iPhone sdk : Open Default Message tones list

In my application , i want to set default system message tones for upcoming message settings. How can i open default device alertTones list.

I have tried following code, but its not returning any sound.

NSFileManager *fileManager = [[NSFileManager alloc] init];
NSURL *directoryURL = [NSURL URLWithString:@"/System/Library/Audio/UISounds"];
NSArray *keys = [NSArray arrayWithObject:NSURLIsDirectoryKey];

NSDirectoryEnumerator *enumerator = [fileManager
                                     enumeratorAtURL:directoryURL
                                     includingPropertiesForKeys:keys
                                     options:0
                                     errorHandler:^(NSURL *url, NSError *error) {
                                         // Handle the error.
                                         // Return YES if the enumeration should continue after the error.
                                         return YES;
                                     }];

for (NSURL *url in enumerator) {
    NSError *error;
    NSNumber *isDirectory = nil;
    if (! [url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:&error]) {
        // handle error
    }
    else if (! [isDirectory boolValue]) {
        [audioFileList addObject:url];
    }
}

Please Help.

Upvotes: 2

Views: 125

Answers (1)

iPhoneDev
iPhoneDev

Reputation: 228

Checked this link https://github.com/TUNER88/iOSSystemSoundsLibrary. I think are you using this reference code and its working I have tested in the iPhone. I think you were testing in the iPhone Simulator. its not working in the simulator. So, Test in the Device its working finecheck the attach image which shows the list of the system sound

Upvotes: 1

Related Questions