Skip to content

Commit

Permalink
[mail] show the alert because it cannot create mail controller on iOS…
Browse files Browse the repository at this point in the history
… 10 Simulator

On iOS 10 Simulator, "MFMailComposeViewController.alloc.init" always return nil

Then `mail_controller.mailComposeDelegate = self` raise an exception with `nil#mailComposeDelegate=` is not found.
  • Loading branch information
Watson1978 committed Sep 23, 2016
1 parent 88ca861 commit 5d266db
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions motion/mail/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def compose(options = {}, &callback)
end

def create_mail_controller(options = {})
unless can_send_mail?
controller = UIAlertController.alertControllerWithTitle("Email", message:"Cannot compose an email. Please run on device.", preferredStyle:UIAlertControllerStyleAlert)
controller.addAction(UIAlertAction.actionWithTitle:"OK",style:UIAlertActionStyleDefault, handler:@callback)
return controller
end

mail_controller = MFMailComposeViewController.alloc.init

mail_controller.mailComposeDelegate = self
Expand Down

0 comments on commit 5d266db

Please sign in to comment.