Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does iOS Google Map detect I am entering a car?

The latest iOS Google Map application(currently of version 4.9.0) has a very nice feature, but so far I can not figure out how this is possible.

The feature is: whenever I am entering my car, try to drive somewhere, Google map will send me a notification to my phone, guess where I am going, giving me an estimate of the traffic, even when the phone is in locked state, and the Google map app hasn't been used for days. A screenshot is provied as following:

Google Map push notification

This is quite amazing to me as an iOS developer. How can it live in the background and detect I am entering a car with such accuracy?

One of my guess is, Google map is using significant location change API. By using this way, the app can be waken in background mode, but, there is still no guarantee it is waken when I am entering my car. And I have already written a test app using this mechanism, although it can be waken in the background, but the timing is not correct, failed to detect I am entering a car or not.

CLLocationManager Class Reference

If you start this service and your app is subsequently terminated, the system automatically relaunches the app into the background if a new event arrives. In such a case, the options dictionary passed to the application:willFinishLaunchingWithOptions: and application:didFinishLaunchingWithOptions: methods of your app delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your app was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.

Any suggestion and help appreciated.

like image 332
Jerry Tian Avatar asked Oct 20 '22 05:10

Jerry Tian


1 Answers

One comment from @alexkent points out my mistake. This is Apple's Maps.app, not Google Maps. All credits belongs to @alexkent.

That notification is from Apple's Maps.app not Google Maps. A new feature in iOS9 (which you must be running) is the ability to detect when you are in your car. I imagine this is done by detecting the Bluetooth signal from the car radio (I have not checked this). I do not believe there is developer API available for this feature.

like image 190
Jerry Tian Avatar answered Oct 21 '22 23:10

Jerry Tian