Open Mobile Safari without using openURL:url - objective-c

I want to open the Mobile Safari app "WITHOUT" changing its currently displayed page.
I can easily switch to Safari using ..
NSString *ourPath = #"http://www.google.co.uk";
NSURL *ourURL = [NSURL URLWithString:ourPath];
if ([ourApplication canOpenURL:ourURL]) {
[ourApplication openURL:ourURL];
}
But what I want to do is just switch to safari and not navigate away from the page it is currently on. Like when I switch using the task switcher, it just pops Safari and leaves it on the page it was.
I've tried sending it a url of #"http:" but this doesn't work it changes pages to to "http:localhost/"
Is there a way to just Open it?
Plasma

I solved this using the answers on this page ..
iOS How can I use UIApplication launchApplicationWithIdentifier which is in private APIs?
Though I didn't have to move my .app file in to /Applications
It was enough to add the entitlements, then simply call it using ...
[[UIApplication sharedApplication] launchApplicationWithIdentifier:#"com.apple.mobilesafari" suspended:NO];
Plasma

Could you open to a page that executes JavaScript history.back() when loaded?

Related

Apple's latest (2015) 'link to app store' directive causes unwanted Safari behaviour

I want to add a link from my app to another of my apps on the appstore.
Question How to link to apps on the app store showed that the itunes.apple.com link was,until recently, the normal way to go. I've tried this and everything is fine. The problem begins when I disgard this and use Apple's new recommendation of using appstore.com. I use the following line of code:
[UIApplication sharedApplication] openURL:[NSURL URLWithString:#http://appstore.com/myappname"]];
The first time I call this from my app it works well. You see it jump through Safari and move onto the appstore where it displays my app.
At this point if you look back into Safari you will notice a new blank tab labelled Favourites has been created.
If I go back to my app and perform the same action to link to the appstore again I'm prompted with one of the two popup boxes:
"Open this page in "App Store"? [Cancel] or [Open].
or
"Cannot Open Page. Safari cannot open the page because the address is invalid" [OK]
I've found that manually deleting the blank tab in Safari will allow the link to work properly but this behaviour isn't what I want my users to see- and I wouldn't be expecting them to delete the blank tabs from Safari.
Any advice on stopping this behaviour whilst following Apple's new rules greatly appreciated.
A simple and clean solution is to present an instance of SKStoreProductViewController inside your app (modally) to display information on the products you are interested in. The user can interact with it as a small view on the App Store and you can simply dismiss it when done.

UIWebView opens safari on load

I have a UIWebView in my application. If I tell it to open the url #"http://twitter.com/" it open in that same webView fine. But if I ask it to open a url like (similar to the one I need it to open): #"feed://www.OcataCore.com/rss/news.xml" it opens up safari as soon as the view that contains the UIWebview is loaded. Is there a way i can force that url to be opened in my webview ?
UIWebView does not offer the same range of features as Safari does. Except html, UIWebView is capable to read the formats listed in this Q&A. It appears like it is not capable of displaying XML, no matter if it is taken from a feed or a local file.
agreed, should not be able to open XML files.
hope this helps though if you are just wondering how to open Safari. use this delegate method of UIWebView to open the links.
webView:shouldStartLoadWithRequest:navigationType
that should work.

How to programmatically add calendar subscriptions on iOS?

Via the settings panel of your iPhone, you can add a subscription to a remote .ics calendar format. I have a Dutch iPhone app that does this from within the app (see the screenshot below, "abonneren op de agenda" means "subscribe to the calendar"), but there must be others too.
I want to mimic this behavior for a project of mine, but I can't find the API to do this with. It looks like it's not a part of EventKit, but because there's no app switching going on when you hit 'subscribe' in the example app I suspect it's also not a url scheme.
Who knows?
Try something like this:
NSString *url = #"http://server/filename.ics";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
This shows an uialertview with the question to the user if he/she wants to subscribe.
;)

How can I activate a specific window of an external application in OSX?

I'm trying to control Safari windows from my application.
I use this code to get the window list from Safari via ScriptingBridge:
SafariApplication *saf = [SBApplication ApplicationWithProcessIdentifier:myPid];
SBElementArray *safariWindows = [saf windows];
This works fine so far.
I also can manage the order of the windows with the index property something like this:
SafariWindow *firstSafWin = [saf.windows objectAtIndex:0];
[firstSafWin setIndex: 1];
Now I try to activate Safari with:
NSRunningApplication *runApp = [NSRunningApplication runningApplicationWithProcessIdentifier: myPid];
[runApp activateWithOptions: NSApplicationActivateAllWindows];
So here comes my problem:
Safari gets activated and the window I wanted is on top now, but it doesn't get the focus (or "mainWindow"). So the focus of the user input is still on the safari window which had the focus before I tried to change the order of the Safari windows.
Is there a way in OSX to get the focus to the Safari window I want?
The Accessibility API can give you this level of control but it must be enabled on the user's machine.
FWIW, what you are doing should work. You should file a bug report against Safari.

iPhone: Button "Vote in AppStore"

I would like to add a button "Vote Us" that opens App Store and brings automatically users to my app review page where they can vote my app.
How can I do it?
I think the easiest way to access specific pages on the App Store is to use the URLs, which are opened automatically on the iPhone using the Store app. For example, sending the user to http://itunes.apple.com/gb/app/polytune/id364009203?mt=8 takes them to the PolyTune page in the App Store. I'm not sure if there is a more direct way to achieve it.
Use this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
#"http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=YOUR_APP_ID&mt=8"
]];