Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
0b1311ec
提交
0b1311ec
authored
12月 19, 2018
作者:
cjl_macbook
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
添加了移动应用一次性订阅消息 iOS+dart部分
[参考连接](
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1500434436_aWfqW&token=&lang=zh_CN
)
上级
49bc09b0
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
139 行增加
和
25 行删除
+139
-25
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+8
-2
FluwxSubscribeMsgHandler.m
ios/Classes/handler/FluwxSubscribeMsgHandler.m
+41
-0
FluwxSubscribeMsgHandler.h
ios/Classes/public/FluwxSubscribeMsgHandler.h
+18
-0
FluwxResponseHandler.m
ios/Classes/wechat/FluwxResponseHandler.m
+31
-23
fluwx_iml.dart
lib/src/fluwx_iml.dart
+26
-0
wechat_response.dart
lib/src/models/wechat_response.dart
+15
-0
没有找到文件。
ios/Classes/FluwxPlugin.m
浏览文件 @
0b1311ec
...
...
@@ -9,7 +9,7 @@
#import "FluwxWXApiHandler.h"
#import "FluwxShareHandler.h"
#import "FluwxLaunchMiniProgramHandler.h"
#import "FluwxSubscribeMsgHandler.h"
@implementation
FluwxPlugin
...
...
@@ -22,6 +22,7 @@ FluwxAuthHandler *_fluwxAuthHandler;
FluwxWXApiHandler
*
_fluwxWXApiHandler
;
FluwxPaymentHandler
*
_fluwxPaymentHandler
;
FluwxLaunchMiniProgramHandler
*
_fluwxLaunchMiniProgramHandler
;
FluwxSubscribeMsgHandler
*
_fluwxSubscribeMsgHandler
;
-
(
void
)
dealloc
{
...
...
@@ -52,7 +53,7 @@ FluwxLaunchMiniProgramHandler *_fluwxLaunchMiniProgramHandler;
_fluwxWXApiHandler
=
[[
FluwxWXApiHandler
alloc
]
init
];
_fluwxPaymentHandler
=
[[
FluwxPaymentHandler
alloc
]
initWithRegistrar
:
registrar
];
_fluwxLaunchMiniProgramHandler
=
[[
FluwxLaunchMiniProgramHandler
alloc
]
initWithRegistrar
:
registrar
];
_fluwxSubscribeMsgHandler
=
[[
FluwxSubscribeMsgHandler
alloc
]
initWithRegistrar
:
registrar
];
}
return
self
;
...
...
@@ -89,6 +90,11 @@ FluwxLaunchMiniProgramHandler *_fluwxLaunchMiniProgramHandler;
[
_fluwxLaunchMiniProgramHandler
handleLaunchMiniProgram
:
call
result
:
result
];
return
;
}
if
([
@"subscribeMsg"
isEqualToString
:
call
.
method
]){
[
_fluwxSubscribeMsgHandler
handleSubscribeWithCall
:
call
result
:
result
];
return
;
}
if
([
call
.
method
hasPrefix
:
@"share"
])
{
[
_fluwxShareHandler
handleShare
:
call
result
:
result
];
...
...
ios/Classes/handler/FluwxSubscribeMsgHandler.m
0 → 100644
浏览文件 @
0b1311ec
//
// FluwxSubscribeMsgHandler.m
// fluwx
//
// Created by cjl on 2018/12/19.
//
#import "FluwxSubscribeMsgHandler.h"
#import <WXApiRequestHandler.h>
@implementation
FluwxSubscribeMsgHandler
{
NSObject
<
FlutterPluginRegistrar
>
*
_registrar
;
}
-
(
instancetype
)
initWithRegistrar
:
(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
self
=
[
super
init
];
if
(
self
)
{
_registrar
=
registrar
;
}
return
self
;
}
-
(
void
)
handleSubscribeWithCall
:
(
FlutterMethodCall
*
)
call
result
:
(
FlutterResult
)
result
{
NSDictionary
*
params
=
call
.
arguments
;
NSString
*
appId
=
[
params
valueForKey
:
@"appId"
];
int
scene
=
[[
params
valueForKey
:
@"scene"
]
intValue
];
NSString
*
templateId
=
[
params
valueForKey
:
@"templateId"
];
NSString
*
reserved
=
[
params
valueForKey
:
@"reserved"
];
WXSubscribeMsgReq
*
req
=
[
WXSubscribeMsgReq
new
];
req
.
scene
=
(
UInt32
)
scene
;
req
.
templateId
=
templateId
;
req
.
reserved
=
reserved
;
req
.
openID
=
appId
;
BOOL
b
=
[
WXApi
sendReq
:
req
];
result
(
@
(
b
));
}
@end
ios/Classes/public/FluwxSubscribeMsgHandler.h
0 → 100644
浏览文件 @
0b1311ec
//
// FluwxSubscribeMsgHandler.h
// fluwx
//
// Created by cjl on 2018/12/19.
//
#import <Foundation/Foundation.h>
#import <Flutter/Flutter.h>
NS_ASSUME_NONNULL_BEGIN
@interface
FluwxSubscribeMsgHandler
:
NSObject
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
;
-
(
void
)
handleSubscribeWithCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
;
@end
NS_ASSUME_NONNULL_END
ios/Classes/wechat/FluwxResponseHandler.m
浏览文件 @
0b1311ec
...
...
@@ -38,6 +38,7 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
}
#pragma mark - WXApiDelegate
-
(
void
)
onResp
:(
BaseResp
*
)
resp
{
if
([
resp
isKindOfClass
:[
SendMessageToWXResp
class
]])
{
if
(
_delegate
...
...
@@ -51,15 +52,13 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
SendMessageToWXResp
*
messageResp
=
(
SendMessageToWXResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
messageResp
.
description
==
nil
?
@""
:
messageResp
.
description
,
errStr:
messageResp
.
errStr
==
nil
?
@""
:
messageResp
.
errStr
,
description:
messageResp
.
description
==
nil
?
@""
:
messageResp
.
description
,
errStr:
messageResp
.
errStr
==
nil
?
@""
:
messageResp
.
errStr
,
errCode:
@
(
messageResp
.
errCode
),
type:
messageResp
.
type
==
nil
?
@2
:
@
(
messageResp
.
type
),
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
,
type:
messageResp
.
type
==
nil
?
@2
:
@
(
messageResp
.
type
),
country:
messageResp
.
country
==
nil
?
@""
:
messageResp
.
country
,
lang:
messageResp
.
lang
==
nil
?
@""
:
messageResp
.
lang
,
fluwxKeyPlatform:
fluwxKeyIOS
};
[
fluwxMethodChannel
invokeMethod
:
@"onShareResponse"
arguments
:
result
];
...
...
@@ -76,14 +75,14 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
SendAuthResp
*
authResp
=
(
SendAuthResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
authResp
.
description
==
nil
?
@""
:
authResp
.
description
,
errStr:
authResp
.
errStr
==
nil
?
@""
:
authResp
.
errStr
,
description:
authResp
.
description
==
nil
?
@""
:
authResp
.
description
,
errStr:
authResp
.
errStr
==
nil
?
@""
:
authResp
.
errStr
,
errCode:
@
(
authResp
.
errCode
),
type:
authResp
.
type
==
nil
?
@1
:
@
(
authResp
.
type
),
country:
authResp
.
country
==
nil
?
@""
:
authResp
.
country
,
lang:
authResp
.
lang
==
nil
?
@""
:
authResp
.
lang
,
type:
authResp
.
type
==
nil
?
@1
:
@
(
authResp
.
type
),
country:
authResp
.
country
==
nil
?
@""
:
authResp
.
country
,
lang:
authResp
.
lang
==
nil
?
@""
:
authResp
.
lang
,
fluwxKeyPlatform:
fluwxKeyIOS
,
@"code"
:
[
StringUtil
nilToEmpty
:
authResp
.
code
],
@"code"
:
[
StringUtil
nilToEmpty
:
authResp
.
code
],
@"state"
:
[
StringUtil
nilToEmpty
:
authResp
.
state
]
};
...
...
@@ -111,27 +110,37 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvSubscribeMsgResponse
:)])
{
[
_delegate
managerDidRecvSubscribeMsgResponse
:(
WXSubscribeMsgResp
*
)
resp
];
}
WXSubscribeMsgResp
*
subscribeMsgResp
=
(
WXSubscribeMsgResp
*
)
resp
;
NSDictionary
*
subMsgResult
=
@{
@"openid"
:
subscribeMsgResp
.
openId
,
@"templateId"
:
subscribeMsgResp
.
templateId
,
@"action"
:
subscribeMsgResp
.
action
,
@"reserved"
:
subscribeMsgResp
.
reserved
,
@"scene"
:
@
(
subscribeMsgResp
.
scene
),
};
[
fluwxMethodChannel
invokeMethod
:
@"onSubscribeMsgResp"
arguments
:
subMsgResult
];
}
else
if
([
resp
isKindOfClass
:[
WXLaunchMiniProgramResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvLaunchMiniProgram
:)])
{
[
_delegate
managerDidRecvLaunchMiniProgram
:(
WXLaunchMiniProgramResp
*
)
resp
];
}
WXLaunchMiniProgramResp
*
miniProgramResp
=
(
WXLaunchMiniProgramResp
*
)
resp
;
NSDictionary
*
commonResult
=
@{
description:
miniProgramResp
.
description
==
nil
?
@""
:
miniProgramResp
.
description
,
errStr:
miniProgramResp
.
errStr
==
nil
?
@""
:
miniProgramResp
.
errStr
,
description:
miniProgramResp
.
description
==
nil
?
@""
:
miniProgramResp
.
description
,
errStr:
miniProgramResp
.
errStr
==
nil
?
@""
:
miniProgramResp
.
errStr
,
errCode:
@
(
miniProgramResp
.
errCode
),
type:
miniProgramResp
.
type
==
nil
?
@1
:
@
(
miniProgramResp
.
type
),
type:
miniProgramResp
.
type
==
nil
?
@1
:
@
(
miniProgramResp
.
type
),
fluwxKeyPlatform:
fluwxKeyIOS
,
};
NSMutableDictionary
*
result
=
[
NSMutableDictionary
dictionaryWithDictionary
:
commonResult
];
if
(
miniProgramResp
.
extMsg
!=
nil
)
{
if
(
miniProgramResp
.
extMsg
!=
nil
)
{
result
[
@"extMsg"
]
=
miniProgramResp
.
extMsg
;
}
...
...
@@ -153,21 +162,20 @@ FlutterMethodChannel *fluwxMethodChannel = nil;
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvPayInsuranceResponse
:)])
{
[
_delegate
managerDidRecvPayInsuranceResponse
:(
WXPayInsuranceResp
*
)
resp
];
}
}
else
if
([
resp
isKindOfClass
:[
PayResp
class
]])
{
}
else
if
([
resp
isKindOfClass
:[
PayResp
class
]])
{
if
([
_delegate
respondsToSelector
:
@selector
(
managerDidRecvPaymentResponse
)])
{
[
_delegate
managerDidRecvPaymentResponse
:(
PayResp
*
)
resp
];
}
PayResp
*
payResp
=
(
PayResp
*
)
resp
;
NSDictionary
*
result
=
@{
description:
[
StringUtil
nilToEmpty
:
payResp
.
description
]
,
description:
[
StringUtil
nilToEmpty
:
payResp
.
description
]
,
errStr:
[
StringUtil
nilToEmpty
:
resp
.
errStr
],
errCode:
@
(
payResp
.
errCode
),
type:
payResp
.
type
==
nil
?
@5
:
@
(
payResp
.
type
),
@"returnKey"
:
payResp
.
returnKey
==
nil
?
@""
:
payResp
.
returnKey
,
type:
payResp
.
type
==
nil
?
@5
:
@
(
payResp
.
type
),
@"returnKey"
:
payResp
.
returnKey
==
nil
?
@""
:
payResp
.
returnKey
,
fluwxKeyPlatform:
fluwxKeyIOS
,
};
[
fluwxMethodChannel
invokeMethod
:
@"onPayResponse"
arguments
:
result
];
...
...
lib/src/fluwx_iml.dart
浏览文件 @
0b1311ec
...
...
@@ -47,6 +47,12 @@ Stream<WeChatLaunchMiniProgramResponse> get responseFromLaunchMiniProgram =>
StreamController
<
WeChatLaunchMiniProgramResponse
>
_responseLaunchMiniProgramController
=
new
StreamController
.
broadcast
();
StreamController
<
WeChatSubscribeMsgResp
>
_responseFromSubscribeMsg
=
new
StreamController
.
broadcast
();
Stream
<
WeChatSubscribeMsgResp
>
get
responseFromSubscribeMsg
=>
_responseFromSubscribeMsg
.
stream
;
final
MethodChannel
_channel
=
const
MethodChannel
(
'com.jarvanmo/fluwx'
)
..
setMethodCallHandler
(
_handler
);
...
...
@@ -63,6 +69,9 @@ Future<dynamic> _handler(MethodCall methodCall) {
}
else
if
(
"onPayResponse"
==
methodCall
.
method
)
{
_responsePaymentController
.
add
(
WeChatPaymentResponse
.
fromMap
(
methodCall
.
arguments
));
}
else
if
(
"onSubscribeMsgResp"
==
methodCall
.
method
)
{
_responseFromSubscribeMsg
.
add
(
WeChatSubscribeMsgResp
.
fromMap
(
methodCall
.
arguments
));
}
return
Future
.
value
(
true
);
...
...
@@ -180,3 +189,20 @@ Future pay(
"extData"
:
extData
,
});
}
Future
subscribeMsg
(
{
@required
String
appId
,
@required
int
scene
,
@required
String
templateId
,
String
reserved
,
})
async
{
return
await
_channel
.
invokeMethod
(
"subscribeMsg"
,
{
"appId"
:
appId
,
"scene"
:
scene
,
"templateId"
:
templateId
,
"reserved"
:
reserved
,
},
);
}
lib/src/models/wechat_response.dart
浏览文件 @
0b1311ec
...
...
@@ -115,3 +115,18 @@ class WeChatPaymentResponse {
extData
=
map
[
"extData"
],
androidTransaction
=
map
[
"transaction"
];
}
class
WeChatSubscribeMsgResp
{
final
String
openid
;
final
String
templateId
;
final
String
action
;
final
String
reserved
;
final
int
scene
;
WeChatSubscribeMsgResp
.
fromMap
(
Map
map
)
:
openid
=
map
[
"openid"
],
templateId
=
map
[
"templateId"
],
action
=
map
[
"action"
],
reserved
=
map
[
"reserved"
],
scene
=
map
[
"scene"
];
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论