I am trying to build up a Contact Us View in one iOS project, What I am trying to do is:
Put a Text Viewin a view controller, which will capture and save users' writing.
If users press send button, the view controller will send the Email or message to customer service. How to implement this or any SDK recommended?
Thanks in advance.
MFMailComposeViewController is fully dedicated for this. it has built in what you are trying to make. So don't write code to take this hassle. Let Apple do it for you. :)
place the uitextview on the storyboard, create an IBoutlet for your textview, and implement the uitextview delegate methods.
You can then use "shouldChangeTextInRange" to determine if the user has pressed enter.
You are going to need to hit a backend API to then send off the data through your mail server. if you don't have a backend server where you can code up a seamless email sending program, you can open up the mail app by using something like this:
let email = "foo#bar.com"
if let url = URL(string: "mailto:\(email)") {
UIApplication.shared.open(url)
}
Related
I am working iOS swift project. I want to send a mail with app itself. When the user clicks the submit button inside the app the mail needs to send in background or pop will be present inside the app without navigating into the mail composer.
if MFMailComposeViewController.canSendMail() {
let mail = MFMailComposeViewController()
mail.mailComposeDelegate = self
mail.setToRecipients([ApplicationModel.sharedInstance.mailAddress])
mail.setSubject("Feedback: \(UserDefaults.Id)")
mail.setMessageBody(sendBpodyMessage(), isHTML: false)
present(mail, animated: true)
} else {
if let emailUrl = createEmailUrl(to: ApplicationModel.sharedInstance.mailAddress,
subject: "Feedback", body: sendBpodyMessage()) {
UIApplication.shared.open(emailUrl)
}
}
I refer so many answers that all were saying there is no way and apple did not have this feature. Is it possible or any other way Folks?
Most of them said to use API send into the own server. I will try it if I don’t have any option related to the above question.
Apple will not allow you to send email from the user's account without displaying a mail composer window to the user (for security reasons.) You will have to implement your own mail sending mechanism from your server if you want this (and still won't be able to send email from the user's account.)
It's not that "Apple does not have this feature." It's that it would be a huge security hole. Apple explicitly blocks third parties from sending emails from the user's account except using a mail composer, and WILL NEVER ALLOW IT.
Think about the potential for abuse if it was allowed. A spammer could release a "trojan horse" app like "flappy bird" for free: A fun, popular game. Millions of people download it. Unbeknownst to them, it starts sending out emails from their accounts, attempting to defraud their friends, or the online community at large
How to detect in which app my custom keyboard used and show different button?
E.g. in Twitter I would add # to string I post into input field and in Reddit /r/
It is possible through following code. As you'll get bundle identifier of the app where you're using your custom keyboard.
Swift
let hostBundleID = self.parentViewController!.valueForKey("_hostBundleID")
let currentHostBundleID = String(hostBundleID)
print(currentHostBundleID);
From bundle identifier you can find app name easily.
Edit: See above. Things have changed.
This is not possible. An extension runs sandboxed and is only fed information from the API and cannot access anything else. The keyboard can only receive text context changes and activate/deactivate calls. Being able to detect an app lies outside of the extension sandbox and therefore is impossible.
Hello I have a custom URL to open an app with a link. It works in the browser. But I want to send an email that another user can click the link in the email and the app will be started. Does anybody know a solution?
It is not possible to send an email with the link (myApp://). It always shows the the link as blank text.
Or does anyone know another solution to transfer data between an app to a other users app?
I think you need to write the link in href html tag
i.e. open my app
another solution is to try to add any text after the double slash i.e. myApp://open
I'm building an internal app. I want to be able to press a button, and have the app automatically send a predefined email message to a specified email address, without the user knowing. I have access to a web-server, but I'm just not quite sure on what the best way to go about doing this is.
I'm using storyboard in xcode, this is a singleview application for the ipad.
Any suggestions are greatly appreciated.
You can create a PHP script that can do this (code below). Use a library such as ASIHTTPRequest to post the user's email address to the script and then the script will automatically send the message.
<?php
$to = $_POST["email"]; //this is the user's address; you can replace $_POST["email"] with "user#example.com" to try it out
$subject = "Subject";
$body = "Message";
$headers = "From: Name <noreply#example.com>\r\n" . "X-Mailer: php";
if (mail($to, $subject, $body, $headers)) {
//sent
}
?>
If you want to use the user's mail account that they have set up in the mail.app - you can't do that without the MFMailComposeViewController.
Solutions are:
Use some Framework or roll your own mail solution that you or the user fills with their respective mail acc data and then send mails.
or
Write a little PHP/Ruby/Java/... script that sends a mail which you can trigger via web request (i.e. REST).
SKPSMTPMessage works well for sending emails without the need for a UI.
(Make sure you add a reference to the CFNetwork.framework in your project.)
I can launch my app if I embed a url in an SMS and then the user clicks on the url from within the message app. I have this all working.
What I would like to be able to do however is send an MMS to the device which contains a number of image(s) and text filling the screen and when the user clicks on the url within the MMS my app is launched same as it is if clicked from within an SMS.
Is it possible to mock this up so I can see it working? i.e. how could I create an MMS containing a working active link to demo a proof of concept (I'm not talking about creating an MMS programatically on iOS, just how to create one containing my app's url to send to the device)?
Edit: This answer was written under the assumption that implementation details were required for the URL handling part. I'll leave the technical details here for future Googlers.
Here is a link to a forum thread which seems to indicate you can't send MMSes from the iPhone programmatically (I know you said you didn't want to know this anyway, but it's here for completeness). The suggestion is to use a message provider's MMS gateway directly (e.g http://www.smsglobal.com).
Instructions on how to get a hyperlink into an MMS are here. You can just write it in plain text, or use an anchor: <a href="myapp://"> Not 100% sure the iPhone will properly parse those anchor tags in an MMS though.
Read this article. The gist is that you add a "URL types" row to your Info.plist and set it to any valid protocol, say myapp, and then a user opens a link in an MMS to a myapp URL. Article excerpt:
myapp://
myapp://some/path/here
myapp://?foo=1&bar=2
myapp://some/path/here?foo=1&bar=2
The iPhone SDK, when launching the application in response to any of the URLs above, will send a message to the UIApplicationDelegate.
If you want to provide a custom handler, simply provide an implementation for the message in your delegate. For example:
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
// Do something with the url here
}