sending sms and email through program automatically - iphone

I have read that In App SMS is finally supported in iPhone OS 4...look at
here
I want to know that if it is also possible to send emails automatically without user's intraction if yes then how?.I mean while our application is running.

No, that's not possible with the official iPhone SDK.
You have to use MFMailComposeViewController or [[UIApplication sharedApplication] openURL: #"sms:12345678"]; or send a text.

Here is the code for Email
NSString *recipients=[NSString stringWithFormat:#"mailto:ABC#gmail.com?cc=bcd#gmail.com&subject=Hi"];
NSString *body=[NSString stringWithFormat:#"&body=How r u "];
NSString *email=[NSString stringWithFormat:#"%#%#",recipients,body];
email=[email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];

Related

Open Facebook i safari if the Facebook native app is not installed

I'm making an application where i would open Facebook native app from within the app.
That problem i have sold with this
NSString* urlString = #"fb://groups/";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];
But if the native app isn't installed it should open Facebook in the native safari app on the iPhone. That is my problem?
Is there anyone that could help me with that?
NSString fbURL = #"fb://group/5385407511";
BOOL canOpenURL = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:fbURL]];
if(canOpenURL) {
[[UIApplication openURL:[NSURL urlWithString:fbURL]];
} else {
[[UIApplication openURL:#"http://facebook.com"];
}
It's a very bad idea to write your app in a way which relies on Facebook's native app not changing its internal structure, your app could break at any moment.
That said, if you must do this for some reason, you can check if the Facebook app is installed by checking an fb:// URL with UIApplication's
- (BOOL)canOpenURL:(NSURL *)url

Direct "rate in iTunes" link in my app?

I've seen posts here on Stackoverflow that describe how to allow users to be directed to apps on the app store.
Is there a way to link directly to the rating and comments form in the App Store?
This IS possible using the technique described on this blog:
http://www.memention.com/blog/2009/09/03/Open-Reviews.html
basically you call UIApplication openURL with the following:
NSString* url = [NSString stringWithFormat: #"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%#", myAppID];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
To get your app ID before your app is available in the app store, use iTunesConnect to define your new app - give it a name, description, icon, screenshots, etc. Once defined, you can get the Apple ID from the Identifiers section for the app.
EDIT:
Here is a secondary url/method that works:
NSString* url = [NSString stringWithFormat: #"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=%#&pageNumber=0&sortOrdering=1&type=Purple+Software&mt=8", appid];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url ]];
I believe the difference between the two is that the first technique (itms-apps://) will launch the App Store app directly while the second one (http://) will launch it indirectly via a redirect resulting from the http web URL. This would have to be confirmed; this is only my recollection.
Answers here are outdated.
This works on my end (Xcode 5 - iOS 7 - works only on Device, not simulator!):
itms-apps://itunes.apple.com/app/idYOUR_APP_ID
For versions lower than iOS 7 use the old one:
itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID
Simple method that I am using is;
-(void)rateApp {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[#"itms-apps://itunes.apple.com/app/" stringByAppendingString: #"id547101139"]]]; }
You can also use SKStoreProductViewController as an alternative. It will open the store in your app. You may like it better than opening another app, especially on iPads.
Thanks to Ahment swift version:
UIApplication.sharedApplication().openURL(NSURL(string: "itms-apps://itunes.apple.com/app/id951334398")!)

How to open the phone call app with a given phone number to call?

I have an contacts management app where I have phone numbers stored in core data. These are represented simply as text, like +33(0)7324 65335-22. Is it possible to call this number by launching the phone app? And if yes, must I do special formatting to my number?
NSString *phoneNumber = #"+33(0)7324 65335-22";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phoneNumber]]];
I'm not sure about the "(0)"...

Sending an image in a faceless email

I am trying to send a faceless email (sending an email without showing the interface), using the code below.
I also want to attach an image to this email.
Is this possible?
- (void) sendEmailTo:(NSString *)toStr withSubject:(NSString *)subjectStr withBody:(NSString *)bodyStr
{
NSString *emailString=[[NSString alloc] initWithFormat:#"mailto:?to=%#&subject=%#&body=%#",
[toStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[subjectStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding],
[bodyStr stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:emailString]];
[emailString release];
}
You are unable to send faceless emails using the built-in emailer.
However you should be able to roll your own emailer using parts from email frameworks like for instance Pantomime

how to send e-mail without MFMailComposeViewController in iOS?

How to redirect to mail application from iPhone application?
I have seen in Stack Overflow like MailComposerViewController.
They are sending email from within the iPhone application. But I want to quit project and redirect it to in-built Mail app Which is in iPhone?
How can I do this?
I have tried the following. Are there any frameworks required for this?
- (IBAction)ddd:(id)sender
{
NSString *_recipient = #"someone#email.com";
NSURL *_mailURL = [NSURL URLWithString:[NSString stringWithFormat:#"mailto:%#?subject=My Subject", _recipient]];
[[UIApplication sharedApplication] openURL:_mailURL];
}
No, there are plenty of stackoverflow posts on how to send e-mail without MFMailComposeViewController. In fact, there was at least one response to your request 16 hours earlier that would quit your app and start Mail
Here's how I do it in my apps, copied exactly as it is:
-(IBAction) mailForHelp:(id)sender
{
NSString *urlStr = [NSString stringWithFormat:#"mailto:info#BitsOnTheGo.com?subject=NumMemorize Question"];
NSURL* mailURL = [NSURL URLWithString:[urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL: mailURL];
}