I want my mobile app to be triggered by the "end-of-navigation" in either Waze or the Google Maps app. In it's simplest form, I would like my app to do something when the user gets the "You've arrived at your destination" notification from the navigation app.
I realize, in Android at least, that I can start the navigation (either in Waze, or Google Maps app) by creating an intent. Then, I can run my own proximity sensor in my app to wait for the user to arrive. However, I wanted something far cleaner - a situation where all that is required from the user is to have my app working in the background and then for this app to able to respond to the event of arrival directly.
Solutions either in iOS or Android are very welcome. Hacky solutions are also very welcome.
Thanks
A super hacky thing you could do (almost don't want to post this) would be to use the NotificationListenerService and keep an eye out for the notifications from google maps or waze.
http://developer.android.com/reference/android/service/notification/NotificationListenerService.html#nestedclasses
I think it should be for public to use as long as you have the permission.
You're going to have to think of something smart for languages, maybe reading resources from the google maps / waze apps to ensure you don't miss notifications that are not in English.
This may be viable for iOS as well: https://developer.apple.com/library/ios/documentation/CoreBluetooth/Reference/AppleNotificationCenterServiceSpecification/Specification/Specification.html I don't have personal experience with the watch Apis for iOS so you'll have to dig around there yourself.
The only possible solution here is to poll the active activities (foreground ones) each X seconds and act from there. You can do it with a service and alarm.
You can do it in the following ways:
Check current running processes:
OR (less preferred) check the current foreground application:
A simple solution will be to create a GeoFence just before the intent for navigation is started. You can listen to Geofence.GEOFENCE_TRANSITION_ENTER event using an intent service running in background. When this event happens you can do what ever task you need to do from the service class. This same principle can be implemented in ios also: Here is a tutorial for implementing Geofence in ios http://www.raywenderlich.com/95014/geofencing-ios-swift and in android http://paulusworld.com/technical/android-geofences
In iOS i am not sure you will get a call back from google or Waze. best way is to use
startMonitoringForRegion
. if you enter region(destination) your app will get a call back. if your app is not running OS will launch your application. hope this will help