Flutter plugin for yandex map sign and yandex navigator sign.
Disclaimer: This project uses Yandex sign algorithm which discribed in commercial_use_signature_navigator and commercial_use_signature_yandexmaps
Get key and client Id from yandex_navigator or yandexmaps
- Convert key.pem file to key.der file with openssl
$ openssl rsa -in key.pem -out key.der -outform DER
- Add file key.der to ios project Bundle example
- Get String(base64) from file key.pem
- Add to local variable for flutter project like in example
Example:
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:yandex_sign/yandex_sign.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
String _signUrl = 'Unknown';
@override
void initState() {
super.initState();
initPlatformState();
}
Future<void> initPlatformState() async {
String signUrl;
try {
final url = 'yandexnavi://build_route_on_map?lat_to=55.70500&lon_to=37.587200&client=007';
final androidKey = '''-----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBALUwoxjKUZtMiFPe1K4XAPDYZCX1b6wOM8UXeGS5EbsJe/h12VM1
asx9rtVXJ1Kwhb1N7KcSFc1l9wl2gqe1f8cCAwEAAQJAGV0Dl7bKkai29LaeovgJ
Y62G52FiDn22dYKBkefuOXYwFBSD6+pbHby3m5oBEy51aZJ+QQBIv+RjHN1h1aUQ
8QIhAN9hr9dxgzKYw8FUQBZ4qgd6hRSjb/ryfjgiF5qPt2FbAiEAz6XFDvwkbwE5
FLrO8MigLVXuEuhiCsbkwn8aobBUGwUCIBGlTNeu/tcrXCNUfW+I/p1ynzqfIoRn
TXMvtj+eZLULAiB/n4s2YpKiB0ZmD0sRgr2wH5hr1pgrt4LyZ9yedBm9YQIhAMIB
oRxLAAcDDIlC6vDrYk94nCT0OQ6ZH2YK3rxu8iyy
-----END RSA PRIVATE KEY-----
''';
final iosNameOfDerFile = 'private_key';
//Sign url for both android & ios with key
signUrl = await YandexSign.getSignUrl(url, androidKey, iosNameOfDerFile);
} on PlatformException {
signUrl = 'Failed to get platform version.';
}
if (!mounted) return;
setState(() {
_signUrl = signUrl;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: Text('Running on: $_signUrl\n'),
),
),
);
}
}
For more info see example
- iOS Support
- Android Support