Hello!
In application I'm developing I have a requirement that user can customize push notification sounds server-side. I checked it documentation and it states that
"The sound files can be in the main bundle of the client app or in the
Library/Sounds
folder of the app’s data container."
So I'm putting sounds I download from back-end to this subfolder in Library, which I create like this:
+ (NSString *)soundFolderPath
{
NSString* path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];
path = [path stringByAppendingPathComponent:@"Sounds"];
NSLog(@"%@: Path to sounds folder: %@", [self class], path);
return path;
}
- (void)createSoundsDirectoryIfNeeded
{
NSFileManager* manager = [NSFileManager defaultManager];
NSString* path = [self.class soundFolderPath];
if (![manager fileExistsAtPath:path])
{
NSError* error = nil;
[manager createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:&error];
if (error) {
[self handleError:error];
return;
}
}
}
But when I send push notification, while app is in background - it plays default notification sound instead of a custom one. I've checked data container of the app - files exist and are in the correct folder. File format conforms to what is described in documentation and I even added those sounds as resources to bundle and that way it actually worked.
I can't find a solution to this and at this point I'm wondering if it's even possible.
Can someone help me with this?