Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-2871 Notification almost in default notification when use OIDC in iOS #2876

Merged
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
3 changes: 1 addition & 2 deletions core/lib/utils/html/html_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class HtmlUtils {

static const unregisterDropListener = (
script: '''
console.log("unregisterDropListener");
const editor = document.querySelector(".note-editable");
const newEditor = editor.cloneNode(true);
editor.parentNode.replaceChild(newEditor, editor);''',
Expand Down Expand Up @@ -76,12 +75,12 @@ class HtmlUtils {
required String base64Data,
required String mimeType
}) {
log('HtmlUtils::convertBase64ToImageResourceData:');
mimeType = validateHtmlImageResourceMimeType(mimeType);
if (!base64Data.endsWith('==')) {
base64Data.append('==');
}
final imageResource = 'data:$mimeType;base64,$base64Data';
log('HtmlUtils::convertBase64ToImageResourceData:imageResource: $imageResource');
return imageResource;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 48. View one-by-one PDF in Dart side in only Web app
# 49. View one-by-one PDF in Dart side in only Web app

Date: 2024-05-17

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 48. Notification setting
# 50. Android notification permission check

Date: 2024-06-07

Expand Down
79 changes: 79 additions & 0 deletions docs/adr/0051-push-notification-click-logic-on-ios.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# 51. Push notification click logic on iOS

Date: 2024-06-07

## Status

Accepted

## Context

On iOS, we use `Notification Service Extension` [NSE](https://developer.apple.com/documentation/usernotifications/modifying-content-in-newly-delivered-notifications) to modify email content first when displaying push notifications to users.
- In NSE we have implemented getting `new email list` based on `EmailDeliveryState` sent from FCM.
- NSE only modifies and displays 1 notification, so we will display the notification for the last email in the list via NSE (is called `RemoteNotification`).
For the remaining emails we will use [UNUserNotificationCenter](https://developer.apple.com/documentation/usernotifications/unusernotificationcenter) to automatically display notifications (is called `LocalNotification`).

## Decision

Brief the logic flows when clicking notifications:

1. Foreground/Background state

- When clicking on notifications (both LocalNotification and RemoteNotification) the `didReceive` function of `UNUserNotificationCenter` in `AppDelegate` will be called.

```swift
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {}
```

`response.notification.request.content.userInfo` is the contents of the push payload notification.
We use `FlutterMethodChannel` to pass `UserInfo` from iOS native code to Flutter dart code

```swift
self.notificationInteractionChannel?.invokeMethod("current_email_id_in_notification_click_when_app_foreground_or_background", arguments: response.notification.request.content.userInfo)
```

2. Terminated state

- With `RemoteNotification`, we will get the push notification payload through `launchOptions?[.remoteNotification]` in the `didFinishLaunchingWithOptions` function of `AppDelegate`

```swift
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {}
```

Save it in a `remoteNotificationPayload` variable in memory and use `FlutterMethodChannel` to retrieve it every time you open the app.

```swift
self.notificationInteractionChannel?.setMethodCallHandler { (call, result) in
switch call.method {
case "current_email_id_in_notification_click_when_app_terminated":
result(self.remoteNotificationPayload)
self.remoteNotificationPayload = nil
default:
break
}
}
```

- As for `LocalNotification`, we will receive the push notification payload at the `didReceive` function of `UNUserNotificationCenter` (similar to `Foreground/Background state`)

```swift
override func userNotificationCenter(
_ center: UNUserNotificationCenter,
didReceive response: UNNotificationResponse,
withCompletionHandler completionHandler: @escaping () -> Void
) {
self.remoteNotificationPayload = response.notification.request.content.userInfo
}
```

## Consequences

- The application is correctly adjusted to the detailed screen email when clicking on the notification.
- Any changes to the click push notification logic must be updated in this ADR.
2 changes: 1 addition & 1 deletion ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ SPEC CHECKSUMS:
FirebaseInstallations: 558b1da7d65afeb996fd5c814332f013234ece4e
FirebaseMessaging: e345b219fd15d325f0cf2fef28cb8ce00d851b3f
fk_user_agent: 1f47ec39291e8372b1d692b50084b0d54103c545
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_appauth: 1ce438877bc111c5d8f42da47729909290624886
flutter_downloader: b7301ae057deadd4b1650dc7c05375f10ff12c39
flutter_image_compress_common: ec1d45c362c9d30a3f6a0426c297f47c52007e3e
Expand Down
Loading
Loading