How to invokeE-mail application by code in ios system? I want to check email interface rather than sending mail interface.
Thanks.
You could make use of this:
- (void)launchMailAppOnDevice
{
NSMutableString *subject = [NSMutableString string];
[subject appendString:#"Your Subject"];
NSMutableString *mailbody = [NSMutableString string];
[mailbody appendString:#"Blah Blah Blah"];
[mailbody appendString:#"Blah Blah Blah "];
NSString *recipients = [NSString stringWithFormat:#"mailto:test#test.com?&subject=%#!",subject];
NSString *body = [NSString stringWithFormat:#"&body=%#!",mailbody];;
NSString *emailString = [NSString stringWithFormat:#"%#%#", recipients, body];
emailString = [emailString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
If you want to check whether mail app is present int app and you want to open it.
if ([[UIApplication sharedApplication] canOpenURL:[ NSURL URLWithString:#"mailto:"]])
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"mailto:"]];
MFMailComposeViewController is an official API that you can use to compose messages from within your app.
I've heard you can use the "mailto:" URL scheme to open the Mail application and compose a message from there (assuming the Mail app is still installed on your iOS device, that is), but this is only supposed for composing a message from within the mail app, it doesn't switch the user to the inbox.
You can't open mail app. All you can do it open the compose e-mail interface using either MFMailComposeViewController or mailto: URL.
Related
SCENARIO
I have an app that is a UIWebView, I make some url overriding for requirements.
PROBLEM
To make a call opening url with tel: works weird in iOS7 and iOS8, it makes the phone call direct in the background, but it also ask for the confirmation, so user experience is horrible:
[[UIApplication sharedApplication] openURL:request.URL];
SOLUTION
To solve this issue, I used telprompt. It works nice in all iOS versions:
NSURL *url = [NSURL URLWithString:#"telprompt://637****"];
return [[UIApplication sharedApplication] openURL:url];
But shows this confirmation dialog:
QUESTION
Now, I have a new requirement, to make the phone call without confirmation or prompt. So... There is some way to make a phone call in iOS omitting the confirmation prompt?
I want something like
NSURL *url = [NSURL URLWithString:#"telnoprompt://637******"];
return [[UIApplication sharedApplication] openURL:url];
NSMutableCharacterSet *characterSet =[NSMutableCharacterSet characterSetWithCharactersInString:#" "];
NSArray *arrayOfComponents = [phone_number componentsSeparatedByCharactersInSet:characterSet];
phone_number = [arrayOfComponents componentsJoinedByString:#""];
NSString *phoneURLString = [NSString stringWithFormat:#"tel:%#", phone_number];
NSString *escapedUrlString = [phoneURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *phoneURL = [NSURL URLWithString:escapedUrlString];
I would like to share one Url link and some text message into WhatsApp from my application. How can i share content?
I got this code for only text
NSString * msg = #"Trueman India Magazine";
NSString * urlWhats = [NSString stringWithFormat:#"whatsapp://send?text=%#",msg];
NSURL * whatsappURL = [NSURL URLWithString:[urlWhats stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if ([[UIApplication sharedApplication] canOpenURL: whatsappURL])
{
[[UIApplication sharedApplication] openURL: whatsappURL];
}
but how i share my url link in WhatsApp?
I had a problem with this whatsapp api with url strings, especially when they contained a query string with several fields, e.g. http://example.com/foo?bar=foo&foo=bar.
When opening the app I found the message text would be empty.
The solution was to properly percent escape the string using the CFString functions.
See the apple documentation here:
https://developer.apple.com/library/mac/documentation/CoreFoundation/Reference/CFURLRef/index.html#//apple_ref/c/func/CFURLCreateStringByAddingPercentEscapes
But for anyone else with this issue here is my solution in full:
CFStringRef originalURLString = (__bridge CFStringRef)[NSString stringWithFormat:#"%#", #"http://example.com/foo?bar=foo&foo=bar"];
CFStringRef preprocessedURLString = CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault, originalURLString, CFSTR(""), kCFStringEncodingUTF8);
NSString *urlString = (__bridge NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, preprocessedURLString, NULL, CFSTR("!*'();:#&=+$,/?%#[]"), kCFStringEncodingUTF8);
NSString *whatsAppURLString = [NSString stringWithFormat:#"whatsapp://send?text=%#", urlString];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:whatsAppURLString]];
Note the use of the characters to be escaped in the CFURLCreateStringByAddingPercentEscapes function.
Include the plain link inside the text, e.g.:
NSString * msg = #"Trueman India Magazine http://www.truemanindiamagazine.com";
The link will be generated/tappable after sending it to someone
We can achieve this by using simple jquery. here is the article link http://www.stepblogging.com/how-to-share-web-article-on-whatsapp-using-jquery/
and you can check demo on your smart phone Demo Link
I have to display the setup email screen in iOS if user has not already setup an email.
So when [MFMailComposeViewController canSendMail] returns NO I need to display following screen
Is this possible ? How can I achieve it ?
Not sure but you can try this:
NSString *recipients = #"mailto:myemail#yahoo.com?subject=subjecthere";
NSString *body = #"&body=bodyHere";
NSString *email = [NSString stringWithFormat:#"%#%#", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
I've followed other questions on this however, What seems to work for them doesn't seem to work for me. I tried putting in the hard value directly into the facebookURL variable, still I get the same result. It opens the facebook app, and gives the message "The page you requested was not found".
NSDictionary *profile = [PFuserProfile objectForKey:#"profile"];
NSString *facebookId = [profile objectForKey:#"facebookId"];
NSMutableString *fullText = [NSMutableString string];
[fullText appendString:#"fb://profile/"];
[fullText appendString:facebookId];
NSURL *facebookURL = [NSURL URLWithString:fullText];
if ([[UIApplication sharedApplication] canOpenURL:facebookURL]) {
NSLog(fullText);
[[UIApplication sharedApplication] openURL:facebookURL];
} else {
NSMutableString *fullText2 = [NSMutableString string];
[fullText2 appendString: #"http://facebook.com/"];
[fullText2 appendString:facebookId];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fullText2]];
}
the second option, if the app isn't installed, works perfectly.
I create a UITextView and set text=#"中国,浙江省杭州市滨江区",
set dataDetectorTypes=UIDataDetectorTypeAddress,
then,long pressed, choose open map, it can found the address in GoogleMap.
But, the same address, i used openUrl can't find the address.
NSString *urlText = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", [address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
anybody who can tell me why? or iOS not use this url(http://maps.google.com/maps?q=%#)
Would you try with a different enconding? eg., NSUnicodeStringEncoding
NSString *urlText = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", [address stringByAddingPercentEscapesUsingEncoding:NSUnicodeStringEncoding]];
And what is the result of
[address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
?
Google Maps http:// calls don't use % seperators but rather +'s.
NSString *fixedAddress = [fullAddress stringByReplacingOccurencesOfString:#" " withString:#"+"];
NSString *googleCall = #"http://maps.google.com/maps?q=";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[googleCall stringByAppendingString:fixedAddress]]];
I, myself encountered this issue and fixed it with the preceeding code last night.