Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
f09621e6
提交
f09621e6
authored
8月 16, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ios share
上级
bde9d52e
隐藏空白字符变更
内嵌
并排
正在显示
34 个修改的文件
包含
345 行增加
和
59 行删除
+345
-59
WeChatPluginHandler.kt
...in/kotlin/com/jarvan/fluwx/handler/WeChatPluginHandler.kt
+10
-3
ShareImageUtil.java
...rc/main/kotlin/com/jarvan/fluwx/utils/ShareImageUtil.java
+5
-1
ic_launcher.png
android/src/main/res/mipmap-hdpi/ic_launcher.png
+0
-0
project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+4
-2
Info.plist
example/ios/Runner/Info.plist
+26
-0
main.dart
example/lib/main.dart
+3
-8
FluwxPlugin.h
ios/Classes/FluwxPlugin.h
+12
-1
FluwxPlugin.m
ios/Classes/FluwxPlugin.m
+24
-41
CallResults.h
ios/Classes/constants/CallResults.h
+0
-0
CallResults.m
ios/Classes/constants/CallResults.m
+0
-0
FluwxKeys.h
ios/Classes/constants/FluwxKeys.h
+6
-0
FluwxKeys.m
ios/Classes/constants/FluwxKeys.m
+4
-0
FluwxMethods.h
ios/Classes/constants/FluwxMethods.h
+0
-0
FluwxMethods.m
ios/Classes/constants/FluwxMethods.m
+0
-0
ImageSchema.h
ios/Classes/constants/ImageSchema.h
+15
-0
ImageSchema.m
ios/Classes/constants/ImageSchema.m
+14
-0
FluwxShareHandler.h
ios/Classes/handler/FluwxShareHandler.h
+20
-0
FluwxShareHandler.m
ios/Classes/handler/FluwxShareHandler.m
+146
-0
FlutterAssetHelper.h
ios/Classes/helper/FlutterAssetHelper.h
+10
-0
FlutterAssetHelper.m
ios/Classes/helper/FlutterAssetHelper.m
+40
-0
StringToWeChatScene.h
ios/Classes/helper/StringToWeChatScene.h
+0
-0
StringToWeChatScene.m
ios/Classes/helper/StringToWeChatScene.m
+0
-0
StringUtil.h
ios/Classes/helper/StringUtil.h
+0
-0
StringUtil.m
ios/Classes/helper/StringUtil.m
+0
-0
SendMessageToWXReq+requestWithTextOrMediaMessage.h
...wechat/SendMessageToWXReq+requestWithTextOrMediaMessage.h
+0
-0
SendMessageToWXReq+requestWithTextOrMediaMessage.m
...wechat/SendMessageToWXReq+requestWithTextOrMediaMessage.m
+0
-0
WXApiManager.h
ios/Classes/wechat/WXApiManager.h
+0
-0
WXApiManager.m
ios/Classes/wechat/WXApiManager.m
+0
-0
WXApiRequestHandler.h
ios/Classes/wechat/WXApiRequestHandler.h
+0
-0
WXApiRequestHandler.m
ios/Classes/wechat/WXApiRequestHandler.m
+6
-3
WXMediaMessage+messageConstruct.h
ios/Classes/wechat/WXMediaMessage+messageConstruct.h
+0
-0
WXMediaMessage+messageConstruct.m
ios/Classes/wechat/WXMediaMessage+messageConstruct.m
+0
-0
WeChatResponseHandler.h
ios/Classes/wechat/WeChatResponseHandler.h
+0
-0
WeChatResponseHandler.m
ios/Classes/wechat/WeChatResponseHandler.m
+0
-0
没有找到文件。
android/src/main/kotlin/com/jarvan/fluwx/handler/WeChatPluginHandler.kt
浏览文件 @
f09621e6
package
com.jarvan.fluwx.handler
package
com.jarvan.fluwx.handler
import
android.graphics.Bitmap
import
android.graphics.BitmapFactory
import
android.util.Log
import
android.util.Log
import
com.jarvan.fluwx.R
import
com.jarvan.fluwx.constant.CallResult
import
com.jarvan.fluwx.constant.CallResult
import
com.jarvan.fluwx.constant.WeChatPluginMethods
import
com.jarvan.fluwx.constant.WeChatPluginMethods
import
com.jarvan.fluwx.constant.WechatPluginKeys
import
com.jarvan.fluwx.constant.WechatPluginKeys
import
com.jarvan.fluwx.utils.ShareImageUtil
import
com.jarvan.fluwx.utils.ShareImageUtil
import
com.jarvan.fluwx.utils.Util
import
com.jarvan.fluwx.utils.WeChatThumbnailUtil
import
com.jarvan.fluwx.utils.WeChatThumbnailUtil
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.modelbase.BaseResp
import
com.tencent.mm.opensdk.modelmsg.*
import
com.tencent.mm.opensdk.modelmsg.*
...
@@ -138,7 +142,8 @@ object WeChatPluginHandler {
...
@@ -138,7 +142,8 @@ object WeChatPluginHandler {
launch
(
UI
){
launch
(
UI
){
val
byteArray
:
ByteArray
?
=
getImageByteArrayCommon
(
registrar
,
imagePath
)
val
byteArray
:
ByteArray
?
=
getImageByteArrayCommon
(
registrar
,
imagePath
)
val
imgObj
=
if
(
byteArray
!=
null
)
{
val
imgObj
=
if
(
byteArray
!=
null
&&
byteArray
.
isNotEmpty
())
{
WXImageObject
(
byteArray
)
WXImageObject
(
byteArray
)
}
else
{
}
else
{
null
null
...
@@ -153,8 +158,10 @@ object WeChatPluginHandler {
...
@@ -153,8 +158,10 @@ object WeChatPluginHandler {
if
(
thumbnail
.
isNullOrBlank
()){
if
(
thumbnail
.
isNullOrBlank
()){
thumbnail
=
imagePath
thumbnail
=
imagePath
}
}
// val thumbnailData = getThumbnailByteArrayCommon(registrar,thumbnail!!)
handleShareImage
(
imgObj
,
call
,
null
,
result
)
val
bitmap
=
BitmapFactory
.
decodeResource
(
registrar
!!
.
context
().
resources
,
R
.
mipmap
.
ic_launcher
)
val
thumbnailData
=
Util
.
bmpToByteArray
(
bitmap
,
true
)
handleShareImage
(
imgObj
,
call
,
thumbnailData
,
result
)
}
}
}
}
...
...
android/src/main/kotlin/com/jarvan/fluwx/utils/ShareImageUtil.java
浏览文件 @
f09621e6
...
@@ -44,7 +44,8 @@ public class ShareImageUtil {
...
@@ -44,7 +44,8 @@ public class ShareImageUtil {
bmp
=
BitmapFactory
.
decodeFile
(
path
);
bmp
=
BitmapFactory
.
decodeFile
(
path
);
result
=
Util
.
bmpToByteArray
(
bmp
,
true
);
result
=
Util
.
bmpToByteArray
(
bmp
,
true
);
}
else
{
}
else
{
result
=
handleNetworkImage
(
registrar
,
path
);
// result = handleNetworkImage(registrar, path);
result
=
Util
.
inputStreamToByte
(
openStream
(
path
));
}
}
return
result
;
return
result
;
...
@@ -53,10 +54,13 @@ public class ShareImageUtil {
...
@@ -53,10 +54,13 @@ public class ShareImageUtil {
private
static
byte
[]
handleNetworkImage
(
PluginRegistry
.
Registrar
registrar
,
String
path
)
{
private
static
byte
[]
handleNetworkImage
(
PluginRegistry
.
Registrar
registrar
,
String
path
)
{
byte
[]
result
=
null
;
byte
[]
result
=
null
;
InputStream
inputStream
=
openStream
(
path
);
InputStream
inputStream
=
openStream
(
path
);
if
(
inputStream
==
null
)
{
if
(
inputStream
==
null
)
{
return
null
;
return
null
;
}
}
String
suffix
=
".jpg"
;
String
suffix
=
".jpg"
;
int
index
=
path
.
lastIndexOf
(
"."
);
int
index
=
path
.
lastIndexOf
(
"."
);
if
(
index
>
0
)
{
if
(
index
>
0
)
{
...
...
android/src/main/res/mipmap-hdpi/ic_launcher.png
0 → 100644
浏览文件 @
f09621e6
544 Bytes
example/ios/Runner.xcodeproj/project.pbxproj
浏览文件 @
f09621e6
...
@@ -441,8 +441,9 @@
...
@@ -441,8 +441,9 @@
"$(inherited)"
,
"$(inherited)"
,
"$(PROJECT_DIR)/Flutter"
,
"$(PROJECT_DIR)/Flutter"
,
);
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.jarvan.fluwxExample
;
PRODUCT_BUNDLE_IDENTIFIER
=
"com.jarvanmo.fluwx-example"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
USER_HEADER_SEARCH_PATHS
=
"\"${PROJECT_DIR}/../..\"/** \"${PROJECT_DIR}/../..\"/**"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
};
name
=
Debug
;
name
=
Debug
;
...
@@ -465,8 +466,9 @@
...
@@ -465,8 +466,9 @@
"$(inherited)"
,
"$(inherited)"
,
"$(PROJECT_DIR)/Flutter"
,
"$(PROJECT_DIR)/Flutter"
,
);
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.jarvan.fluwxExample
;
PRODUCT_BUNDLE_IDENTIFIER
=
"com.jarvanmo.fluwx-example"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
USER_HEADER_SEARCH_PATHS
=
"\"${PROJECT_DIR}/../..\"/** \"${PROJECT_DIR}/../..\"/**"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
};
name
=
Release
;
name
=
Release
;
...
...
example/ios/Runner/Info.plist
浏览文件 @
f09621e6
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
<
d
i
c
t
>
<
d
i
c
t
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
k
e
y
>
CFBundleDevelopmentRegion
<
/k
e
y
>
<
string
>
en
<
/string
>
<
string
>
en
<
/string
>
<
k
e
y
>
CFBundleDisplayName
<
/k
e
y
>
<
string
>
$
{
PROJECT_NAME
}<
/string
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
k
e
y
>
CFBundleExecutable
<
/k
e
y
>
<
string
>
$
(
EXECUTABLE_NAME
)<
/string
>
<
string
>
$
(
EXECUTABLE_NAME
)<
/string
>
<
k
e
y
>
CFBundleIdentifier
<
/k
e
y
>
<
k
e
y
>
CFBundleIdentifier
<
/k
e
y
>
...
@@ -18,6 +20,19 @@
...
@@ -18,6 +20,19 @@
<
string
>
1.0
<
/string
>
<
string
>
1.0
<
/string
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
k
e
y
>
CFBundleSignature
<
/k
e
y
>
<
string
>
????
<
/string
>
<
string
>
????
<
/string
>
<
k
e
y
>
CFBundleURLTypes
<
/k
e
y
>
<
a
rr
a
y
>
<
d
i
c
t
>
<
k
e
y
>
CFBundleTypeRole
<
/k
e
y
>
<
string
>
Editor
<
/string
>
<
k
e
y
>
CFBundleURLName
<
/k
e
y
>
<
string
>
weixin
<
/string
>
<
k
e
y
>
CFBundleURLSchemes
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
wxd930ea5d5a258f4f
<
/string
>
<
/
a
rr
a
y
>
<
/
d
i
c
t
>
<
/
a
rr
a
y
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
k
e
y
>
CFBundleVersion
<
/k
e
y
>
<
string
>
1
<
/string
>
<
string
>
1
<
/string
>
<
k
e
y
>
LSRequiresIPhoneOS
<
/k
e
y
>
<
k
e
y
>
LSRequiresIPhoneOS
<
/k
e
y
>
...
@@ -41,5 +56,16 @@
...
@@ -41,5 +56,16 @@
<
/
a
rr
a
y
>
<
/
a
rr
a
y
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
k
e
y
>
UIViewControllerBasedStatusBarAppearance
<
/k
e
y
>
<
fa
ls
e
/
>
<
fa
ls
e
/
>
<
k
e
y
>
LSApplicationQueriesSchemes
<
/k
e
y
>
<
a
rr
a
y
>
<
string
>
weixin
<
/string
>
<
/
a
rr
a
y
>
<
k
e
y
>
NSAppTransportSecurity
<
/k
e
y
>
<
d
i
c
t
>
<
k
e
y
>
NSAllowsArbitraryLoads
<
/k
e
y
>
<
tru
e
/
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/
d
i
c
t
>
<
/plist
>
<
/plist
>
example/lib/main.dart
浏览文件 @
f09621e6
...
@@ -17,8 +17,8 @@ class _MyAppState extends State<MyApp> {
...
@@ -17,8 +17,8 @@ class _MyAppState extends State<MyApp> {
void
initState
()
{
void
initState
()
{
super
.
initState
();
super
.
initState
();
// initPlatformState();
// initPlatformState();
Fluwx
.
init
(
"wxd930ea5d5a258f4f"
).
then
((
_
)
{
Fluwx
.
init
(
"wxd930ea5d5a258f4f"
).
then
((
result
)
{
print
(
"succes"
);
print
(
"succes
-->
$result
"
);
},
onError:
(
value
)
{
},
onError:
(
value
)
{
print
(
"--->
$value
"
);
print
(
"--->
$value
"
);
});
});
...
@@ -55,12 +55,7 @@ class _MyAppState extends State<MyApp> {
...
@@ -55,12 +55,7 @@ class _MyAppState extends State<MyApp> {
child:
new
FlatButton
(
child:
new
FlatButton
(
onPressed:
()
{
onPressed:
()
{
var
fluwx
=
Fluwx
();
var
fluwx
=
Fluwx
();
fluwx
.
share
(
WeChatShareImageModel
(
fluwx
.
share
(
WeChatShareTextModel
(
text:
"hehe"
));
image:
"https://timgsa.baidu.com/timg?image&quality=80&size=b10000_10000&sec=1534342262&di=ae1078c9080282ec8bbd4909e6669ee2&src=http://img4q.duitang.com/uploads/item/201402/19/20140219123329_QkdNy.jpeg"
,
transaction:
"hehe"
,
title:
"from dart"
,
scene:
WeChatScene
.
SESSION
));
},
},
child:
new
Text
(
"share text to wechat"
)),
child:
new
Text
(
"share text to wechat"
)),
),
),
...
...
ios/Classes/FluwxPlugin.h
浏览文件 @
f09621e6
#import <Flutter/Flutter.h>
#import <Flutter/Flutter.h>
@class
FluwxShareHandler
;
extern
BOOL
isWeChatRegistered
;
extern
BOOL
isWeChatRegistered
;
@interface
FluwxPlugin
:
NSObject
<
FlutterPlugin
>
@interface
FluwxPlugin
:
NSObject
<
FlutterPlugin
>
{
@private
FluwxShareHandler
*
_fluwxShareHandler
;
}
@end
@end
ios/Classes/FluwxPlugin.m
浏览文件 @
f09621e6
...
@@ -2,10 +2,9 @@
...
@@ -2,10 +2,9 @@
#import "FluwxMethods.h"
#import "FluwxMethods.h"
#import "WXApi.h"
#import "WXApi.h"
#import "StringUtil.h"
#import "StringUtil.h"
#import "CallResults.h"
#import "../../../../../../ios/Classes/handler/FluwxShareHandler.h"
#import "WXApiRequestHandler.h"
#import "FluwxShareHandler.h"
#import "FluwxKeys.h"
#import "FluwxShareHandler.h"
#import "StringToWeChatScene.h"
@implementation
FluwxPlugin
@implementation
FluwxPlugin
...
@@ -17,70 +16,54 @@ BOOL isWeChatRegistered = NO;
...
@@ -17,70 +16,54 @@ BOOL isWeChatRegistered = NO;
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName
:
@"fluwx"
methodChannelWithName
:
@"fluwx"
binaryMessenger
:[
registrar
messenger
]];
binaryMessenger
:[
registrar
messenger
]];
FluwxPlugin
*
instance
=
[[
FluwxPlugin
alloc
]
init
];
FluwxPlugin
*
instance
=
[[
FluwxPlugin
alloc
]
init
WithRegistrar
:
registrar
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
self
=
[
super
init
];
if
(
self
)
{
_fluwxShareHandler
=
[[
FluwxShareHandler
alloc
]
initWithRegistrar
:
registrar
];
}
return
self
;
}
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
([
initWeChat
isEqualToString
:
call
.
method
])
{
if
([
initWeChat
isEqualToString
:
call
.
method
])
{
[
self
initWeChatIfNeeded
:
call
result
:
result
];
[
self
initWeChatIfNeeded
:
call
result
:
result
];
}
else
if
([
call
.
method
hasPrefix
:
@"share"
])
{
}
if
([
call
.
method
hasPrefix
:
@"share"
])
{
[
self
handleShare
:
call
result
:
result
];
[
_fluwxShareHandler
handleShare
:
call
result
:
result
];
}
else
{
}
else
{
result
(
FlutterMethodNotImplemented
);
result
(
FlutterMethodNotImplemented
);
}
}
}
}
-
(
void
)
initWeChatIfNeeded
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
-
(
void
)
initWeChatIfNeeded
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
(
isWeChatRegistered
)
{
if
(
isWeChatRegistered
)
{
result
(
resultDone
);
result
(
@YES
);
return
;
return
;
}
}
NSString
*
appId
=
call
.
arguments
;
NSString
*
appId
=
call
.
arguments
;
NSLog
(
appId
);
if
([
StringUtil
isBlank
:
appId
])
{
if
([
StringUtil
isBlank
:
appId
])
{
result
([
FlutterError
errorWithCode
:
@"invalid app id"
message
:
@"are you sure your app id is correct ? "
details
:
appId
]);
result
([
FlutterError
errorWithCode
:
@"invalid app id"
message
:
@"are you sure your app id is correct ? "
details
:
appId
]);
return
;
return
;
}
}
[
WXApi
registerApp
:
appId
];
isWeChatRegistered
=
[
WXApi
registerApp
:
appId
];
result
(
resultDone
);
result
(
@YES
);
}
-
(
void
)
handleShare
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
(
!
isWeChatRegistered
)
{
result
([
FlutterError
errorWithCode
:
resultErrorNeedWeChat
message
:
resultMessageNeedWeChat
details
:
nil
]);
return
;
}
if
([
shareText
isEqualToString
:
call
.
method
])
{
[
self
shareText
:
call
result
:
result
];
}
else
if
([
shareImage
isEqualToString
:
call
.
method
]){
[
self
shareImage
:
call
result
:
result
];
result
(
FlutterMethodNotImplemented
);
}
}
-
(
void
)
shareText
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
text
=
call
.
arguments
[
fluwxKeyText
];
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendText
:
text
InScene
:[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
}
-
(
void
)
shareImage
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
text
=
call
.
arguments
[
fluwxKeyText
];
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendText
:
text
InScene
:[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
}
}
...
...
ios/Classes/CallResults.h
→
ios/Classes/
constants/
CallResults.h
浏览文件 @
f09621e6
File moved
ios/Classes/CallResults.m
→
ios/Classes/
constants/
CallResults.m
浏览文件 @
f09621e6
File moved
ios/Classes/FluwxKeys.h
→
ios/Classes/
constants/
FluwxKeys.h
浏览文件 @
f09621e6
...
@@ -18,5 +18,10 @@ extern NSString *const fluwxKeyDescription;
...
@@ -18,5 +18,10 @@ extern NSString *const fluwxKeyDescription;
extern
NSString
*
const
fluwxKeyPackage
;
extern
NSString
*
const
fluwxKeyPackage
;
extern
NSString
*
const
fluwxKeyMessageExt
;
extern
NSString
*
const
fluwxKeyMediaTagName
;
extern
NSString
*
const
fluwxKeyMessageAction
;
@interface
FluwxKeys
:
NSObject
@interface
FluwxKeys
:
NSObject
@end
@end
\ No newline at end of file
ios/Classes/FluwxKeys.m
→
ios/Classes/
constants/
FluwxKeys.m
浏览文件 @
f09621e6
...
@@ -18,6 +18,10 @@ NSString *const fluwxKeyDescription = @"description";
...
@@ -18,6 +18,10 @@ NSString *const fluwxKeyDescription = @"description";
NSString
*
const
fluwxKeyPackage
=
@"?package="
;
NSString
*
const
fluwxKeyPackage
=
@"?package="
;
NSString
*
const
fluwxKeyMessageExt
=
@"messageExt"
;
NSString
*
const
fluwxKeyMediaTagName
=
@"mediaTagName "
;
NSString
*
const
fluwxKeyMessageAction
=
@"messageAction"
;
@implementation
FluwxKeys
{
@implementation
FluwxKeys
{
}
}
...
...
ios/Classes/FluwxMethods.h
→
ios/Classes/
constants/
FluwxMethods.h
浏览文件 @
f09621e6
File moved
ios/Classes/FluwxMethods.m
→
ios/Classes/
constants/
FluwxMethods.m
浏览文件 @
f09621e6
File moved
ios/Classes/constants/ImageSchema.h
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import <Foundation/Foundation.h>
extern
NSString
*
const
SCHEMA_ASSETS
;
extern
NSString
*
const
SCHMEA_HTTP
;
extern
NSString
*
const
SCHMEA_HTTPS
;
extern
NSString
*
const
SCHEMA_FILE
;
@interface
ImageSchema
:
NSObject
@end
\ No newline at end of file
ios/Classes/constants/ImageSchema.m
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import "ImageSchema.h"
NSString
*
const
SCHEMA_ASSETS
=
@
"assets://"
;
NSString
*
const
SCHMEA_HTTP
=
@"http://"
;
NSString
*
const
SCHMEA_HTTPS
=
@"https://"
;
NSString
*
const
SCHEMA_FILE
=
@"file://"
;
@implementation
ImageSchema
@end
\ No newline at end of file
ios/Classes/handler/FluwxShareHandler.h
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import <Foundation/Foundation.h>
#import "CallResults.h"
#import "WXApiRequestHandler.h"
#import "FluwxKeys.h"
#import "StringToWeChatScene.h"
#import "WXApi.h"
#import "FluwxMethods.h"
#import <Flutter/Flutter.h>
#import "FluwxPlugin.h"
@class
StringUtil
;
@interface
FluwxShareHandler
:
NSObject
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
;
-
(
void
)
handleShare
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
;
@end
\ No newline at end of file
ios/Classes/handler/FluwxShareHandler.m
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import "FluwxShareHandler.h"
#import "ImageSchema.h"
#import "StringUtil.h"
@implementation
FluwxShareHandler
NSObject
<
FlutterPluginRegistrar
>
*
_registrar
;
-
(
instancetype
)
initWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>
*
)
registrar
{
self
=
[
super
init
];
if
(
self
)
{
_registrar
=
registrar
;
}
return
self
;
}
-
(
void
)
handleShare
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
(
!
isWeChatRegistered
)
{
result
([
FlutterError
errorWithCode
:
resultErrorNeedWeChat
message
:
resultMessageNeedWeChat
details
:
nil
]);
return
;
}
if
(
!
[
WXApi
isWXAppInstalled
])
{
result
([
FlutterError
errorWithCode
:
@"wechat not installed"
message
:
@"wechat not installed"
details
:
nil
]);
return
;
}
if
([
shareText
isEqualToString
:
call
.
method
])
{
[
self
shareText
:
call
result
:
result
];
}
else
if
([
shareImage
isEqualToString
:
call
.
method
])
{
[
self
shareImage
:
call
result
:
result
];
}
else
if
([
shareWebPage
isEqualToString
:
call
.
method
])
{
[
self
shareWebPage
:
call
result
:
result
];
}
}
-
(
void
)
shareText
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
text
=
call
.
arguments
[
fluwxKeyText
];
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendText
:
text
InScene
:[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
}
-
(
void
)
shareImage
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
imagePath
=
call
.
arguments
[
fluwxKeyImage
];
if
([
imagePath
hasPrefix
:
SCHEMA_ASSETS
])
{
}
else
if
([
imagePath
hasPrefix
:
SCHEMA_FILE
])
{
}
else
{
[
self
shareNetworkImage
:
call
result
:
result
imagePath
:
imagePath
];
}
NSString
*
text
=
call
.
arguments
[
fluwxKeyText
];
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendText
:
text
InScene
:[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
}
-
(
void
)
shareNetworkImage
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
imagePath
:(
NSString
*
)
imagePath
{
NSString
*
thumbnail
=
call
.
arguments
[
fluwxKeyThumbnail
];
if
([
StringUtil
isBlank
:
thumbnail
])
{
thumbnail
=
imagePath
;
}
dispatch_queue_t
globalQueue
=
dispatch_get_global_queue
(
0
,
0
);
dispatch_async
(
globalQueue
,
^
{
NSURL
*
imageURL
=
[
NSURL
URLWithString
:
imagePath
];
//下载图片
NSData
*
imageData
=
[
NSData
dataWithContentsOfURL
:
imageURL
];
NSData
*
thumbnailData
;
UIImage
*
thumbnailImage
;
if
([
thumbnail
hasPrefix
:
SCHEMA_ASSETS
])
{
}
else
if
([
thumbnail
hasPrefix
:
SCHEMA_FILE
])
{
}
else
{
NSURL
*
thumbnailURL
=
[
NSURL
URLWithString
:
thumbnail
];
thumbnailData
=
[
NSData
dataWithContentsOfURL
:
thumbnailURL
];
if
([
thumbnailData
length
]
>
(
32
*
1024
))
{
}
else
{
thumbnailImage
=
[
UIImage
imageWithData
:
thumbnailData
];
}
}
dispatch_async
(
dispatch_get_main_queue
(),
^
{
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendImageData
:
imageData
TagName
:
call
.
arguments
[
fluwxKeyMediaTagName
]
MessageExt:
fluwxKeyMessageExt
Action:
fluwxKeyMessageAction
ThumbImage:
thumbnailImage
InScene:
[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
});
});
}
-
(
void
)
shareWebPage
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
webPageUrl
=
call
.
arguments
[
@"webPage"
];
NSString
*
imagePath
=
call
.
arguments
[
fluwxKeyImage
];
if
([
imagePath
hasPrefix
:
SCHEMA_ASSETS
])
{
}
else
if
([
imagePath
hasPrefix
:
SCHEMA_FILE
])
{
}
else
{
[
self
shareNetworkImage
:
call
result
:
result
imagePath
:
imagePath
];
}
NSString
*
text
=
call
.
arguments
[
fluwxKeyText
];
NSString
*
scene
=
call
.
arguments
[
fluwxKeyScene
];
BOOL
done
=
[
WXApiRequestHandler
sendText
:
text
InScene
:[
StringToWeChatScene
toScene
:
scene
]];
result
(
@
(
done
));
}
@end
\ No newline at end of file
ios/Classes/helper/FlutterAssetHelper.h
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import <Foundation/Foundation.h>
#import "ImageSchema.h"
#import "FluwxKeys.h"
@interface
FlutterAssetHelper
:
NSObject
@end
\ No newline at end of file
ios/Classes/helper/FlutterAssetHelper.m
0 → 100644
浏览文件 @
f09621e6
//
// Created by mo on 2018/8/16.
//
#import "FlutterAssetHelper.h"
@implementation
FlutterAssetHelper
+
(
NSString
*
)
getPackageName
:(
NSString
*
)
assetPath
{
NSUInteger
length
=
SCHEMA_ASSETS
.
length
;
return
@""
;
}
+
(
NSString
*
)
getPath
:(
NSString
*
)
assetPath
{
NSUInteger
schemaLength
=
SCHEMA_ASSETS
.
length
;
NSUInteger
totalLength
=
assetPath
.
length
;
NSRange
range
=
NSMakeRange
(
schemaLength
,
totalLength
-
schemaLength
);
NSString
*
result
=
[
assetPath
substringWithRange
:
range
];
if
([
result
rangeOfString
:
fluwxKeyPackage
].
location
!=
NSNotFound
)
{
result
=
[
result
stringByReplacingCharactersInRange
:
<
#
(
NSRange
)
range
#
>
withString
:
<
#
(
NSString
*
)
replacement
#
>
]
}
return
result
;
}
@end
\ No newline at end of file
ios/Classes/StringToWeChatScene.h
→
ios/Classes/
helper/
StringToWeChatScene.h
浏览文件 @
f09621e6
File moved
ios/Classes/StringToWeChatScene.m
→
ios/Classes/
helper/
StringToWeChatScene.m
浏览文件 @
f09621e6
File moved
ios/Classes/StringUtil.h
→
ios/Classes/
helper/
StringUtil.h
浏览文件 @
f09621e6
File moved
ios/Classes/StringUtil.m
→
ios/Classes/
helper/
StringUtil.m
浏览文件 @
f09621e6
File moved
ios/Classes/SendMessageToWXReq+requestWithTextOrMediaMessage.h
→
ios/Classes/
wechat/
SendMessageToWXReq+requestWithTextOrMediaMessage.h
浏览文件 @
f09621e6
File moved
ios/Classes/SendMessageToWXReq+requestWithTextOrMediaMessage.m
→
ios/Classes/
wechat/
SendMessageToWXReq+requestWithTextOrMediaMessage.m
浏览文件 @
f09621e6
File moved
ios/Classes/WXApiManager.h
→
ios/Classes/
wechat/
WXApiManager.h
浏览文件 @
f09621e6
File moved
ios/Classes/WXApiManager.m
→
ios/Classes/
wechat/
WXApiManager.m
浏览文件 @
f09621e6
File moved
ios/Classes/WXApiRequestHandler.h
→
ios/Classes/
wechat/
WXApiRequestHandler.h
浏览文件 @
f09621e6
File moved
ios/Classes/WXApiRequestHandler.m
→
ios/Classes/
wechat/
WXApiRequestHandler.m
浏览文件 @
f09621e6
...
@@ -29,12 +29,15 @@
...
@@ -29,12 +29,15 @@
MessageExt
:(
NSString
*
)
messageExt
MessageExt
:(
NSString
*
)
messageExt
Action
:(
NSString
*
)
action
Action
:(
NSString
*
)
action
ThumbImage
:(
UIImage
*
)
thumbImage
ThumbImage
:(
UIImage
*
)
thumbImage
InScene
:(
enum
WXScene
)
scene
{
InScene
:(
enum
WXScene
)
scene
title
:(
NSString
*
)
title
description
:
(
NSString
*
)
description
{
WXImageObject
*
ext
=
[
WXImageObject
object
];
WXImageObject
*
ext
=
[
WXImageObject
object
];
ext
.
imageData
=
imageData
;
ext
.
imageData
=
imageData
;
WXMediaMessage
*
message
=
[
WXMediaMessage
messageWithTitle
:
nil
WXMediaMessage
*
message
=
[
WXMediaMessage
messageWithTitle
:
title
Description
:
nil
Description
:
description
Object
:
ext
Object
:
ext
MessageExt
:
messageExt
MessageExt
:
messageExt
MessageAction
:
action
MessageAction
:
action
...
...
ios/Classes/WXMediaMessage+messageConstruct.h
→
ios/Classes/
wechat/
WXMediaMessage+messageConstruct.h
浏览文件 @
f09621e6
File moved
ios/Classes/WXMediaMessage+messageConstruct.m
→
ios/Classes/
wechat/
WXMediaMessage+messageConstruct.m
浏览文件 @
f09621e6
File moved
ios/Classes/WeChatResponseHandler.h
→
ios/Classes/
wechat/
WeChatResponseHandler.h
浏览文件 @
f09621e6
File moved
ios/Classes/WeChatResponseHandler.m
→
ios/Classes/
wechat/
WeChatResponseHandler.m
浏览文件 @
f09621e6
File moved
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论