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

[MM-57409] Notify error sharing on iOS #8408

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[MM-57409] Notify error sharing on iOS #8408

wants to merge 2 commits into from

Conversation

Willyfrog
Copy link
Contributor

@Willyfrog Willyfrog commented Dec 11, 2024

Ticket: MM-57409

Approach to solve it:

  1. a local notification for failure is scheduled.
  2. the device tries to share
    1. If the share action succeeds, the notification is removed from the queue
    2. if the share action is known to fail, we remove the notification and launch a new one immediately
    3. if the share action takes too long, notification kicks in and next time we remove attempts to keep trying.

Why such a complex approach:

  • iOS might kill the share action process, by having this queued notification we'll ensure the user doesn't expect it to be shared
  • iOS waits for up to 9 days for the user to come online to try and do the sharing action, while this might be fine for other apps, it goes a bit against the timing expected by our users. I set up a 5 min deadline, but we can change it to something else (bigger/smaller)
  • we don't have control on when the share action is executing

Context:

  • This is only for iOS. Since the code path is very different we can process this and I'll tackle Android as soon as possible, depending on other priorities.
  • Timeout needs to be defined.
  • The message should be reviewed. I kept a vague message for the scheduled notification since there could be a number of issues at play, but it can definitely be improved.

Pending:

  • There are no tests for this part and I'm not sure how to do them, so any pointers would be great.
  • Localization, since this is not part of the regular app, I haven't yet done any localization.
  • Android.
  • Unit testing.
  • allow users to specify their own timeout within some sensible range. This could be discussed if it makes sense.

Checklist

  • Added or updated unit tests (required for all new features)
  • Has UI changes
  • Includes text changes and localization file updates
  • Have tested against the 5 core themes to ensure consistency between them.
  • Have run E2E tests by adding label E2E iOS tests for PR.

Device Information

iOS simulator

Screenshots

CleanShot 2024-12-11 at 15 58 03@2x

Release Note

Improved error notification when sharing on iOS

@Willyfrog Willyfrog added 2: Dev Review Requires review by a core commiter 2: UX Review Requires review by a UX Designer labels Dec 11, 2024
@Willyfrog Willyfrog self-assigned this Dec 11, 2024
@Willyfrog Willyfrog added the 2: PM Review Requires review by a product manager label Dec 11, 2024
@Willyfrog Willyfrog requested a review from esethna December 11, 2024 15:02
Copy link
Contributor

@enahum enahum left a comment

Choose a reason for hiding this comment

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

Additionally, what happens when:

  1. The use taps on the notification that was presented.
  2. The user has the application opened when the notification triggers
  3. Tap on the notification inside the app as shown in 2.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why the changes on this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove them, they were added by mistake

Comment on lines +187 to +194
if let timeout = data.failTimeout, timeout < Date() {
backgroundSession?.invalidateAndCancel()
os_log(
"Mattermost BackgroundSession: postMessageIfUploadFinished session %{public}@ timed out",
session.configuration.identifier ?? "no identifier"
)
return
}
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this be done after checking if the last file was actually uploaded? because if that is the case, this is cancelling the whole thing instead of just posting the message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup! The reason is that we already told the user that the sharing failed due to a timeout. Since we can't control when this happens this could be a day later making things confusing. So we cancel the first opportunity we have

@@ -56,6 +61,7 @@ extension ShareExtension {
filename,
id
)
return "There was an error when trying to upload. Please try again"
Copy link
Contributor

Choose a reason for hiding this comment

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

before the other two returns you added a notifyFailureNow call, but not here, why?

)
}
}

// TODO: setup some configuration for allowing users to figure out the right ammount of time to wait.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should allow the user to set this, we should come up with a number that makes sense.. maybe an hour or so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's cool with me too. O just didn't feel entitled to make a decision on either option

Comment on lines +62 to +63
let NETWORK_ERROR_MESSAGE: String = "Mattermost App couldn't acknowledge the message was posted due to network conditions, please review and try again"
let FILE_ERROR_MESSAGE: String = "The shared file couldn't be processed for sharing"
Copy link
Contributor

Choose a reason for hiding this comment

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

Ideally this would be localized. You can check the code in the Share Extension around the Views on how is done with the use of NSLocalizedString or String.localizedString.


func scheduleFailNotification(timeout: Double = SHARE_TIMEOUT, description: String = NETWORK_ERROR_MESSAGE) -> String {
let failNotification = UNMutableNotificationContent()
failNotification.title = "Share content failed"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should also be localized.

@Willyfrog
Copy link
Contributor Author

Additionally, what happens when:

  1. The use taps on the notification that was presented.
  2. The user has the application opened when the notification triggers
  3. Tap on the notification inside the app as shown in 2.

for 1 and 3, it opens the app.
2 is not showing, seems I need to also handle the local notification within the app, right? I'll work on that next as well as the translations and update the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2: Dev Review Requires review by a core commiter 2: PM Review Requires review by a product manager 2: UX Review Requires review by a UX Designer release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants