Skip to content
This repository was archived by the owner on Feb 5, 2025. It is now read-only.

Conversation

@Gio2018
Copy link
Contributor

@Gio2018 Gio2018 commented Jan 23, 2020

Magic Email Clients

  • Add AppSelector class, that creates an action sheet that contains a list of apps that can be called by tapping on its buttons. The specific use case are (magic) installed email clients

    • EmailClients.plist contains the URL Schemes of the currently supported email clients
    • Currently supported email clients:
      • Apple Mail (default)
      • Airmail
      • Fastmail
      • Gmail
      • Microsoft Outlook
      • Spark
      • Yahoo Mail
  • Add LinkMailPresenter, that presents the action sheet on a UIViewController. If no other client is available, Apple Mail will be opened directly without presenting the action sheet

  • Add the protocol URLHandler as a generic URL handler, injected into AppSelector. UIApplication conforms to URLHandler (and it's the default to handle URL Schemes)

Related WordPress-iOS PR: wordpress-mobile/WordPress-iOS#13275

Giorgio Ruscigno added 4 commits January 22, 2020 15:26
- add AppSelector type: wraps a custom UIAlertController that contains a list of apps that can be called
- add LinkMailPresenter: uses AppSelector to present a list of available email clients. The supported clients are read from EmailClients.plist
- update NUXLinkMailViewController, to use LinkMailPresenter
…update AppSelector to sort the action list alphabetically and use WordPressAuthenticator.bundle to search EmailClients.plist
- add URLHandler protocol
- add conformance to URLHandler for URLSession to inject the dependency in AppSelector
- add AppSelectorTests.swift
@Gio2018 Gio2018 added the enhancement New feature or request label Jan 23, 2020
@Gio2018 Gio2018 added this to the 1.0.2 milestone Jan 23, 2020
@Gio2018 Gio2018 self-assigned this Jan 23, 2020
@Gio2018 Gio2018 requested review from ScoutHarris and frosty January 24, 2020 00:28
Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

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

This is looking really good! I just left some comments in the code, but nothing too major :)

* Update AppSelectorTitles: add context to localizable strings
* Update LinkMailPresenter: update message to check email, using the user's email address
@ScoutHarris ScoutHarris removed this from the 1.0.2 milestone Jan 24, 2020
@Gio2018
Copy link
Contributor Author

Gio2018 commented Feb 3, 2020

@frosty , @ScoutHarris , catching up on this after my vacation break! Please let me know if there are any other changes needed before approving it. Thanks!

Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

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

Looking good, I just have one comment about localization!

let message = NSLocalizedString("Please open your email app and look for an email from WordPress.com.", comment: "Message to ask the user to check their email and look for a WordPress.com email.")
let title = NSLocalizedString("Check your email!",
comment: "Alert title for check your email during logIn/signUp.")
let message = NSLocalizedString("We just emailed a link to ",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest using a localized string with format here, so that these strings can be combined into one – different languages may need to put the email address into a different order in the string, so it's easiest for translation if it's all together. Something like:

let message = String.localizedStringWithFormat(NSLocalizedString("We just emailed a link to %@. Please check your mail app and tap the link to log in.", comment: "blah"), emailAddress)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@Gio2018 Gio2018 requested a review from frosty February 5, 2020 17:40
Copy link
Contributor

@ScoutHarris ScoutHarris left a comment

Choose a reason for hiding this comment

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

Hey @Gio2018 .

On a real iPad (not a simulator), when tapping the Open Mail button, it crashes:

2020-02-05 14:19:10:286 WordPress[5383:3237395] 🔵 Tracked: login_magic_link_open_email_client_viewed
2020-02-05 14:19:10.293523-0700 WordPress[5383:3237395] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x1170b8a00>) of style UIAlertControllerStyleActionSheet from WordPressAuthenticator.LoginNavigationController (<WordPressAuthenticator.LoginNavigationController: 0x116093a00>). The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem.  If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'

Copy link
Contributor

@frosty frosty left a comment

Choose a reason for hiding this comment

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

Looks good! Tested on iPad, and that problem seems fixed too 👍

@Gio2018 Gio2018 requested a review from ScoutHarris February 6, 2020 15:44
Copy link
Contributor

@ScoutHarris ScoutHarris left a comment

Choose a reason for hiding this comment

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

Tested on iPad, and that problem seems fixed too

Ditto that. Thanks @Gio2018 !

@Gio2018 Gio2018 merged commit 1470051 into develop Feb 6, 2020
@Gio2018 Gio2018 deleted the feature/magic-email-clients branch February 6, 2020 17:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants