Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ data class AndroidNotificationTapEvent (
*
* This is an internal URL that is generated using
* `NotificationOpenPayload.buildAndroidNotificationUrl` while creating the
* notification during `NotificationDisplayManager._onMessageFcmMessage`.
* notification during `NotificationDisplayManager._onNotifPayloadNewMessage`.
*
* See [notificationTapEvents].
*/
Expand Down
6 changes: 5 additions & 1 deletion ios/NotificationService/IosNotifications.g.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,22 +142,26 @@ struct ImprovedNotificationContent: Hashable {
var title: String
/// The new body to use for the notification.
var body: String
var userInfo: [AnyHashable?: Any?]


// swift-format-ignore: AlwaysUseLowerCamelCase
static func fromList(_ pigeonVar_list: [Any?]) -> ImprovedNotificationContent? {
let title = pigeonVar_list[0] as! String
let body = pigeonVar_list[1] as! String
let userInfo = pigeonVar_list[2] as! [AnyHashable?: Any?]

return ImprovedNotificationContent(
title: title,
body: body
body: body,
userInfo: userInfo
)
}
func toList() -> [Any?] {
return [
title,
body,
userInfo,
]
}
static func == (lhs: ImprovedNotificationContent, rhs: ImprovedNotificationContent) -> Bool {
Expand Down
4 changes: 4 additions & 0 deletions ios/NotificationService/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ class NotificationService: UNNotificationServiceExtension {
return
}

IosNativeHostApiSetup.setUp(
binaryMessenger: headlessEngine.binaryMessenger, api: IosNativeHostApiImpl())

// Register Flutter plugins with the headless engine.
GeneratedPluginRegistrant.register(with: headlessEngine)

Expand All @@ -61,6 +64,7 @@ class NotificationService: UNNotificationServiceExtension {
case .success(let improvedNotificationContent):
bestAttemptContent.title = improvedNotificationContent.title
bestAttemptContent.body = improvedNotificationContent.body
bestAttemptContent.userInfo = improvedNotificationContent.userInfo as! [AnyHashable : Any]
contentHandler(bestAttemptContent)

case .failure(let error): // TODO(log)
Expand Down
8 changes: 8 additions & 0 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
B32717692F6C49E5007682B1 /* IosNativeHostApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32717682F6C49E5007682B1 /* IosNativeHostApi.swift */; };
B340EB382F5B092B007AD309 /* IosNative.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = B340EB372F5B092B007AD309 /* IosNative.g.swift */; };
B34E9F092D776BEB0009AED2 /* Notifications.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = B34E9F082D776BEB0009AED2 /* Notifications.g.swift */; };
B35E11A62F484E6800DE4085 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
B378A5012F45B08F0031EFA1 /* NotificationService.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = B378A4FA2F45B08F0031EFA1 /* NotificationService.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
B3D425322F6D40C200F9AE69 /* IosNative.g.swift in Sources */ = {isa = PBXBuildFile; fileRef = B340EB372F5B092B007AD309 /* IosNative.g.swift */; };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this line is added in this commit:
0270431 notif: Setup IosNativeHostApi Pigeon API for NotificationService headless Flutter engine

But that file isn't new (or even touched) in that commit; in fact it's already present in main, added originally in 1d03e57 (#2195).

What caused this line to appear in this particular commit?

Should this line have been present all along? What's been the effect of it not being present?

B3D425332F6D40C200F9AE69 /* IosNativeHostApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32717682F6C49E5007682B1 /* IosNativeHostApi.swift */; };
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is added in this commit (same as the comment above):
0270431 notif: Setup IosNativeHostApi Pigeon API for NotificationService headless Flutter engine

But that file isn't new in that commit, or touched there; it was introduced in the previous commit:
9882e18 ios [nfc]: Move IosNativeHostApiImpl to its own Swift file

Should this line have been added in that commit? What caused it to appear in this file?

It also looks quite a lot like another line a few lines above:

               B32717692F6C49E5007682B1 /* IosNativeHostApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = B32717682F6C49E5007682B1 /* IosNativeHostApi.swift */; };

which does appear in that earlier commit. What's the effect of having both lines, instead of just the line that was added later? Should we have only one of them?

F311C174AF9C005CE4AADD72 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3EAE3F3F518B95B7BFEB4FE7 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -84,6 +87,7 @@
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B32717682F6C49E5007682B1 /* IosNativeHostApi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosNativeHostApi.swift; sourceTree = "<group>"; };
B340EB372F5B092B007AD309 /* IosNative.g.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosNative.g.swift; sourceTree = "<group>"; };
B34E9F082D776BEB0009AED2 /* Notifications.g.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifications.g.swift; sourceTree = "<group>"; };
B378A4FA2F45B08F0031EFA1 /* NotificationService.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationService.appex; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -212,6 +216,7 @@
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */,
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */,
74858FAE1ED2DC5600515810 /* AppDelegate.swift */,
B32717682F6C49E5007682B1 /* IosNativeHostApi.swift */,
B34E9F082D776BEB0009AED2 /* Notifications.g.swift */,
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */,
);
Expand Down Expand Up @@ -569,13 +574,16 @@
B34E9F092D776BEB0009AED2 /* Notifications.g.swift in Sources */,
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */,
B340EB382F5B092B007AD309 /* IosNative.g.swift in Sources */,
B32717692F6C49E5007682B1 /* IosNativeHostApi.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
B378A4F62F45B08F0031EFA1 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B3D425322F6D40C200F9AE69 /* IosNative.g.swift in Sources */,
B3D425332F6D40C200F9AE69 /* IosNativeHostApi.swift in Sources */,
B35E11A62F484E6800DE4085 /* GeneratedPluginRegistrant.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 0 additions & 10 deletions ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,3 @@ class NotificationTapEventListener: NotificationTapEventsStreamHandler {
eventSink?.success(IosNotificationTapEvent(payload: payload))
}
}

private class IosNativeHostApiImpl: IosNativeHostApi {
func setExcludedFromBackup(filePath: String) throws {
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true

var url = URL(fileURLWithPath: filePath, isDirectory: false)
try url.setResourceValues(resourceValues)
}
}
12 changes: 12 additions & 0 deletions ios/Runner/IosNativeHostApi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Flutter
import UIKit

public class IosNativeHostApiImpl: IosNativeHostApi {
func setExcludedFromBackup(filePath: String) throws {
var resourceValues = URLResourceValues()
resourceValues.isExcludedFromBackup = true

var url = URL(fileURLWithPath: filePath, isDirectory: false)
try url.setResourceValues(resourceValues)
}
}
2 changes: 1 addition & 1 deletion ios/Runner/Notifications.g.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ struct AndroidNotificationTapEvent: NotificationTapEvent {
///
/// This is an internal URL that is generated using
/// `NotificationOpenPayload.buildAndroidNotificationUrl` while creating the
/// notification during `NotificationDisplayManager._onMessageFcmMessage`.
/// notification during `NotificationDisplayManager._onNotifPayloadNewMessage`.
///
/// See [notificationTapEvents].
var dataUrl: String
Expand Down
Loading
Loading