Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
c0bc73b2
提交
c0bc73b2
authored
8月 18, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
register api 调整
上级
c5546371
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
54 行增加
和
18 行删除
+54
-18
AppRegister.java
android/src/main/kotlin/com/jarvan/fluwx/AppRegister.java
+0
-1
FluwxPlugin.kt
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
+1
-1
WechatPluginKeys.java
...in/kotlin/com/jarvan/fluwx/constant/WechatPluginKeys.java
+7
-2
WeChatPluginHandler.kt
...in/kotlin/com/jarvan/fluwx/handler/WeChatPluginHandler.kt
+19
-5
main.dart
example/lib/main.dart
+1
-2
main.dart
lib/main.dart
+3
-2
fluwx.dart
lib/src/fluwx.dart
+6
-5
flutter_register_model.dart
lib/src/models/flutter_register_model.dart
+17
-0
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/AppRegister.java
浏览文件 @
c0bc73b2
...
@@ -14,6 +14,5 @@ public class AppRegister extends BroadcastReceiver {
...
@@ -14,6 +14,5 @@ public class AppRegister extends BroadcastReceiver {
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
final
IWXAPI
api
=
WXAPIFactory
.
createWXAPI
(
context
,
null
);
final
IWXAPI
api
=
WXAPIFactory
.
createWXAPI
(
context
,
null
);
// 将该app注册到微信
// 将该app注册到微信
api
.
registerApp
(
WechatPluginKeys
.
appId
);
}
}
}
}
android/src/main/kotlin/com/jarvan/fluwx/FluwxPlugin.kt
浏览文件 @
c0bc73b2
...
@@ -29,7 +29,7 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
...
@@ -29,7 +29,7 @@ class FluwxPlugin(private var registrar: Registrar) : MethodCallHandler {
if
(
call
.
method
==
WeChatPluginMethods
.
UNREGISTER_APP
){
if
(
call
.
method
==
WeChatPluginMethods
.
UNREGISTER_APP
){
WeChatPluginHandler
.
unregisterApp
()
WeChatPluginHandler
.
unregisterApp
(
call
)
result
.
success
(
true
)
result
.
success
(
true
)
return
return
}
}
...
...
android/src/main/kotlin/com/jarvan/fluwx/constant/WechatPluginKeys.java
浏览文件 @
c0bc73b2
...
@@ -6,7 +6,12 @@ package com.jarvan.fluwx.constant;
...
@@ -6,7 +6,12 @@ package com.jarvan.fluwx.constant;
* 万里飞雪,将穹苍作烘炉,熔万物为白银。
* 万里飞雪,将穹苍作烘炉,熔万物为白银。
**/
**/
public
class
WechatPluginKeys
{
public
class
WechatPluginKeys
{
public
static
String
appId
=
""
;
public
static
final
String
ANDROID
=
"android"
;
public
static
final
String
APP_ID
=
"appId"
;
public
static
final
String
PLATFORM
=
"platform"
;
public
static
final
String
RESULT
=
"result"
;
public
static
final
String
SCENE
=
"scene"
;
public
static
final
String
SCENE
=
"scene"
;
public
static
final
String
SCENE_TIMELINE
=
"WeChatScene.TIMELINE"
;
public
static
final
String
SCENE_TIMELINE
=
"WeChatScene.TIMELINE"
;
public
static
final
String
SCENE_SESSION
=
"WeChatScene.SESSION"
;
public
static
final
String
SCENE_SESSION
=
"WeChatScene.SESSION"
;
...
@@ -22,7 +27,7 @@ public class WechatPluginKeys {
...
@@ -22,7 +27,7 @@ public class WechatPluginKeys {
public
static
final
String
PACKAGE
=
"?package="
;
public
static
final
String
PACKAGE
=
"?package="
;
public
static
final
String
MESSAGE_EXT
=
"messageExt"
;
public
static
final
String
MESSAGE_EXT
=
"messageExt"
;
public
static
final
String
MEDIA_TAG_NAME
=
"mediaTagName "
;
public
static
final
String
MEDIA_TAG_NAME
=
"mediaTagName "
;
public
static
final
String
MESSAGE_ACTION
=
"messageAction"
;
public
static
final
String
MESSAGE_ACTION
=
"messageAction"
;
}
}
android/src/main/kotlin/com/jarvan/fluwx/handler/WeChatPluginHandler.kt
浏览文件 @
c0bc73b2
...
@@ -39,12 +39,20 @@ object WeChatPluginHandler {
...
@@ -39,12 +39,20 @@ object WeChatPluginHandler {
fun
registerApp
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
fun
registerApp
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
if
(!
call
.
argument
<
Boolean
>(
WechatPluginKeys
.
ANDROID
)){
return
}
if
(
wxApi
!=
null
)
{
if
(
wxApi
!=
null
)
{
result
.
success
(
true
)
result
.
success
(
mapOf
(
WechatPluginKeys
.
PLATFORM
to
WechatPluginKeys
.
ANDROID
,
WechatPluginKeys
.
RESULT
to
true
))
return
return
}
}
val
appId
=
call
.
arguments
as
String
?
val
appId
:
String
?
=
call
.
argument
(
WechatPluginKeys
.
APP_ID
)
if
(
appId
.
isNullOrBlank
())
{
if
(
appId
.
isNullOrBlank
())
{
result
.
error
(
"invalid app id"
,
"are you sure your app id is correct ?"
,
appId
)
result
.
error
(
"invalid app id"
,
"are you sure your app id is correct ?"
,
appId
)
return
return
...
@@ -53,10 +61,16 @@ object WeChatPluginHandler {
...
@@ -53,10 +61,16 @@ object WeChatPluginHandler {
val
api
=
WXAPIFactory
.
createWXAPI
(
registrar
!!
.
context
().
applicationContext
,
appId
)
val
api
=
WXAPIFactory
.
createWXAPI
(
registrar
!!
.
context
().
applicationContext
,
appId
)
val
registered
=
api
.
registerApp
(
appId
)
val
registered
=
api
.
registerApp
(
appId
)
wxApi
=
api
wxApi
=
api
result
.
success
(
registered
)
result
.
success
(
mapOf
(
WechatPluginKeys
.
PLATFORM
to
WechatPluginKeys
.
ANDROID
,
WechatPluginKeys
.
RESULT
to
registered
))
}
}
fun
unregisterApp
()
{
fun
unregisterApp
(
call
:
MethodCall
)
{
if
(!
call
.
argument
<
Boolean
>(
WechatPluginKeys
.
ANDROID
)){
return
}
wxApi
?.
unregisterApp
()
wxApi
?.
unregisterApp
()
wxApi
=
null
wxApi
=
null
}
}
...
@@ -317,7 +331,7 @@ object WeChatPluginHandler {
...
@@ -317,7 +331,7 @@ object WeChatPluginHandler {
"type"
to
resp
.
type
,
"type"
to
resp
.
type
,
"errCode"
to
resp
.
errCode
,
"errCode"
to
resp
.
errCode
,
"openId"
to
resp
.
openId
,
"openId"
to
resp
.
openId
,
"platform"
to
"android"
WechatPluginKeys
.
PLATFORM
to
"android"
)
)
channel
?.
invokeMethod
(
WeChatPluginMethods
.
WE_CHAT_RESPONSE
,
result
)
channel
?.
invokeMethod
(
WeChatPluginMethods
.
WE_CHAT_RESPONSE
,
result
)
...
...
example/lib/main.dart
浏览文件 @
c0bc73b2
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:fluwx/main.dart'
;
import
'package:fluwx/main.dart'
;
void
main
(
)
=>
runApp
(
new
MyApp
());
void
main
(
)
=>
runApp
(
new
MyApp
());
...
@@ -16,7 +15,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -16,7 +15,7 @@ class _MyAppState extends State<MyApp> {
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// initPlatformState();
// initPlatformState();
Fluwx
.
registerApp
(
"wxd930ea5d5a258f4f"
).
then
((
result
)
{
Fluwx
.
registerApp
(
RegisterModel
(
appId:
"wxd930ea5d5a258f4f"
)
).
then
((
result
)
{
print
(
"succes-->
$result
"
);
print
(
"succes-->
$result
"
);
},
onError:
(
value
)
{
},
onError:
(
value
)
{
print
(
"--->
$value
"
);
print
(
"--->
$value
"
);
...
...
lib/main.dart
浏览文件 @
c0bc73b2
...
@@ -2,4 +2,5 @@ library fluwx;
...
@@ -2,4 +2,5 @@ library fluwx;
export
'src/fluwx.dart'
;
export
'src/fluwx.dart'
;
export
'src/models/wechat_share_models.dart'
;
export
'src/models/wechat_share_models.dart'
;
export
'src/wechat_scene.dart'
;
export
'src/wechat_scene.dart'
;
export
'src/wechat_reponse.dart'
;
export
'src/wechat_reponse.dart'
;
\ No newline at end of file
export
'src/models/flutter_register_model.dart'
;
\ No newline at end of file
lib/src/fluwx.dart
浏览文件 @
c0bc73b2
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:fluwx/src/models/wechat_share_models.dart'
;
import
'models/flutter_register_model.dart'
;
import
'models/wechat_share_models.dart'
;
class
Fluwx
{
class
Fluwx
{
static
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
static
const
Map
<
Type
,
String
>
_shareModelMethodMapper
=
{
...
@@ -20,12 +21,12 @@ class Fluwx {
...
@@ -20,12 +21,12 @@ class Fluwx {
Stream
<
Map
>
get
weChatResponseUpdate
=>
_responseStreamController
.
stream
;
Stream
<
Map
>
get
weChatResponseUpdate
=>
_responseStreamController
.
stream
;
static
Future
registerApp
(
String
appId
)
async
{
static
Future
registerApp
(
RegisterModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"registerApp"
,
appId
);
return
await
_channel
.
invokeMethod
(
"registerApp"
,
model
.
toMap
()
);
}
}
static
Future
unregisterApp
()
async
{
static
Future
unregisterApp
(
RegisterModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"unregisterApp"
);
return
await
_channel
.
invokeMethod
(
"unregisterApp"
,
model
.
toMap
()
);
}
}
void
listen
()
{
void
listen
()
{
_channel
.
setMethodCallHandler
(
_handler
);
_channel
.
setMethodCallHandler
(
_handler
);
...
...
lib/src/models/flutter_register_model.dart
0 → 100644
浏览文件 @
c0bc73b2
class
RegisterModel
{
final
String
appId
;
final
bool
doIOS
;
final
bool
doAndroid
;
RegisterModel
({
this
.
appId
,
this
.
doIOS
:
true
,
this
.
doAndroid
:
true
});
Map
toMap
(){
return
{
"appId"
:
appId
,
"iOS"
:
doIOS
,
"android"
:
doAndroid
};
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论