skip to Main Content

I am trying to open Apple’s Mail app from my application and I am running this code:

   let mailURL = URL(string: "message://")!
   if UIApplication.shared.canOpenURL(mailURL) {
       UIApplication.shared.open(mailURL, options: [:], completionHandler: nil)
   }

However, UIApplication.shared.canOpenURL(mailURL) line returns false. This code actually working well on my other application but not working on this. Do you have any ideas what is the reason for this issue?

edit: I tried to run this both in the simulator and real device.

edit: using Xcode 12.5.1, Big Sur 11.6

2

Answers


  1. Use mailto for the URL’s protocol, not message.

    Example:

    mailto://[email protected]
    
    Login or Signup to reply.
  2. For security reasons, Apple doesn’t allow you to open URLs with arbitrary schemes, only those that you have registered to (so when they review your code they can figure out what applications you are checking for and reject you. Checking for mail is fine because everyone has that).

    But Apple wouldn’t allow you to check if my app is installed on a device.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search