changeset 2116:cdc5124b6525

Mac: Fix building on Mac after the notification image changes. Implament attaching an image to the notification on Mojave and later.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Jun 2020 08:39:44 +0000
parents 79e5842fb609
children 37060de79102
files mac/dw.m
diffstat 1 files changed, 12 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Tue Jun 23 08:13:24 2020 +0000
+++ b/mac/dw.m	Tue Jun 23 08:39:44 2020 +0000
@@ -10847,6 +10847,17 @@
                 notification.title = [NSString stringWithUTF8String:title];
                 if(description)
                     notification.body = [NSString stringWithUTF8String:outbuf];
+                if(imagepath)
+                {
+                    NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:imagepath]];
+                    NSError *error;
+                    UNNotificationAttachment *attachment = [UNNotificationAttachment attachmentWithIdentifier:@"imageID"
+                                                                URL:url
+                                                            options:nil
+                                                              error:&error];
+                    if(attachment)
+                        notification.attachments = @[attachment];
+                }
                 retval = notification;
             }
         }
@@ -10862,7 +10873,7 @@
             notification.title = [NSString stringWithUTF8String:title];
             notification.informativeText = [NSString stringWithUTF8String:outbuf];
             if(imagepath)
-                notification.contentImage = [NSImage initByReferencingFile:[NSString stringWithUTF8String:imagepath]];
+                notification.contentImage = [[NSImage alloc] initWithContentsOfFile:[NSString stringWithUTF8String:imagepath]];
             retval = notification;
         }
     }