If you have an issue with any of our projects. feel free to register.

Commit 05f66d40 authored by Dmitry Nevedomsky's avatar Dmitry Nevedomsky

Show Album Art with UserNotification.

parent 1f3d045b
......@@ -174,6 +174,32 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
content.sound = nil;
content.categoryIdentifier = @"play";
if ([defaults boolForKey:@"notifications.show-album-art"] && [pe albumArtInternal]) {
NSError *error = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *tmpSubFolderName = [NSProcessInfo.processInfo globallyUniqueString];
NSURL *tmpSubFolderURL = [[NSURL fileURLWithPath:NSTemporaryDirectory()]
URLByAppendingPathComponent:tmpSubFolderName isDirectory:true];
if ([fileManager createDirectoryAtPath:[tmpSubFolderURL path]
error:&error]) {
NSURL *fileURL = [tmpSubFolderURL URLByAppendingPathComponent:@"art.png"];
NSImage *image = [pe albumArt];
CGImageRef cgRef = [image CGImageForProposedRect:NULL context:nil hints:nil];
NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] initWithCGImage:cgRef];
[newRep setSize:[image size]];
NSData *pngData = [newRep representationUsingType:NSBitmapImageFileTypePNG properties:@{}];
[pngData writeToURL:fileURL atomically:YES];
UNNotificationAttachment *icon = [UNNotificationAttachment attachmentWithIdentifier:@"art"
content.attachments = @[icon];
UNNotificationRequest * request = [UNNotificationRequest requestWithIdentifier:@"PlayTrack" content:content trigger:nil];
[center addNotificationRequest:request withCompletionHandler:^(NSError * _Nullable error) {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment