I can't open Mail app? - objective-c

I'm trying to open iOS's mail application by clicking a button.
So I did this :
NSString *mailString = [NSString stringWithFormat:#"mailto://test#test.com"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailString]];
But nothing in particular happens... what's the problem ?
Thanks for your advices

#"mailto:test#test.com"
instead of
#"mailto://test#test.com"
Better way of doing this would be to use MFMailComposeViewController

And it works only on the real device, not on the simulator (in my case)

Related

How to hide all application in mac app programmatically?

In my cocoa app I want to hide all applications I've found this but I don't want to do in that way. so, is there any way to get result as expected. Below code which I am using and problem is finder windows not closing.
for (NSRunningApplication *app in [[NSWorkspace sharedWorkspace] runningApplications]) {
[app hide];
}
I guess you're looking for [[NSWorkspace sharedWorkspace] hideOtherApplications]; call.

How to open Notification Center via URL Scheme from app?

Using the URL Scheme below, I'm able to open the 'Settings' App from the app I'm currently working on.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
Is it also possible to tweak the URL Scheme so that I can directly open the 'Notification Center' feature inside the 'Settings' App?
Kindly advise. All help appreciated!
I tried this code to prevent crashes from iOS versions and it's working for me:
if ([[UIApplication sharedApplication] respondsToSelector:#selector(openURL:options:completionHandler:)]) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:#{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
tested on iOS 8 up;
you can try this url scheme: "prefs:root=NOTIFICATIONS_ID"
But u must add URL types in ur project: Click on ur Project in Project Navigator-> click on TARGET -> tab Info -> and add URL Types by click (+) and add URL scheme : "prefs".
if you still not clear check this Answer here
All the best,

Link to iTunes have to restart app

Im Linking to appstore from my app using
 
`NSString *iTunesLink = #"itms-apps://itunes.com/apps/companyname/";
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];
This works, but when returning to my app it's just a blank screen and I have to restart the app.
Am I missing some fundemanatal piece of code here
Try using a link with this format itms-apps://ax.itunes.apple.com/app/id123456789

iOS, openURL opens odd webpage... (welcome to appe.com)

When user click the link,
it should go to the app store page(angry bird page).
this is the code:
NSString *url = #"http://itunes.apple.com/us/album/angry-birds-rio-samba-single/id426982849?uo=4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
but, first time when I click the link, it goes to odd webpage.
(blank white page with text "welcome to appe.com", not apple.com).
and when when I click the link again, it goes to the right page.
anyone who experience with this situation?
this is error page on app store.
It's strange. Ia haven't experienced such situation yet. However, the link you are trying to open is not the Angry birds Rio GAME, but a SONG. If you want to lead user to Angry birds Rio game in app store, you should rather use:
NSString* urlString=#"itms-apps://itunes.apple.com/pl/app/angry-birds-rio/id420635506?mt=8";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
(the protocol is not http:// but itms-apps://
use this link instead
NSString *url = #"http://itunes.apple.com/us/album/angry-birds-rio-samba-single/id426982849?ign-mpt=uo%3D4";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
I double-checked the url. and that was the problem.
I use this url,
http://itunes.apple.com/us/album/angry-birds-rio-samba-single/id426982849
not this correct one,
http://itunes.apple.com/us/album/angry-birds-rio-samba-single/id426982849?uo=4
I modified the url and it fixed the problem.

How to open web browser with UIWebView

Hey guys,
On my Xcode project, I am trying to open a web browser at the click of one of my buttons, but here's what I'm really trying to do. First of all, I am opening a web browser using this example code:
NSURL *fanPageURL = [NSURL URLWithString:#"fb://profile/210227459693"];
if (![[UIApplication sharedApplication] openURL: fanPageURL]) {
NSURL *webURL = [NSURL URLWithString:#"http://www.facebook.com/pages/Blackout-Labs/210227459693"];
[[UIApplication sharedApplication] openURL: webURL];
}
[super viewDidLoad];
Now this code works properly, but the problem is that it's closing my application and opens the link in the Safari application, which is not what I want. I went the other way around by creating another view (after click the button), then inserted a UIWebView using Interface Builder, but it still didn't work. So I was hoping someone can help me out how to open this link within my app instead of closing my app and opening the link in the Safari app, thanks
Look at SVWebViewController. It's a ready made UIViewController subclass with a UIWebView in it and all you need to do to show it is
SVWebViewController *webViewController = [[SVWebViewController alloc] initWithAddress:#"http://google.com"];
[self.navigationController pushViewController:webViewController animated:YES];
There is also a modal version, see the Usage Section.
You'll need to create a UIViewController subclass that has UIWebView as a subview, and show that when the button in tapped.