Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter-scheme
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
flutter-plugin
flutter-scheme
Commits
90c6eaeb
Commit
90c6eaeb
authored
Jun 04, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增使用说明,以及example中Android和iOS测试地址
parent
8f5e0c6d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
36 deletions
+94
-36
CHANGELOG.md
CHANGELOG.md
+6
-2
README.md
README.md
+69
-29
a.html
a.html
+10
-0
example/lib/main.dart
example/lib/main.dart
+1
-1
example/pubspec.lock
example/pubspec.lock
+1
-1
lib/appscheme.dart
lib/appscheme.dart
+4
-0
lib/src/app_scheme.dart
lib/src/app_scheme.dart
+1
-1
pubspec.yaml
pubspec.yaml
+2
-2
No files found.
CHANGELOG.md
View file @
90c6eaeb
##
0
.0.1
##
1
.0.1
*
TODO: Describe initial release.
*
TODO: 新增使用说明,以及example中Android和iOS测试地址
## 1.0.0
*
TODO: 提交Flutter Android、iOS自定义Scheme URL方案.
README.md
View file @
90c6eaeb
# Flutter App Scheme
## 配置说明
flutter create --template=plugin --platforms=android,ios -a java -i objc flutter_scheme
### 1、Android端配置说明
在您项目中 Android的
`AndroidManifest.xml`
文件中按照如下规范添加
`Scheme`
,例如
`android/app/src/main/AndroidManifest.xml`
#### a、在需要启动的Activity中新增以下格式的代码
```
xml
<!--Android Scheme-->
<intent-filter>
<action
android:name=
"android.intent.action.VIEW"
/>
<category
android:name=
"android.intent.category.DEFAULT"
/>
<!--需要被网页拉起必须设置-->
<category
android:name=
"android.intent.category.BROWSABLE"
/>
<category
android:name=
"android.intent.category.APP_BROWSER"
/>
<!--协议部分-->
<data
android:host=
"hong.com"
android:path=
"/product"
android:scheme=
"app"
/>
</intent-filter>
```
### 2、iOS端配置说明
在你的项目中,ios工程中
```Info.plist```
文件中按照如下规范添加
`Scheme`
,例如:
`ios/Runner/Info.plist`
#### a、在`Info.plist`文件中添加如下格式的代码
```
xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist
version=
"1.0"
>
<dict>
...
<key>
CFBundleURLTypes
</key>
<!-- 表示添加Scheme相关信息 -->
<array>
<dict>
<key>
CFBundleURLName
</key>
<string>
hong.com/product
</string>
<key>
CFBundleURLSchemes
</key>
<array>
<string>
app
</string>
<!-- 此处是Scheme -->
</array>
</dict>
</array>
...
</dict>
</plist>
```
## 使用方法
...
...
@@ -11,37 +56,41 @@ flutter create --template=plugin --platforms=android,ios -a java -i objc flutter
AppScheme appScheme = AppSchemeImpl.getInstance();
```
### 2、getInitScheme
```
```
dart
appScheme
.
getInitScheme
().
then
((
value
){
if(value != null){
setState(() {
_platformVersion = "Init ${value.dataString}";
});
}
if
(
value
!=
null
){
setState
(()
{
_platformVersion
=
"Init
${value.dataString}
"
;
});
}
});
```
### 3、getLatestScheme
```
```
dart
appScheme
.
getLatestScheme
().
then
((
value
){
if(value != null){
setState(() {
_platformVersion = "Latest ${value.dataString}";
});
}
if
(
value
!=
null
){
setState
(()
{
_platformVersion
=
"Latest
${value.dataString}
"
;
});
}
});
```
### 4、注册从外部打开的Scheme监听信息
```
```
dart
appScheme
.
registerSchemeListener
().
listen
((
event
)
{
if(event != null){
setState(() {
_platformVersion = "listen ${event.dataString}";
});
}
if
(
event
!=
null
){
setState
(()
{
_platformVersion
=
"listen
${event.dataString}
"
;
});
}
});
```
### 5、example中测试地址
`测试地址`
:
[
https://api.dsfgx.com/a.html
](
https://api.dsfgx.com/a.html
)
## URL Scheme协议格式:
一个完整的完整的URL Scheme协议格式由scheme、host、port、path和query组成,其结构如下所示
...
...
@@ -61,13 +110,4 @@ param: 即query,代表传递的参数
## Scheme使用
既然我们使用scheme来做打开app并跳转的逻辑,那这个scheme应该声明在哪里比较合适呢?如果你的应用在启动页(splash)或者在主界面(main)初始化了一些必要的设置,比如必要的token信息检查交易或者一些其它校验等,没有这些信息会造成崩溃的,这个时候我们就需要在启动页来声明这个scheme了,获取scheme信息保存起来,然后在主界面做处理逻辑,如跳转到其它界面等。当然你也可以声明scheme在其它地方,具体得需要看怎么实现业务比较方便。
## GIT 相关指令
#### 查看相关提交的日志信息
git log
#### 退回到指定的commit
git reset --hard commit Id
\ No newline at end of file
既然我们使用scheme来做打开app并跳转的逻辑,那这个scheme应该声明在哪里比较合适呢?如果你的应用在启动页(splash)或者在主界面(main)初始化了一些必要的设置,比如必要的token信息检查交易或者一些其它校验等,没有这些信息会造成崩溃的,这个时候我们就需要在启动页来声明这个scheme了,获取scheme信息保存起来,然后在主界面做处理逻辑,如跳转到其它界面等。当然你也可以声明scheme在其它地方,具体得需要看怎么实现业务比较方便。
\ No newline at end of file
a.html
View file @
90c6eaeb
...
...
@@ -36,5 +36,15 @@
<div>
<a
href=
"intent://hong.com/product?productId=10000007#Intent;scheme=app;end"
>
Android特殊机型
</a>
</div>
<div
style=
"text-align:center;"
>
<h4>
小熊有好货测试
</h4>
<div>
<a
href=
"xiaoxiongapp://xapi.xiaomanxiong.com/home?redirect_type=1&ios_redirect_url=www.baidu.com&android_redirect_url=www.baidu.com"
>
测试类型1
</a>
</div>
<div>
<a
href=
"intent://xapi.xiaomanxiong.com/home?redirect_type=1&ios_redirect_url=www.baidu.com&android_redirect_url=www.baidu.com#Intent;scheme=xiaoxiongapp;end"
>
(Android特殊机型)测试类型1
</a>
</div>
</div>
</body>
</html>
\ No newline at end of file
example/lib/main.dart
View file @
90c6eaeb
import
'package:flutter/material.dart'
;
import
'package:appscheme/
flutter_
scheme.dart'
;
import
'package:appscheme/
app
scheme.dart'
;
void
main
(
)
{
runApp
(
MyApp
());
...
...
example/pubspec.lock
View file @
90c6eaeb
...
...
@@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "
0
.0.1"
version: "
1
.0.1"
async:
dependency: transitive
description:
...
...
lib/
flutter_
scheme.dart
→
lib/
app
scheme.dart
View file @
90c6eaeb
library
flutter_scheme
;
library
appscheme
;
export
'src/app_scheme.dart'
;
export
'src/entity/scheme_entity.dart'
;
\ No newline at end of file
export
'src/entity/scheme_entity.dart'
;
lib/src/app_scheme.dart
View file @
90c6eaeb
import
'dart:async'
;
import
'package:appscheme/
flutter_
scheme.dart'
;
import
'package:appscheme/
app
scheme.dart'
;
import
'plugin_controller.dart'
;
...
...
pubspec.yaml
View file @
90c6eaeb
name
:
appscheme
description
:
Android、iOS自定义Scheme URL方案
version
:
0
.0.1
author
:
Scott
Wang
version
:
1
.0.1
#author: Scott
Wang
homepage
:
http://scott-cry.win/
environment
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment