iPhone - Disable UIWebView from prompting to enable location services - iphone

During the development of my iPhone app, I decided to integrate Google Maps by including a UIWebView with a URL I construct pointing to maps.google.com. The problem is that the website tries to get the user's location, displaying the "This app wants to use your location". This creates a number of issues for me, which I can explain if necessary.
Is there any way to disable the UIWebView / Mobile Safari from asking for the user's location. The only workaround I can think of is to use Google's Javascript v3 API to make my own map, but I would have to get a license and I'm not 100% certain I would be able to disable asking for location (although I think I can).
Does anyone have an alternate workaround or way of tackling this issue? Thanks!

I believe I found a suitable workaround for now. I remembered that you can embed maps from Google in your website using an iframe. I checked the url they construct to do this and noticed they appended an extra parameter, "output=embed". I appended the "output" variable in the url and pasted this into Mobile Safari on the simulator and it no longer asks me for my location.
The only drawback of this is that I can see so far is that there are some extra UI components on the page as it includes both the mobile controls and website embed controls on the page. Also, I have not tested this on an actual device yet.
Edit: Testing on the device showed that the embed controls don't work, but the mobile controls work as does every other aspect of the map.

Use an MKMapView instead.

(I'm assuming there's a reason you're not using MKMapView for this task and you're stuck with the UIWebView)
You might try asking for user location earlier in your application via CLLocationManager, i.e. right after launch. The permission alert will not be shown more than once. (whether the user chooses to allow or not, which you do not seem to care about)
Not entirely sure that this will work in your case though, UIWebView may still prompt for permission to share location data with the websites it shows.

Assuming it's done via JavaScript, you could try injecting some javascript in - (void)webViewDidStartLoad:(UIWebView *)webView using -[UIWebView stringByEvaluatingJavaScriptFromString:] (e.g. you could set the location-requesting function to null). I'm not entirely sure how well that works while the page is still loading, though...

Related

How to share "Starling" game in a facebook feed

I want to share a part of the game that I made on facebook like it can be done in Angrybirds.
but the problem is that the game was written in starling and
I am getting this error "application is not correctly embeded"
and my question are
can I use starling without hardware acceleration same how?
if same know of a way to tell Facebook to embed the swf in direct mode?
Here it end Angrybirds example just past it on facebook
https://angrybirds-facebook.appspot.com/embed?levelId=9-1&levelName=Surf+and+Turf-1&score=56530
I came across this issue on a project earlier in the year and unfortunately there's no current way to use Stage3D inside the Facebook timeline ('feed gaming' as opposed to a standard Facebook app), because the embedding that Facebook applies uses wmode:"opaque", and there's no option to change that through the FBML meta properties. More details here on what you can specify: https://developers.facebook.com/docs/games/feed-gaming/
In the case of Angry Birds, they use a stripped down version of their app (with just one level, I believe) for the timeline feed version, which doesn't use Starling or Stage3D.
And to answer your other question, you can use Starling with a software rendered fallback (where compatible graphics hardware isn't available), but it unfortunately will still go through Stage3D (as described here: http://www.bytearray.org/?p=3443), and if used without wmode:"direct" it will still fail with the error 3702: Context3D not available.
The workaround, then, if you need it to run in the Facebook timeline, is to either rebuild your application to use conventional display objects, and no Stage3D content, or to make a cut-back second version, which doesn't use Stage3D but links out to your fullblown version, inside a conventional Facebook app. Sorry for the bad news; I feel your pain.
can I use starling without hardware acceleration same how?
No, it's a Stage-3D based engine so it will use hardware acceleration
if same know of a way to tell Facebook to embed the swf in direct mode?
You should change your HTML wrapper file (where your flash is embeded), add a new param "wmode = direct" an it will work perfectly.
The place where you should change your wmode param depends on what IDE you work with. With FlashDevelop or Flash Builder you just add
wmode: "direct"
to the params array

How to really ensure files can be opened?

I know there are quite a few questions that may sound similar, but they never cover my needs, so here's my own attempt:
I am pretty aware, that I can fetch the UTI of a file and use a UIDocumentInteractionController to either check if there's at least one app that can open it or ask the user to select an app, that's great.
Also the UIWebView can open a bunch of other UTIs as well, although it never tells the system what kind of and therefore never appears in the app selection dialog. So when I am sure there is no app I can still check if the UIWebView supports it and create an own view.
That works well to some degrees, until smartass apps like Dropbox appear and basically tell the system I can open every UTI!.
What now? For me that renders the whole mechanism kind of useless, I cannot use the fallback anymore and my only way is to let my app go the Dropbox-way and register every UTI as well.
Any ideas how to solve that?

Simulate actual button press on mobile-safari on iPod Touch / iPhone

I am building a web-based tool for internal purposes for my company that runs on an ipod touch. It's working fine, but there are a few quirks such as not being able to auto-focus on a text field when a page loads without the user actually tapping the screen (I can "focus" the field, but the keyboard is not active). Additionally, I cannot programmatically trigger sounds to play (I am using the jPlayer library). What it seems to come down to is this:
Is there some way I can trick the browser on an ipod touch 4 to thinking the user has actually tapped a specific div on the screen? If I can do that, I can solve every other issue. Since this is for internal purposes, I am free to make any modifications needed. However, I need to able to do keep the "app" code in HTML5 and JavaScript for a myriad of reasons. Perhaps an app with a modification to safari to allow this, then I can run my site in that app?
Perhaps an app with a modification to safari to allow this, then I can run my site in that app?
Yes, you could write a really simple app with just a UIWebView in which you display your HTML5 based app. If you need extra things such as back button etc. you would have to implement that (it's also not very difficult). The UIWebView should behave mostly exactly like Safari, so it should be a de facto "app with a modification to safari".
You could then give the right element focus and call
[webView becomeFirstResponder];
The sounds could also be played programmatically by simply requesting the appropriate URL.
I think with this setup the additional effort in terms of coding beyond your existing web based tool is minimal. However, this assumes you have Xcode, know some basic Objective-C and are familiar with the procedures of ad hoc or company distribution of "real" apps.
You can try to use a timed event

When to use UIWebView versus Safari in iPhone App?

When displaying web content within an iPhone App, we can generally choose between displaying that content within a UIWebView, or popping open an instance of Safari.
I've generally found that for related content, the experience of displaying the content "in-app" by using a UIWebView is cleaner (maybe in a modal view or navigationcontroller), though it's a bit more work to do so.
For possibly unrelated content, I'll generally go for Safari.
Is there any established line of reasoning for picking one method over the other?
EDIT: Along with the technical, what's your reasoning with respect to user experience?
Last I read, Safari will execute JS much faster than an embedded UIWebView. The UIWebView, as it is used in user-generated apps, will not precompile the JS for improved speed.
It looks like this deficiency may go away iOS 5.
With respect to the UX, I think it depends on when the web content is displayed to the user in the user's workflow. Also, how frequently it is done & how distracting it can be? These things matter because you want to keep the user inside your app for the maximum amount of time (there is a good chance that the user won't come back). It is frustrating for the user if she has to leave your app to go to Safari multiple times & return back to your application within a short span of time. Moreover, if by any chance you have specified that your app be terminated if it is sent to the background, then you should not be launching Safari.
For example, the same factors hold when you create you Settings page. To quote from the HIG,
Applications then have two options for presenting preferences:
Display preferences inside the application. OR
Use a Settings bundle to
manage preferences from the Settings application.
Which option you choose depends on how you expect users to interact
with them. The Settings bundle is generally the preferred mechanism
for displaying preferences. However, games and other applications that
contain configuration options or other frequently accessed preferences
might want to present them inside the application instead.
HTH,
Akshay

Plug In To Other Applications (iPhone SDK)

I'm pretty sure that due to the Application Sandbox, none of this is possible, but...
I am working on an application that operates on text that the user inputs. Aside from forcing the user to copy and paste from another application or type in text, what other options exist for getting text? To be more specific:
Is there any way to get the user to "pass" an email to my app? I can imagine a hacky solution where I have the user mail it to a server on the Net, and then I expose the mail from a server-side application, but I'd like something a bit more direct.
Is there any way to get to the user's mail inbox without asking them to put in their credentials?
Is there any way to plug-in to Safari, so that I can send web pages "over" to the app? I don't mean a full plugin, which I know is impossible.
I'm trying to think of creative ways to solve this problem of how to get text into my app, so any ideas would help.
From the Iphone SDK Forum: "Apps can't read each others files - but you could use a URL scheme to launch one app from another. Any parameters in the URL would be passed."
It's what my gut was telling me, but i wanted to go verify before saying..officially, no. The Sandbox isolates each program..
You can pass via URL text strings, but that's about it. I haven't seen any app which hacks around this limitation, but that just may be none of them surviving the app submission process.
http://www.iphonedevsdk.com/forum/iphone-sdk-development/21099-sharing-data-between-applications.html