flutter_wechat 0.1.5

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 89

flutter_wechat

A flutter plugin to use wechat.

Features

  • [X] Add Login
  • [X] Add Pay
  • [ ] Support LocalImage
  • [ ] Support 分享小程序

Install

Add this to your package's pubspec.yaml file:

dependencies:
  flutter_wechat: "^0.1.5"

Getting Started

  • Android
    • For Android, you must do the following before you can use the plugin:
      • Add the permissions to your AndroidManifest.xml
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
        <uses-permission android:name="android.permission.READ_PHONE_STATE" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
        <uses-permission android:name="android.permission.WRITE_SETTINGS" />
      
           如果想要响应微信resp需要在mainActivity同级目录下创建wxapi文件夹      下面新建WXEntryACtivity集成Activity      例如:
    private IWXAPI api;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        api = WXAPIFactory.createWXAPI(this, "wxb25d3dec3db1affc", false);
        onNewIntent(getIntent());
        finish();
    }

        @Override
    public void onReq(BaseReq baseReq) {

    }

    @Override
    public void onResp(BaseResp baseResp) {
        sendBroadcastToWechat(baseResp);
    }

    private void sendBroadcastToWechat(BaseResp baseResp) {
        Intent intent = new Intent();
        intent.setAction("sendResp");
        if (baseResp instanceof SendAuth.Resp) {
            SendAuth.Resp resp = (SendAuth.Resp) (baseResp);
            intent.putExtra("code", resp.errCode == 0 ? resp.code : "-1");
            intent.putExtra("type", "SendAuthResp");
            sendBroadcast(intent);
        } else {
            intent.setAction("sendResp");
            intent.putExtra("code", baseResp.errCode + "");
            intent.putExtra("type", "ShareResp");
            sendBroadcast(intent);
        }
    }
    protected void onNewIntent(Intent intent) {
        api.handleIntent(intent, this);
    }
     // ios 8.x or older
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
{
     NSString * urlStr = [url absoluteString];
    [[NSNotificationCenter defaultCenter]
     postNotificationName:@"WeChat" object:nil userInfo:@{@"url":urlStr}];
    return YES;
}

// ios 9.0+
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options
{
    NSString * urlStr = [url absoluteString];
    [[NSNotificationCenter defaultCenter]
     postNotificationName:@"WeChat" object:nil userInfo:@{@"url":urlStr}];
    return YES;
}

How to use

import 'package:flutter_wechat/flutter_wechat.dart';
注册
await FlutterWechat.registerWechat("wxxxxxx");// 微信注册需要在你需要的地方注册,最好是app首页
分享
await FlutterWechat.shareText(text: "test", type:0,);//文字分享 type 0 聊天页面 1 朋友圈
await FlutterWechat.shareImage(imgUrl: "xxx", type:0,);
await FlutterWechat.shareMusic(imgUrl: "xxx", musicUrl:"",title:"",description:"",musicDataUrl:"",musicLowBandDataUrl:"",musicLowBandUrl:"",type:0,);
await FlutterWechat.shareVideo(imgUrl: "xxx", videoUrl:"",title:"",description:"",videoLowBandUrl:"",type:0,);
await FlutterWechat.shareWebPage(imgUrl: "xxx", webpageUrl:"",title:"",description:"",type:0,);
登录
await FlutterWechat.login(scope:"",state:"");
支付
await FlutterWechat.pay(partnerId: "",prepayId: "",nonceStr: "",timeStampe: "",sign: "",package: "",appId: "",);//具体参考微信参数传递
返回直接添加回调
.then((state){print(state)})

[0.0.1] - 2018.4.17

  • Support wechatShare.

[0.0.2] - 2018.4.18

  • change README.md

[0.0.7] - 2018.4.18

  • 移除调试输出

[0.0.9] - 2018.4.19

  • 增加微信登录

[0.1.0] - 2018.4.19

  • android ios统一返回

[0.1.2] - 2018.4.22

  • 支付

[0.1.5] - 2018.7.2

  • 删除测试Event回调

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_wechat: "^0.1.5"

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


      import 'package:flutter_wechat/flutter_wechat.dart';
  
Version Uploaded Documentation Archive
0.1.5 Jul 3, 2018 Go to the documentation of flutter_wechat 0.1.5 Download flutter_wechat 0.1.5 archive
0.1.2 Apr 22, 2018 Go to the documentation of flutter_wechat 0.1.2 Download flutter_wechat 0.1.2 archive
0.1.1 Apr 22, 2018 Go to the documentation of flutter_wechat 0.1.1 Download flutter_wechat 0.1.1 archive
0.1.0 Apr 21, 2018 Go to the documentation of flutter_wechat 0.1.0 Download flutter_wechat 0.1.0 archive
0.0.9 Apr 19, 2018 Go to the documentation of flutter_wechat 0.0.9 Download flutter_wechat 0.0.9 archive
0.0.8 Apr 19, 2018 Go to the documentation of flutter_wechat 0.0.8 Download flutter_wechat 0.0.8 archive
0.0.7 Apr 18, 2018 Go to the documentation of flutter_wechat 0.0.7 Download flutter_wechat 0.0.7 archive
0.0.6 Apr 18, 2018 Go to the documentation of flutter_wechat 0.0.6 Download flutter_wechat 0.0.6 archive
0.0.5 Apr 18, 2018 Go to the documentation of flutter_wechat 0.0.5 Download flutter_wechat 0.0.5 archive
0.0.4 Apr 18, 2018 Go to the documentation of flutter_wechat 0.0.4 Download flutter_wechat 0.0.4 archive

All 13 versions...

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3
  • Flutter: 0.5.4

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
79 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
89
Learn more about scoring.

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use flutter_wechat.dart.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run flutter format to format lib/flutter_wechat.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.6 1.14.10
meta 1.1.5
sky_engine 0.0.99
typed_data 1.1.5
vector_math 2.0.6 2.0.7