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

English doc support

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