Google Maps Javascript Event in iOS UIWebView - ios

I have a UIWebView that loads a web page which consists of an embedded Google Maps map. I want the iOS app to perform an action as long as the user is panning the Google map. (I'm using the standard method of bridging between Javascript and Objective-C code--creating an IFrame and picking it up on the other side as a page load--and that part is working fine.)
The problem I'm having is that the Google Maps API running on Safari on the iPhone does not pick up 'pan' events continuously. It only picks up one event at the very end of panning. (I figured this out using the iPhone simulator web inspector tool available within Safari.) Google Maps running in Desktop Safari, in contrast, picks up a continuous stream of events whenever the user pans the map--which is what I want.
Here's the Javascript code which runs differently between mobile and. desktop Safari.
google.maps.event.addListener(map, 'bounds_changed', function(){
console.log("This browser is noticing panning.")
})
To summarize, in desktop Safari, it prints continuously during a 'bounds changed' action, while in mobile Safari it only prints once at the end of the action.
Is this an issue with Google Maps or with iOS Safari? How can I fix it?
EDIT: While 'bounds_changed' events are not triggered properly in iOS Safari, a 'drag' event is triggered continuously. Still, however, the bounds (retrieved with map.getBounds()) of the map are not updated until after the drag motion is complete, so listening for a 'drag' is not much help if I need the bounds.

Related

How to Hide Screen on Pause in Ionic App for iOS

I am developing a mobile app for iOS using Ionic Framework 4 with Cordova/PhoneGap. The app contains sensitive information. One of the requirements is that the screen become hidden/blank whenever the user pauses the app (i.e. when they press the Home button).
Normally iOS takes a snapshot of the current screen whenever the user presses the Home button. This snapshot needs to be blank.
Is there a plugin for Cordova/PhoneGap or Ionic Native which can be used to make the screen blank?
It appears that this cannot be accomplished through JavaScript inside the webview. The pause can be detected but no interactive code works at that point, so it is too late to blank out the screen. See http://docs.phonegap.com/en/2.9.0rc1/cordova_events_events.md.html#pause
The pause can be intercepted earlier by native iOS code, but this would require a Cordova/PhoneGap plugin. I am hoping someone here can recommend a plugin that can detect the pause and hide the screen.

Possibility to stop opening Google Map app while clicking the logo

I am using Google Map in an iOS app built for a client. I know that the logo at the bottom cannot and shouldn't be removed at any time. I am wondering whether I can disable the click action and stop the app jumping or not, since the client don't want the app to open an external app.

Using geolocation.watchPosition() in mobile safari using location services

The output geo coordinates are only accurate on first load, the problem is when the iPhone screen times out and the locations services also timeout. And if I open safari again the geo coordinates are off by 100's of meters. The same thing happens if I push safari app to background. The problem is fixed if I reload the safari tab requesting geolocation or if I clear safari app cache and open up safari again. Why is this happening? My use case involves showing the user an arrow that guides to destination. Thus it is likely the phone times out occasionally for user that leads to location services timeout. iOS chrome does not mimic this behavior and work as expected i.e geo coordinates are always accurate event after tab in focus and /or screen timeout.
I don't know why this happens exactly, but it's happening to me too. I was able to get around the issue by using window.setInterval to call a function every 5 seconds or so that checks whether the location has been updated. If it hasn't, then the function stops and restarts the geolocation watch.
The restarting of the geolocation watch has the same effect as reloading the page, i.e. the accuracy becomes much better again, and location updates resume. Hope that helps!

Prevent Google Cardboard Pairing / Startup Screen on iOS

When my google cardboard app starts up for the first time, it launches a Google page that says "Google Cardboard. Let's get you set up. Pair your phone with your viewer for the best experience."
I'd like to control this experience to show my own initial screen before the google cardboard sdk launches. One reason for this is that I want people without cardboard to be able to immediately start experiencing the app in non-cardboard mode without having to go through the pairing process.
I know I can launch the pairing / viewer profile selector later on with the cardboard.ShowSettingsDialog().
One way to do this with the current version of the SDK is to have a starter scene without a Cardboard component in it. It will not be in VR, and it won't trigger onboarding.
[edit] The function OnFocus() in CardboardiOSDevice.cs is where it decides to launch the onboarding dialog. You can suppress that by editing this function. But you may want to continue using the onboarding dialog for first time users, rather than the settings dialog, because of it walks them through the scanning process.

jQuery Mobile Detect Home Screen Bookmark

I know there's no way to add a home screen bookmark automatically within a mobile web app, however, is there a way to DETECT if one has been created?
You could prompt the user to bookmark your app and then save their response (seen here on Mobile Boilerplate). This would allow you to "detect" if they have already added it.
The Mobile Bookmark Bubble is a JavaScript library that adds a promo
bubble to the bottom of your mobile web application, inviting users to
bookmark the app to their device's home screen. The library uses HTML5
local storage to track whether the promo has been displayed already,
to avoid constantly nagging users.

Resources