Commit 3e7a8316 authored by 汪林玲's avatar 汪林玲

Scheme返回参数格式更新

parent a180f453
...@@ -48,6 +48,7 @@ appScheme.registerSchemeListener().listen((event) { ...@@ -48,6 +48,7 @@ appScheme.registerSchemeListener().listen((event) {
``` ```
<scheme>://<host>:<port>/<path>?<query> <scheme>://<host>:<port>/<path>?<query>
``` ```
xiaoxiongapp://xapi.xiaomanxiong.com/home?redirect_type=1&ios_redirect_url=aaaaaaa.com&android_redirect_url=aaaaaaa.com
如下就是一个自定义的URL 如下就是一个自定义的URL
openapp://hhong:80/product?productId=10000007 openapp://hhong:80/product?productId=10000007
openapp: 即Scheme 该Scheme协议名称(必填) openapp: 即Scheme 该Scheme协议名称(必填)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
</head> </head>
<body> <body>
<div> <div>
<a href="app://hong.com/product?productId=10000007">Android、iOS</a> <a href="app://hong.com/product?productId=10000007&">Android、iOS</a>
</div> </div>
<div> <div>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
android:name=".MainActivity" android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:launchMode="singleTop" android:launchMode="singleTask"
android:theme="@style/LaunchTheme" android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
<meta-data android:name="flutterEmbedding" android:value="2"/> <meta-data android:name="flutterEmbedding" android:value="2"/>
......
...@@ -347,7 +347,7 @@ ...@@ -347,7 +347,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = Q74HRRECHL; DEVELOPMENT_TEAM = 4R6KK56452;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
...@@ -471,7 +471,7 @@ ...@@ -471,7 +471,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = Q74HRRECHL; DEVELOPMENT_TEAM = 4R6KK56452;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
...@@ -490,7 +490,7 @@ ...@@ -490,7 +490,7 @@
buildSettings = { buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = Q74HRRECHL; DEVELOPMENT_TEAM = 4R6KK56452;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
......
...@@ -12,32 +12,32 @@ class MyApp extends StatefulWidget { ...@@ -12,32 +12,32 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
String _platformVersion = 'Unknown'; String _platformVersion = 'Unknown';
static AppScheme appScheme = AppSchemeImpl.getInstance(); static AppScheme appScheme = AppSchemeImpl.getInstance();
@override @override
void initState() { void initState() {
super.initState(); super.initState();
appScheme.getInitScheme().then((value){ appScheme.getInitScheme().then((value) {
if(value != null){ if (value != null) {
setState(() { setState(() {
_platformVersion = "Init ${value.dataString}"; _platformVersion = "Init ${value.dataString} map:${value.query}";
}); });
} }
}); });
appScheme.getLatestScheme().then((value){ appScheme.getLatestScheme().then((value) {
if(value != null){ if (value != null) {
setState(() { setState(() {
_platformVersion = "Latest ${value.dataString}"; _platformVersion = "Latest ${value.dataString} map:${value.query}";
}); });
} }
}); });
appScheme.registerSchemeListener().listen((event) { appScheme.registerSchemeListener().listen((event) {
if(event != null){ if (event != null) {
setState(() { setState(() {
_platformVersion = "listen ${event.dataString}"; _platformVersion = "listen ${event.dataString} map:${event.query}";
}); });
} }
}); });
......
...@@ -14,49 +14,49 @@ packages: ...@@ -14,49 +14,49 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0-nullsafety.1"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.3"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0-nullsafety.3"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -73,21 +73,21 @@ packages: ...@@ -73,21 +73,21 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10-nullsafety.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0-nullsafety.3"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0-nullsafety.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -99,56 +99,56 @@ packages: ...@@ -99,56 +99,56 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0-nullsafety.2"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0-nullsafety.1"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.1"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19" version: "0.2.19-nullsafety.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0-nullsafety.3"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.3"
sdks: sdks:
dart: ">=2.12.0-0.0 <3.0.0" dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"
...@@ -3,8 +3,16 @@ class SchemeEntity { ...@@ -3,8 +3,16 @@ class SchemeEntity {
String host; String host;
int port; int port;
String path; String path;
String query; Map<String, String> query;
String source; String source;
String dataString; String dataString;
SchemeEntity({this.scheme,this.host,this.port,this.path,this.query,this.source,this.dataString}); SchemeEntity({
this.scheme,
this.host,
this.port,
this.path,
this.query,
this.source,
this.dataString,
});
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'entity/scheme_entity.dart'; import 'entity/scheme_entity.dart';
abstract class SchemeController { abstract class SchemeController {
Future<SchemeEntity> getInitScheme(); Future<SchemeEntity> getInitScheme();
Future<SchemeEntity> getLatestScheme(); Future<SchemeEntity> getLatestScheme();
Stream<SchemeEntity> registerSchemeListener(); Stream<SchemeEntity> registerSchemeListener();
} }
class PluginController implements SchemeController{ class PluginController implements SchemeController {
final MethodChannel _schemeChannel; final MethodChannel _schemeChannel;
final EventChannel _eventChannel; final EventChannel _eventChannel;
PluginController({ PluginController(
@required MethodChannel schemeChannel, {@required MethodChannel schemeChannel,
@required EventChannel eventChannel @required EventChannel eventChannel})
}):_schemeChannel=schemeChannel,_eventChannel=eventChannel; : _schemeChannel = schemeChannel,
_eventChannel = eventChannel;
@override @override
Future<SchemeEntity> getInitScheme() async{ Future<SchemeEntity> getInitScheme() async {
dynamic data = await _schemeChannel.invokeMethod('getInitScheme'); dynamic data = await _schemeChannel.invokeMethod('getInitScheme');
if(data != null && data is Map && data.isNotEmpty){ if (data != null && data is Map && data.isNotEmpty) {
return SchemeEntity( return SchemeEntity(
scheme:data['scheme'] as String, scheme: data['scheme'] as String,
host:data['host'] as String, host: data['host'] as String,
port:data['port'] as int, port: data['port'] as int,
path:data['path'] as String, path: data['path'] as String,
query:data['query'] as String, query: Uri.parse(data['dataString'] as String).queryParameters,
source:data['source'] as String, source: data['source'] as String,
dataString:data['dataString'] as String, dataString: data['dataString'] as String,
); );
} }
return null; return null;
} }
@override @override
Future<SchemeEntity> getLatestScheme() async{ Future<SchemeEntity> getLatestScheme() async {
dynamic data = await _schemeChannel.invokeMethod('getLatestScheme'); dynamic data = await _schemeChannel.invokeMethod('getLatestScheme');
if(data != null && data is Map && data.isNotEmpty){ if (data != null && data is Map && data.isNotEmpty) {
Map<String, String> queryParameters =
Uri.parse(data['dataString'] as String).queryParameters;
return SchemeEntity( return SchemeEntity(
scheme:data['scheme'] as String, scheme: data['scheme'] as String,
host:data['host'] as String, host: data['host'] as String,
port:data['port'] as int, port: data['port'] as int,
path:data['path'] as String, path: data['path'] as String,
query:data['query'] as String, query: queryParameters,
source:data['source'] as String, source: data['source'] as String,
dataString:data['dataString'] as String, dataString: data['dataString'] as String,
); );
} }
return null; return null;
...@@ -58,27 +58,32 @@ class PluginController implements SchemeController{ ...@@ -58,27 +58,32 @@ class PluginController implements SchemeController{
@override @override
Stream<SchemeEntity> registerSchemeListener() { Stream<SchemeEntity> registerSchemeListener() {
return _eventChannel return _eventChannel
.receiveBroadcastStream() .receiveBroadcastStream()
.map((event) => event) .map((event) => event)
.asBroadcastStream().map((event) => (event != null && event is Map && event.isNotEmpty)?SchemeEntity( .asBroadcastStream()
scheme:event['scheme'] as String, .map((event) => (event != null && event is Map && event.isNotEmpty)
host:event['host'] as String, ? SchemeEntity(
port:event['port'] as int, scheme: event['scheme'] as String,
path:event['path'] as String, host: event['host'] as String,
query:event['query'] as String, port: event['port'] as int,
source:event['source'] as String, path: event['path'] as String,
dataString:event['dataString'] as String, query: Uri.parse(event['dataString'] as String).queryParameters,
):null); source: event['source'] as String,
dataString: event['dataString'] as String,
)
: null);
} }
} }
class PluginControllerFactory { class PluginControllerFactory {
const PluginControllerFactory(); const PluginControllerFactory();
PluginController create() { PluginController create() {
const MethodChannel _channelMethod = const MethodChannel('scheme/flutter.app.method'); const MethodChannel _channelMethod =
const EventChannel _eventChannel = const EventChannel('scheme/flutter.app.event'); const MethodChannel('scheme/flutter.app.method');
PluginController _controller = PluginController(schemeChannel:_channelMethod,eventChannel:_eventChannel); const EventChannel _eventChannel =
const EventChannel('scheme/flutter.app.event');
PluginController _controller = PluginController(
schemeChannel: _channelMethod, eventChannel: _eventChannel);
return _controller; return _controller;
} }
} }
\ No newline at end of file
...@@ -7,49 +7,49 @@ packages: ...@@ -7,49 +7,49 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.5.0" version: "2.5.0-nullsafety.1"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
name: boolean_selector name: boolean_selector
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.3"
charcode: charcode:
dependency: transitive dependency: transitive
description: description:
name: charcode name: charcode
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
clock: clock:
dependency: transitive dependency: transitive
description: description:
name: clock name: clock
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.1"
collection: collection:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.15.0" version: "1.15.0-nullsafety.3"
fake_async: fake_async:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
flutter: flutter:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter
...@@ -66,21 +66,21 @@ packages: ...@@ -66,21 +66,21 @@ packages:
name: matcher name: matcher
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.12.10" version: "0.12.10-nullsafety.1"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0-nullsafety.3"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0-nullsafety.1"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -92,56 +92,56 @@ packages: ...@@ -92,56 +92,56 @@ packages:
name: source_span name: source_span
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.8.0" version: "1.8.0-nullsafety.2"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
name: stack_trace name: stack_trace
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.10.0" version: "1.10.0-nullsafety.1"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
name: stream_channel name: stream_channel
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.1"
string_scanner: string_scanner:
dependency: transitive dependency: transitive
description: description:
name: string_scanner name: string_scanner
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.1.0" version: "1.1.0-nullsafety.1"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
name: term_glyph name: term_glyph
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.2.0" version: "1.2.0-nullsafety.1"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.19" version: "0.2.19-nullsafety.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
name: typed_data name: typed_data
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "1.3.0" version: "1.3.0-nullsafety.3"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.1.0-nullsafety.3"
sdks: sdks:
dart: ">=2.12.0-0.0 <3.0.0" dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.20.0" flutter: ">=1.20.0"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment