提交 37b8306b authored 作者: JarvanMo's avatar JarvanMo

English doc support

上级 93d5442e
![logo](./arts/fluwx_logo.png)
适用于Flutter的微信SDK,方便快捷。
`Fluwx` makes easier using WeChatSDK on Flutter.
## 使用需知
使用`Fluwx`之前,强烈建议先阅读[微信SDK官方文档](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1)
## Before
Before using`Fluwx`,I highly recommond you read this [article](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1)
这有助于你使用`Fluwx`
### 目前功能
* 文本分享。
* 网站分享。
* 图片分享。
* 音乐分享。
* 视频分享。
* 小程序分享。
* 发送Auth认证。
## 技术参数
Android部分使用到了`kotlin-1.2.60`。以下是Android部分所涉及到的技术:
### What does Fluwx support?
* Share Text.
* Share WebPage.
* Share Image.
* Share Music.
* Share Video.
* Share MiniProgram.
* Send Auth.
## Tech Used In Flux
For Android,`kotlin-1.2.60` is included:
```gradle
api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.24.0'
......@@ -25,53 +25,53 @@
implementation 'top.zibin:Luban:1.1.8'
implementation 'com.squareup.okhttp3:okhttp:3.11.0'
```
iOS部分涉及到的技术:
For iOS:
```podspec
s.dependency 'WechatOpenSDK','~> 1.8.2'
```
Flutter版本信息<br>
For Flutter<br>
> Flutter 0.7.5 channel dev https://github.com/flutter/flutter.git<br>
> Framework revision eab5cd9853 (4 days ago) 2018-08-30 14:47:04 -0700<br>
> Engine revision dc7b5eb89d<br>
> Tools Dart 2.1.0-dev.3.0.flutter-760a9690c2<br>
## 引入
在`pubspec.yaml`文件中添加如下代码:
## Import
add the following in your `pubspec.yaml` file:
```yaml
dependencies:
fluwx: ^0.1.3
```
## 初始化
使用`Fluwx`前,需要进行初始化操作
## Init Fluwx
Before using`Fluwx`,you should init `FLuwx`
```dart
Fluwx.registerApp(RegisterModel(appId: "your app id", doOnAndroid: true, doOnIOS: true));
```
- `appId`:在微信平台申请的appId。
- `doOnAndroid`:是否在android平台上执行此操作。
- `doOnIOS`:是否在平台上执行此操作。</br>
每一个字段都是非必须的,但是如果不传`appId`或`doOnAndroid: false`或者`doOnIOS: false`,请务必手动注册`WXApi`以保证`Fluwx`正常工作。
注册完成后,请在使用`Fluwx`前在对应平台添加如下代码:
Android上
- `appId`:the appId you applied from WeChat.
- `doOnAndroid`:whether init for Android.
- `doOnIOS`:whether init for iOS
Each param isn't necessary.However,if `appId`is blank, or `doOnAndroid: false`, or `doOnIOS: false`,you must register your `WXApi` on the particular platform in order to ensure `Fluwx` can work.
After tha,add the following code before using `Fluwx` on the particular platform:
For Android
```kotlin
FluwxShareHandler.setWXApi(wxapi)
```
iOS上:
For iOS:
```objective-c
isWeChatRegistered = YES;
```
> 注意:尽管可以通过Fluwx完成微信注册,但一些操作依然需要在对应平台进行设置,如配置iOS的URLSchema,Android上的WXEntryActivity等。
> NOTE:Although we can register WXApi via Fluwx,but there's still some work you have to doon the particular platform.For example, creat a `WXEntryActivity` for android and add a URLSchema for iOS.
### 传送门
* [分享](./doc/SHARE.md)
### More
* [Share](./doc/SHARE.md)
* [Auth](./doc/SEND_AUTH.md)
* [支付](./doc/WXPay.md)
* [回调](./doc/RESPONSE.md)
* [Payment](./doc/WXPay.md)
* [Resonse](./doc/RESPONSE.md)
### 更多功能敬请请期待
### Waiting
## LICENSE
......
### 微信调回
微信的回调也要根据平台的不同进行差异化处理(如果你不需要回调,请忽略)。
### Response From WeChat
There's some work we have to do on the particular plaform(if you don't need this,just ignore).
### Android
由于机制问题,`Android`端需要在`WXEntryActivity``WXPayEntryActivity`中添加如下代码
For`Android`,create `WXEntryActivity`or`WXPayEntryActivity`,and override the following function
```kotlin
override fun onResp(resp: BaseResp) {
FluwxResponseHandler.handleResponse(resp)
}
```
你也可以直接继承`FluwxWXEntryActivity`
`WXEntryActivity``WXPayEntryActivity`创建规则请参阅官方文档。具体可以参考[example wxapi](https://github.com/OpenFlutter/fluwx/tree/master/example/android/app/src/main/kotlin/net/sourceforge/simcpux/wxapi )
也不要忘记在`AndroidManifest.mxl`中注册:
You can also directly inherit `FluwxWXEntryActivity`,and then you can do nothing.
For the rule of creating `WXEntryActivity`and`WXPayEntryActivity`,please read[example wxapi](https://github.com/OpenFlutter/fluwx/tree/master/example/android/app/src/main/kotlin/net/sourceforge/simcpux/wxapi )
never register your Activity in `AndroidManifest.mxl`:
```xml
<activity
android:name="your.package.name.registered.on.wechat.wxapi.WXEntryActivity"
......@@ -26,7 +26,7 @@
```
### iOS
在你的`AppDelegate.m`中重写下面方法:
override the following function in`AppDelegate.m`:
```objective-c
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [WXApi handleOpenURL:url delegate:[FluwxResponseHandler responseHandler]];
......@@ -38,17 +38,18 @@
```
### Flutter
We can get the reponse from WeChat after sharing and etc:
```dart
_fluwx.response.listen((response){
//do something
});
```
从微信回调的值为`WeChatResponse`,其实`type`字段为枚举:
The type of return value is `WeChatResponse`,and `type` is an enum:
```dart
enum WeChatResponseType {
SHARE,
AUTH,
PAYMENT }
```
`result`为微信回传的值,其类型为`Map`,具体返回值请参阅微信官方文档,但均额外包含一个
`platform`字段,其值为`android`或者`iOS`,以便开发者作差异化处理。
`result` is the real response from WeChat,it's a `Map`, read the WeChat documents for more details.
Howver,there an addtional param `platform`,the value of `platform` is `android`or`iOS`.
## 发送Auth验证
`Fluwx`目前只支持获取`code`,若要获取`access_token`请在服务器端完成。
## Send Auth
We'll get a `code` by sending auth:
```dart
fluwx.sendAuth(WeChatSendAuthModel(
scope: "snsapi_userinfo",
state:"wechat_sdk_demo_test",
));
```
### 返回值处理
`fluwx.share(model)`返回的是一个`Map`
`Fluwx` doesn't support getting `access_toke`.
### Return
The return value of `fluwx.share(model)` is a `Map`
```dart
{
"platform":"Android",//或者iOS
result:true //或者false,取决于WXApi.sendRequest()的结果
"platform":"Android",//or iOS
result:true //or false,depending on the result of WXApi.sendRequest()
}
```
\ No newline at end of file
### 简述
目前`Fluwx`并不是支持所有的分享类型,目前仅支持文本分享、图片分享、网址分享
音乐、视频以及小程序的分享。未来会考虑增加更多支持。
### Summary
`Fluwx` doesn't support all kind of sharing.Only text, image, web page,
music, video and mini program are supported.We'll consider the more.
More support will be considered in the future.
.
> 注意:目前分享中涉及到图片的地方仅支持`png`和`jpg`,支持网络图片及`assets`图片。<br>
> 使用`assets`图片需要添加`assets://`。<br>
> 也可以在`assets`图片添加`?package=package_name`以读取指定包的图片。<br>
> 未来可能支持`file://`,目前以`file://`图片不会做任何处理。<br>
> 如果不指定schema或者schema错误,将会被处理为网络图片,请谨慎。<br>
> 由于微信的限制,一般的缩略图要小于32k(小程序的缩略图要小于120k),所以在使用缩略的时候<br>
> 很有必要使用一张合格的缩略图,否则`Fluwx`进行压缩,其结果可能并不是你所预期的。
### 分享去处
绝大部分分享可以分享到会话,朋友圈,收藏(小程序目前只能分享到会话)。默认分享到会话。
> NOTE:Images or thumbnails used for sharing only support `png`and`jpg`.Network or assets images are OK.<br>
> However,using images from `assets`,you have to add a schema `assets://`。<br>
> For assets image from a particular package,you have to add a query param:`?package=package_name`<br>
> We consider support `file://` in the future,so paths begin with `file://` are ok, but fluwx does nothing<br>
> If no schema or wrong schema proivided,fluwx will load it as network image.Be careful<br>
> Due to the limits of WeChat,the thumbnail must be smaller than 32k(mini-program's is smaller than 120k),you'd better provide <br>
> a qualified thumbnail.Otherwise, `Fluwx` will compress it for you. The result of compression is unpredictable.
### The Destination
The destination of sharing can be SESSION(default),TIMELINE or FAVORITE.However,mini-program only support SESSION.
```dart
///[WeChatScene.SESSION]会话
///[WeChatScene.TIMELINE]朋友圈
......@@ -24,24 +25,24 @@
FAVORITE
}
```
### 返回值处理
`fluwx.share(model)`返回的是一个`Map`
### Return
the return value of `fluwx.share(model)` is `Map`
```dart
{
"platform":"Android",//或者iOS
result:true //或者false,取决于WXApi.sendRequest()的结果
"platform":"Android",//or iOS
result:true //or false,depends on WXApi.sendRequest()
}
```
### 分享文本
### Share Text
```dart
fluwx.share(WeChatShareTextModel(
text: "text from fluwx",
transaction: "transaction}",//仅在android上有效,下同。
transaction: "transaction}",
scene: scene
));
```
### 分享图片
### Share Image
```dart
fluwx.share(WeChatShareImageModel(
image: _imagePath,
......@@ -50,9 +51,9 @@
scene: scene,
description: "image"));
```
> 注意:如果不指定 `thumbnail`,那么`Fluwx`将尝试从`image`中获取缩略图。
> NOTE:`Fluwx` will create thumbnail from `image` if thumbnail isn't provided.
### 分享音乐
### Share Music
```dart
var model = WeChatShareMusicModel(
title: _title,
......@@ -64,9 +65,8 @@
fluwx.share(model);
```
音乐的分享有两种:`musicUrl``musicLowBandUrl`。这两种形式是不共存的,如果
都二者都进行了赋值,那么只会读取`musicUrl`
### 分享视频
Two kind of music:`musicUrl``musicLowBandUrl`.They are not coexisting,if both are assigned, only`musicUrl` will be used.
### Share Video
```dart
var model = new WeChatShareVideoModel(
videoUrl: _videoUrl,
......@@ -78,9 +78,8 @@
);
fluwx.share(model);
```
视频的分享有两种:`videoUrl``videoLowBandUrl`。这两种形式是不共存的,如果
都二者都进行了赋值,那么只会读取`videoUrl`
### 分享小程序
Two kind of video:`videoUrl``videoLowBandUrl`.They are not coexisting,if both are assigned, only `videoUrl` will be used.
### Share Mini Program
```dart
var model =new WeChatShareMiniProgramModel(
webPageUrl: _webPageUrl,
......@@ -92,7 +91,7 @@
);
fluwx.share(model);
```
`miniProgramType`仅支持三种:
`miniProgramType` only suports the following values:
* MINI_PROGRAM_TYPE_RELEASE
* MINI_PROGRAM_TYPE_TEST
* MINI_PROGRAM_TYPE_PREVIEW
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论