Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(notif): render pp in ios notif (#1722)

Sean Ayeb140bbdfcdfa
diff --git a/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist
new file mode 100644
index 0000000000..10e505a0de
--- /dev/null
+++ b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
+ <key>CFBundleDisplayName</key>
+ <string>NotificationServiceExtension</string>
+ <key>CFBundleExecutable</key>
+ <string>$(EXECUTABLE_NAME)</string>
+ <key>CFBundleIdentifier</key>
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>$(PRODUCT_NAME)</string>
+ <key>CFBundlePackageType</key>
+ <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
+ <key>CFBundleShortVersionString</key>
+ <string>$(MARKETING_VERSION)</string>
+ <key>CFBundleVersion</key>
+ <string>100</string>
+ <key>NSExtension</key>
+ <dict>
+ <key>NSExtensionPointIdentifier</key>
+ <string>com.apple.usernotifications.service</string>
+ <key>NSExtensionPrincipalClass</key>
+ <string>$(PRODUCT_MODULE_NAME).NotificationService</string>
+ </dict>
+</dict>
+</plist>
diff --git a/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationService.swift b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationService.swift
new file mode 100644
index 0000000000..edd7f5b9f2
--- /dev/null
+++ b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationService.swift
@@ -0,0 +1,156 @@
+import UserNotifications
+import Intents
+
+final class NotificationService: UNNotificationServiceExtension {
+ private var contentHandler: ((UNNotificationContent) -> Void)?
+ private var bestAttemptContent: UNMutableNotificationContent?
+
+ override func didReceive(
+ _ request: UNNotificationRequest,
+ withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void
+ ) {
+ self.contentHandler = contentHandler
+ bestAttemptContent = request.content.mutableCopy() as? UNMutableNotificationContent
+
+ guard let content = bestAttemptContent else {
+ contentHandler(request.content)
+ return
+ }
+
+ let userInfo = request.content.userInfo
+ let senderName = content.title
+
+ // Track pending downloads
+ let group = DispatchGroup()
+ var profileImageURL: URL?
+ var attachmentImageURL: URL?
+
+ let tempDir = FileManager.default.temporaryDirectory
+ .appendingPathComponent(UUID().uuidString, isDirectory: true)
+
+ do {
+ try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true)
+ } catch {
+ contentHandler(content)
+ return
+ }
+
+ // Download profile picture for left side (communication notification)
+ if let urlString = userInfo["senderProfilePictureUrl"] as? String,
+ let url = URL(string: urlString) {
+ group.enter()
+ URLSession.shared.downloadTask(with: url) { location, _, error in
+ defer { group.leave() }
+ guard error == nil, let location = location else { return }
+ let fileURL = tempDir.appendingPathComponent("profile.jpg")
+ try? FileManager.default.moveItem(at: location, to: fileURL)
+ profileImageURL = fileURL
+ }.resume()
+ }
+
+ // Download attachment image for right side
+ if let urlString = userInfo["attachmentImageUrl"] as? String,
+ let url = URL(string: urlString) {
+ group.enter()
+ URLSession.shared.downloadTask(with: url) { location, _, error in
+ defer { group.leave() }
+ guard error == nil, let location = location else { return }
+ let fileURL = tempDir.appendingPathComponent("attachment.jpg")
+ try? FileManager.default.moveItem(at: location, to: fileURL)
+ attachmentImageURL = fileURL
+ }.resume()
+ }
+
+ group.notify(queue: .main) {
+ // Add attachment image on right side if available
+ if let attachmentURL = attachmentImageURL,
+ let attachment = try? UNNotificationAttachment(
+ identifier: "attachment-image",
+ url: attachmentURL
+ ) {
+ content.attachments = [attachment]
+ }
+
+ // Add profile picture on left side via communication notification (iOS 15+)
+ if let profileURL = profileImageURL {
+ if #available(iOS 15.0, *) {
+ self.configureCommunicationNotification(
+ content: content,
+ senderName: senderName,
+ avatarURL: profileURL,
+ contentHandler: contentHandler
+ )
+ } else {
+ contentHandler(content)
+ }
+ } else {
+ contentHandler(content)
+ }
+ }
+ }
+
+ @available(iOS 15.0, *)
+ private func configureCommunicationNotification(
+ content: UNMutableNotificationContent,
+ senderName: String,
+ avatarURL: URL,
+ contentHandler: @escaping (UNNotificationContent) -> Void
+ ) {
+ // Create a unique identifier for the sender
+ let handle = INPersonHandle(value: senderName, type: .unknown)
+
+ // Load the avatar image
+ var personImage: INImage? = nil
+ if let imageData = try? Data(contentsOf: avatarURL) {
+ personImage = INImage(imageData: imageData)
+ }
+
+ // Create the sender person
+ let sender = INPerson(
+ personHandle: handle,
+ nameComponents: nil,
+ displayName: senderName,
+ image: personImage,
+ contactIdentifier: nil,
+ customIdentifier: senderName
+ )
+
+ // Create a send message intent
+ let intent = INSendMessageIntent(
+ recipients: nil,
+ outgoingMessageType: .outgoingMessageText,
+ content: content.body,
+ speakableGroupName: nil,
+ conversationIdentifier: senderName,
+ serviceName: nil,
+ sender: sender,
+ attachments: nil
+ )
+
+ // Set the sender's image for the intent
+ intent.setImage(personImage, forParameterNamed: \.sender)
+
+ // Create an interaction and donate it
+ let interaction = INInteraction(intent: intent, response: nil)
+ interaction.direction = .incoming
+ interaction.donate { error in
+ if let error = error {
+ NSLog("NotificationServiceExtension: Failed to donate interaction: \(error)")
+ }
+ }
+
+ // Update the notification content with the intent
+ do {
+ let updatedContent = try content.updating(from: intent)
+ contentHandler(updatedContent)
+ } catch {
+ contentHandler(content)
+ }
+ }
+
+ override func serviceExtensionTimeWillExpire() {
+ if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
+ contentHandler(bestAttemptContent)
+ }
+ }
+}
diff --git a/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationServiceExtension.entitlements b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationServiceExtension.entitlements
new file mode 100644
index 0000000000..28c29bf6d8
--- /dev/null
+++ b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/NotificationServiceExtension.entitlements
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>aps-environment</key>
+ <string>production</string>
+</dict>
+</plist>
diff --git a/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj b/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj
index 792d2161fd..0b2d943511 100644
--- a/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj
+++ b/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj
@@ -19,8 +19,34 @@
C6BD59C055C986EA4A77FDA2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF1DE57E7D9CF13BB2E0E038 /* Assets.xcassets */; };
C869023DDFE275D42F3FBF29 /* libapp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 39EEC6A55698228E08917A52 /* libapp.a */; };
E68F6CFDAED6503ABB4044A5 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE1209BFDECB28E00189B168 /* Metal.framework */; };
+ NSE00000001 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = NSE00000002 /* NotificationService.swift */; };
+ NSE00000003 /* NotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = NSE00000004 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
+/* Begin PBXContainerItemProxy section */
+ NSE00000005 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = A9B1B09F1872768368ACECE2 /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = NSE00000006;
+ remoteInfo = NotificationServiceExtension;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ NSE00000007 /* Embed App Extensions */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 13;
+ files = (
+ NSE00000003 /* NotificationServiceExtension.appex in Embed App Extensions */,
+ );
+ name = "Embed App Extensions";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
007E478DB8BC37A788C4730F /* app_iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = app_iOS.entitlements; sourceTree = "<group>"; };
02B7F8347F94B067E6B27396 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };
@@ -42,6 +68,10 @@
F3673D372C5ABDD1AD6E7067 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
FBC720DFA1D01F55B0A32344 /* app_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; name = app_iOS.app; path = macro.app; sourceTree = BUILT_PRODUCTS_DIR; };
FC8F21D1B3C54F48FD8FA060 /* logger.rs */ = {isa = PBXFileReference; lastKnownFileType = file; path = logger.rs; sourceTree = "<group>"; };
+ NSE00000002 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };
+ NSE00000004 /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
+ NSE00000008 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+ NSE00000009 /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -60,6 +90,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ NSE0000000A /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -122,6 +159,7 @@
AF1DE57E7D9CF13BB2E0E038 /* Assets.xcassets */,
02B7F8347F94B067E6B27396 /* LaunchScreen.storyboard */,
2867E55E70187711EE923EBD /* app_iOS */,
+ NSE0000000B /* NotificationServiceExtension */,
BAFB695BB8415511FEC74542 /* Externals */,
78CBE3E5873199C0066F12DF /* Sources */,
855775165ACE55D883F89EB3 /* src */,
@@ -141,6 +179,7 @@
isa = PBXGroup;
children = (
FBC720DFA1D01F55B0A32344 /* app_iOS.app */,
+ NSE00000004 /* NotificationServiceExtension.appex */,
);
name = Products;
sourceTree = "<group>";
@@ -154,6 +193,16 @@
path = app;
sourceTree = "<group>";
};
+ NSE0000000B /* NotificationServiceExtension */ = {
+ isa = PBXGroup;
+ children = (
+ NSE00000002 /* NotificationService.swift */,
+ NSE00000008 /* Info.plist */,
+ NSE00000009 /* NotificationServiceExtension.entitlements */,
+ );
+ path = NotificationServiceExtension;
+ sourceTree = "<group>";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -165,10 +214,12 @@
81BE6BC5B603407AF570E994 /* Sources */,
2FBCB8C3ED193E9C4A9FDB59 /* Resources */,
4825CF6C55516D374210C8E1 /* Frameworks */,
+ NSE00000007 /* Embed App Extensions */,
);
buildRules = (
);
dependencies = (
+ NSE0000000C /* PBXTargetDependency */,
);
name = app_iOS;
packageProductDependencies = (
@@ -177,6 +228,22 @@
productReference = FBC720DFA1D01F55B0A32344 /* app_iOS.app */;
productType = "com.apple.product-type.application";
};
+ NSE00000006 /* NotificationServiceExtension */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = NSE0000000D /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */;
+ buildPhases = (
+ NSE0000000E /* Sources */,
+ NSE0000000A /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = NotificationServiceExtension;
+ productName = NotificationServiceExtension;
+ productReference = NSE00000004 /* NotificationServiceExtension.appex */;
+ productType = "com.apple.product-type.app-extension";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -200,6 +267,7 @@
projectRoot = "";
targets = (
E86255CB8A1836C0BF0C0E14 /* app_iOS */,
+ NSE00000006 /* NotificationServiceExtension */,
);
};
/* End PBXProject section */
@@ -250,8 +318,24 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ NSE0000000E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ NSE00000001 /* NotificationService.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
+/* Begin PBXTargetDependency section */
+ NSE0000000C /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = NSE00000006 /* NotificationServiceExtension */;
+ targetProxy = NSE00000005 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
/* Begin XCBuildConfiguration section */
1B9D5B8D34E6E0C88D0207F2 /* release */ = {
isa = XCBuildConfiguration;
@@ -456,6 +540,64 @@
};
name = debug;
};
+ NSE0000000F /* debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = arm64;
+ CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 100;
+ DEVELOPMENT_TEAM = TY74Q77JBD;
+ GENERATE_INFOPLIST_FILE = NO;
+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALID_ARCHS = arm64;
+ };
+ name = debug;
+ };
+ NSE00000010 /* release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = arm64;
+ CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ CODE_SIGN_STYLE = Automatic;
+ CURRENT_PROJECT_VERSION = 100;
+ DEVELOPMENT_TEAM = TY74Q77JBD;
+ GENERATE_INFOPLIST_FILE = NO;
+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
+ LD_RUNPATH_SEARCH_PATHS = (
+ "$(inherited)",
+ "@executable_path/Frameworks",
+ "@executable_path/../../Frameworks",
+ );
+ MARKETING_VERSION = 1.0;
+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SDKROOT = iphoneos;
+ SKIP_INSTALL = YES;
+ SWIFT_EMIT_LOC_STRINGS = YES;
+ SWIFT_VERSION = 5.0;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALID_ARCHS = arm64;
+ };
+ name = release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -477,6 +619,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = debug;
};
+ NSE0000000D /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ NSE0000000F /* debug */,
+ NSE00000010 /* release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = debug;
+ };
/* End XCConfigurationList section */
};
rootObject = A9B1B09F1872768368ACECE2 /* Project object */;
diff --git a/js/app/tauri/src-tauri/gen/apple/project.yml b/js/app/tauri/src-tauri/gen/apple/project.yml
index 67887eedd7..f886574c33 100644
--- a/js/app/tauri/src-tauri/gen/apple/project.yml
+++ b/js/app/tauri/src-tauri/gen/apple/project.yml
@@ -70,6 +70,8 @@ targets:
EXCLUDED_ARCHS[sdk=iphoneos*]: x86_64
groups: [app]
dependencies:
+ - target: NotificationServiceExtension
+ embed: true
- framework: libapp.a
embed: false
- sdk: CoreGraphics.framework
@@ -85,4 +87,20 @@ targets:
basedOnDependencyAnalysis: false
outputFiles:
- $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a
- - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a
\ No newline at end of file
+ - $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a
+ NotificationServiceExtension:
+ type: app-extension
+ platform: iOS
+ sources:
+ - path: NotificationServiceExtension
+ info:
+ path: NotificationServiceExtension/Info.plist
+ properties:
+ CFBundleShortVersionString: 0.1.0
+ CFBundleVersion: "0.1.0"
+ settings:
+ base:
+ PRODUCT_BUNDLE_IDENTIFIER: com.macro.dev.NotificationServiceExtension
+ ARCHS: [arm64]
+ VALID_ARCHS: arm64
+ EXCLUDED_ARCHS[sdk=iphoneos*]: x86_64
\ No newline at end of file