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.
From the Home screen, tap the Apps icon (in the QuickTap bar) > the Apps tab (if necessary) > Google folder > Gmail or tap Google folder > Gmail on the Home screen.
Clear your browser cache To test this, try to clear your browser's cache and cookies. Here's how to clear your cache and cookies in Chrome, for example, and if you're using an iPhone, uninstall the Gmail app and then reinstall it from the App Store.
Any web browser—Go to mail.google.com. and choose Gmail. Android devices—Install and open the Android app.
Add Gmail to your dock To easily open Gmail, add the app to your dock: Tap and hold the Gmail app . Drag the Gmail app down, and release it on your dock.
As explained here, if you're on iOS9+, don't forget to add googlegmail
to LSApplicationQueriesSchemes
on your info.plist
Then, you can do the same as the accepted answer (below is my swift 2.3 version):
let googleUrlString = "googlegmail:///co?subject=Hello&body=Hi" if let googleUrl = NSURL(string: googleUrlString) { // show alert to choose app if UIApplication.sharedApplication().canOpenURL(googleUrl) { if #available(iOS 10.0, *) { UIApplication.sharedApplication().openURL(googleUrl, options: [:], completionHandler: nil) } else { UIApplication.sharedApplication().openURL(googleUrl) } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With