Please help to solve the issue of sending invites to the app via SMS or iMessage.
The issue is that when all the receipents of the message have iMessage available (blue button), then upon invitation sending a group consisting of these people gets created, but I need to send the messages separately (not in group).
if MFMessageComposeViewController.canSendText() {
let messageViewController = MFMessageComposeViewController()
messageViewController.body = "Some invite text"
messageViewController.recipients = [phone_numbers_from_contacts]
messageViewController.messageComposeDelegate = self
self.present(messageViewController, animated: true, completion: nil)
} else {
// Some alert with text "SMS services are not available"
}
AFAIK you have no control over whether the message is sent as a group message or not.
If you want to send it as individual messages then I would suggest using multiple different instances of the MFMessageComposeViewController.
TBH though, you shouldn't really be using this for sending out spam texts anyway.
Related
i build a register form for my app and i need to send the user a verifiation code by sms in order to complete the registration proccess.
i tried to use MFMessageComposeViewController but its open the dialog sms on the device so the user can see the code.
i also checked the web for 3party of sending sms but there is a problem with the country code. i know its posible becuse whatsapp do it to confirm the user.
what it the right way to do it?
this is the topic the i tried:
Sending SMS in iOS with Swift
The best way to achieve this is by creating some views for allowing the user to enter the phone number with the country code which can be used by a server to send a request for initiating the OTP verification. To achieve this you need to:
Create View Controllers.
Upload Phone Number and Country code to the server.
Validate the requests by verifying the OTP.
As mentioned by Dan, you can use Digits in Fabric for that purpose, and create custom views for a great UX.
On the other hand, you can also use a service called as SendOTP from MSG91 - you can use it for internal testing and development ideas as they provide you with 5,000 free OTP SMS. The service has a complete set of APIs which you can implement on the backend as well on the app front. Also, they provide a framework so that you don't need to create the views, but only presentViewController and call delegate methods for knowing what happened during the verification process - such as Cancelled or Verified or Failed.
Swift implementation of the same looks like this:
class OTPFrame: UIViewController, sendOTPAuthenticationViewControllerDelegate {
func loadOTPFramework() {
SendOTP.sharedManager().startWithApiId("yourAppID")
let frameworkPath: NSString = NSBundle.mainBundle().privateFrameworksPath!
let frameworkBundlePath: NSString = frameworkPath.stringByAppendingPathComponent("SendOTPFramework.framework")
let frameworkBundle : NSBundle
= NSBundle(path: frameworkBundlePath as String)!
let authenticationViewController: AuthenticationViewController = AuthenticationViewController(nibName: "AuthenticationViewController", bundle: frameworkBundle)
authenticationViewController.delegate = self self.presentViewController(authenticationViewController, animated: true, completion: nil)
}
func authenticationisSuccessfulForMobileNumber(mobNo: String!, withCountryCode countryCode: String!) {
print("Success")
}
func canceledAuthentication() {
print("Cancelled")
}
func authenticationisFailedForMobileNumber(mobNo: String!, withCountryCode countryCode: String!) {
print("Failed")
}
}
Disclaimer: I, in no way, endorse the services mentioned above - you are free to choose whatever you like.
Thank You!
I would give digits a try! It's part of the Twitter Fabric package and it's very simple to use. The user enters their phone number and Fabric takes care of validating the number.
A client of mine is having an issue where he'll use our app to send an email with an auto generated PDF that's attached to the email and sometimes it will work and sometimes it will not.
Things We've noticed:
When sending from his gmail account, it typically fails and the email is sent out with a blank message and an attachment that reads 'noname'.
Sometimes, when selecting his personal email, the app still sends the email from his gmail account. I was able to reproduce this on an iPad Pro and can verify that when I select one email, it shows it was sent from another.
Removing the gmail account from the iPad and readding it back usually
fixes the problem for the first email sent and then it goes back to
the normal problem stated in the first bullet.
Here is the code where I create the MailComposer view:
func configureMailComposeViewController() -> MFMailComposeViewController {
let mailComposerViewController = MFMailComposeViewController()
mailComposerViewController.mailComposeDelegate = self
if let fileData = NSData(contentsOfFile: GeneratePDF.attachEachPage()) {
mailComposerViewController.setSubject(Constants.EmailPreferences.subject)
mailComposerViewController.setMessageBody(Constants.EmailPreferences.message, isHTML: true)
mailComposerViewController.addAttachmentData(fileData, mimeType: "application/pdf", fileName: "overview")
}
return mailComposerViewController
}
The view opens up no problem, There's a title, body message, and an attachment. Yet, when received everything's been stripped except the title. The PDF is < 6MB and only has 5 pages.
I have an option to "invite all" in my device contacts email to use my iOS application through MFMailComposeViewController. Its working fine right now. But i want to know the limitation of recipients can allow in a single mail from Apple. Herewith i added the code to send mails. Here contactList is an array. Assume like this array contains more than 2000 email id's.
#IBAction func act_InviteAllInContacts(sender: AnyObject)
{
var contactList : NSMutableArray = NSMutableArray()
contactList = addressBookClassObj.getContactNames()
var picker = MFMailComposeViewController()
picker.mailComposeDelegate = self
picker.setSubject("APPLICATION NAME")
picker.setMessageBody("Hi! Checkout this app https://itunes.apple.com/us/app***********", isHTML: true)
picker.setToRecipients(contactList as [AnyObject])
presentViewController(picker, animated: true, completion: nil)
}
Need advice: is it possible to send mails to all the recepient or message will be failure.
Apple's documentation does not refer to any limitation.
However, this is a VERY BAD practice to send an email to 2000 recipient!
You might be denied by your email provider
You might be black listed for spam
If you put your recipient list anywhere else than in the Bcc field (setBccRecipients:), everyone will have access to every email address in your list.
To send that amount of messages, you should really consider to use a Mailing Tool such as Mailchimp.
TL;DR: There might be no limitation, but please don't do that !
I'm having some trouble with Quickblox chat. Whenever two users are both logged in and both joined in the same chat room, messages that are sent between the two users are not marked as read. When I back out of the room to the dialogs list and the dialogs are refreshed, it says that there are unread messages even though I was in the room and I was receiving the messages live.
Is there a certain call that I must make to let it be known that the received messages should be marked as read? I am developing in iOS.
Thanks.
User has to read message to mark it as read
NSString *dialogID = #"53d10eede4b02f496c21549f";
NSArray *mesagesIDs = #[#"53aabe15e4b077ddd43e7fd3", #"53aabe15e4b077ddd43e7fd7"];
[QBChat markMessagesAsRead:mesagesIDs dialogID:dialogID delegate:self];
In iOS you can use:
QBRequest.markMessagesAsRead(Set<String>?, dialogID: String, successBlock:
{
(QBResponse) in code
})
{
(QBResponse) in code
}
Is it possible to send an automatically generated email using my own email address to another email address of mine by clicking a button?
I tried to use MFMailComposeViewController but another view appeared. Can I do it without this view?
You can do it only by creating own server-side mailer. On button clicking you have to send request with all needed data (email address, body, subject, etc) and server will send mail.
If You want send directly from app - MFMailComposeViewController is the only LEGAL way
By default in iOS you can only use the MFMailComposeViewController, which uses the user's mail account. Therefore you cannot send fully automated mail messages (the user allways has to confirm/cancel).
libMailCore is a great iOS framework which allows you to generate and send mails without any user interferance. In that case you'll be using your own server/credentials (thus not the user mail account). There are apps in the App Store using mailcore, so i would guess it's legit.
Yes there is a way using Swift-SMTP.
Send email
Create a Mail object and use your SMTP handle to send it. To set the sender and receiver of an email, use the User struct:
let drLight = Mail.User(name: "Dr. Light", email: "drlight#gmail.com")
let megaman = Mail.User(name: "Megaman", email: "megaman#gmail.com")
let mail = Mail(
from: drLight,
to: [megaman],
subject: "Humans and robots living together in harmony and equality.",
text: "That was my ultimate wish."
)
smtp.send(mail) { (error) in
if let error = error {
print(error)
}
}