For developers: how to launch 2GIS navigation using deeplink
Startup
To start 2GIS from other apps or web-pages, use URL scheme dgis://
Opening the 2GIS app on mobile devices
To launch 2GIS in iOS app:
- Call a command openURL to UIApplication class object
- Send a URL containing dgis scheme in the command
[[UIApplication sharedApplication] openURL: [NSURL URLWithString:@"dgis://"]];
If 2GIS is not installed
Before launching 2GIS, check if the app is installed on the device. If 2GIS is not installed, you can open it through the App Store.
Use the canOpenURL method to verify whether you can edit the URL
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"dgis://"]])
{
//If the app is installed, launch it.
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"dgis://"]];
} else
{ // If the app is not installed, go to App Store.
[[UIApplication sharedApplication] openURL:
[NSURL URLWithString:@"https://itunes.apple.com/ru/app/id481627348?mt=8″]];
}
To build a route
To build a route, create a URL as follows.
dgis://2gis.ru/routeSearch/rsType/<type>/from/<lon>,<lat>/to/<lon>,<lat>
- from/<lon>,<lat> is used to set the departure point,
- rsType/<type> is used to set the type of transport,
- to/<lon>,<lat> is used to set the destination point.
The following parameters are used:
- type, data type: string. Route type: car (car route), ctx (public transport), pedestrian (foot route), taxi (route by taxi). For example, if the parameter type / car, then the route is built using road transport.
- lon, data type: float. Longitude.
- lat, data type: float. Latitude.
URL example
dgis://2gis.ru/routeSearch/rsType/car/from/55.352823,25.246908/to/55.465508,25.398003
The route can be built without a departure point. In this case, the current location of the user is substituted as the point of departure (if it can be determined).
URL example
dgis://2gis.ru/routeSearch/rsType/car/to/55.465508,25.398003