diff --git a/Fastmate.xcodeproj/project.pbxproj b/Fastmate.xcodeproj/project.pbxproj index 83d2337..35361fe 100644 --- a/Fastmate.xcodeproj/project.pbxproj +++ b/Fastmate.xcodeproj/project.pbxproj @@ -348,7 +348,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 5RNJHF933P; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = Fastmate/Info.plist; @@ -375,7 +375,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1; + CURRENT_PROJECT_VERSION = 2; DEVELOPMENT_TEAM = 5RNJHF933P; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = Fastmate/Info.plist; diff --git a/Fastmate/Fastmate.js b/Fastmate/Fastmate.js index 035e1b5..fc5719f 100644 --- a/Fastmate/Fastmate.js +++ b/Fastmate/Fastmate.js @@ -129,7 +129,7 @@ Notification = function(title, options) { ++notificationID; var n = new originalNotification(title, options); Object.defineProperty(n, "onclick", { set: function(value) { Fastmate.notificationClickHandlers[notificationID.toString()] = value; }}); - window.webkit.messageHandlers.Fastmate.postMessage('{"title": "' + title + '", "options": ' + JSON.stringify(options) + ', "notificationID": ' + notificationID + '}'); + window.webkit.messageHandlers.Fastmate.postMessage('{"title": ' + JSON.stringify(title) + ', "options": ' + JSON.stringify(options) + ', "notificationID": ' + notificationID + '}'); return n; } diff --git a/Fastmate/WebViewController.m b/Fastmate/WebViewController.m index fe505bb..faf030e 100644 --- a/Fastmate/WebViewController.m +++ b/Fastmate/WebViewController.m @@ -302,7 +302,11 @@ - (void)copyURLToPasteboard:(NSURL *)URL { } - (void)postNotificationForMessage:(WKScriptMessage *)message { - NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[message.body dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil]; + NSError *error = nil; + NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[message.body dataUsingEncoding:NSUTF8StringEncoding] options:0 error:&error]; + if (error) { + NSLog(@"Failed to decode notification with body: %@. Error: %@", message.body, error); + } [NotificationCenter.sharedInstance postNotificationWithIdentifier:[dictionary[@"notificationID"] stringValue] title:dictionary[@"title"]