问题
My iOS application includes sending emails as part of its functionality. MFMailComposeViewController
allows in-app composition of an email, with the OS using Mail.app in the background to send the message. However, I want to allow users to send an email with the Gmail app for iOS if they so choose.
Since remote view controllers aren't public API, the only way this would be possible is with a URL handler, but I couldn't find one documented online anywhere. Does anyone know of one? If there is one, is it publicly acknowledged by the Gmail team (i.e. do they consider it public API, or are they using it only between Chrome and Gmail and aren't quite ready to take the wrapping paper off)?
回答1:
Silly me, I didn't finish doing my research. Once I opened up the Gmail app's .ipa and found googlegmail
as a listed CFBundleURLTypes
in the Info.plist
, the web turned up a few great resources for this:
- Finding the Gmail URL scheme for iOS
- Finding the Gmail URL scheme for iOS: Part 2
- handleOpenURL: Shared Interapp Communication! has a searchable list of URL handlers.
Long story short, this worked on my iPhone 5 running iOS 7.0 and Gmail for iOS v2.4.1, and opened a compose pane in the Gmail app, even when the app had been explicitly killed:
googlegmail:///co?subject=Hello&body=Hi
I'm still looking for confirmation that this is considered a public API of Gmail. Does anyone have any knowledge about how the Gmail team feels about this?
来源:https://stackoverflow.com/questions/19281933/is-there-a-url-handler-for-gmail-for-ios-to-compose-a-message