Ankita Shah Ankita Shah - 3 months ago 83
Swift Question

Open Gmail app from my app

I'm trying to send an email from my app. But what I want is if user is having Gmail app on his/her phone, then mail should be sent using it. If Gmail app is unavailable then the user should be redirected to Mailbox.

So how can I know if user contains Gmail app and how can I redirect user to it.

Thanks in advance


You need to use custom URL Scheme. For gmail application its:


If you want to compose a message there you can add more parameters to this URL:


You can determinate if any kind of application is installed using this code (just replace customURL obviously for an other apps):

NSString *customURL = @"googlegmail://";

if ([[UIApplication sharedApplication] 
canOpenURL:[NSURL URLWithString:customURL]])
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:customURL]];
  //not installed, show popup for a user or an error