flutter_qq_bridge 0.0.3

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 49

flutter_qq_bridge

支持 Android / iOS:

1.登录 2.获取用户基本信息 3.分享(目前仅支持新闻类型)

Update

version 0.0.2 -> 添加 TencentOpenAPI.framework

Getting Started

1. 环境配置

Android

AndroidManifest
...

<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"/>

...

<activity
    android:name="com.tencent.connect.common.AssistActivity"
    android:configChanges="orientation|keyboardHidden"
    android:screenOrientation="behind"
    android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity
    android:name="com.tencent.tauth.AuthActivity"
    android:launchMode="singleTask"
    android:noHistory="true" >
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="tencent${your app_id}" />
    </intent-filter>
</activity>

iOS

详情请参考腾讯官方文档及网络上更多优秀解答

2. Flutter 中使用

import 'package:flutter_qq_bridge/flutter_qq_bridge.dart';

① 初始化

await FlutterQqBridge.registerQq('$androidAppId', '$iOSAppId');

② QQ 登录

var res = await FlutterQqBridge.login();

if (res.code == 0) { // success
  _tencent = Tencent.fromJson(res.message);
  
  // update UI
  setState(() {
    _loginRes = 'openId:${_tencent.openId}, accessToken:${_tencent.accessToken}, expires:${_tencent.expiresTime}';
  });
}

③ 获取用户基本信息(登录之后)

if (_tencent != null) { // _tencent from login success
  var res = await FlutterQqBridge.getUserInfo(_tencent);
  if (res.code == 0) {
    _qqUser = QqUser.fromJson(res.message);
    
    // update UI
    setState(() {
      _userInfo = 'nickname:${_qqUser.nickname}, '
          'gender:${_qqUser.gender}, '
          'year:${_qqUser.year}, '
          'province:${_qqUser.province}, '
          'city:${_qqUser.city}, '
          'figureurl:${_qqUser.figureurl},';
    });
  }
}

④ 分享

分享给好友:

var res = await FlutterQqBridge.shareToQQ(ShareQQContent(
  title: 'Remeet-只有00后的脱单神器',
  summary: '我们只想做个简单干净的聊天软件,帮你遇见喜欢的人。',
  targetUrl: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.haisong.remeet',
  imageUrl: 'http://pp.myapp.com/ma_icon/0/icon_52621236_1517135649/96',
  appName: 'Remeet',
));

// update UI
setState(() {
  _shareQqRes = 'share -> code: ${res.code}, message:${res.message}';
});

分享到 QQ 空间:

var res = await FlutterQqBridge.shareToQzone(ShareQqContent(
  title: 'Remeet-只有00后的脱单神器',
  summary: '我们只想做个简单干净的聊天软件,帮你遇见喜欢的人。',
  targetUrl: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.haisong.remeet',
  imageUrl: 'http://pp.myapp.com/ma_icon/0/icon_52621236_1517135649/96',
  appName: 'Remeet',
));

setState(() {
  _shareQzoneRes = 'share -> code: ${res.code}, message:${res.message}';
});

[0.0.1] - TODO: Add release date.

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_qq_bridge/flutter_qq_bridge.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => new _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _loginRes = 'Unknown';
  String _shareQqRes = 'Unknown';
  String _shareQzoneRes = 'Unknown';
  String _userInfo = 'Unknown';

  Tencent _tencent;
  QqUser _qqUser;

  _login() async {
    var res = await FlutterQqBridge.login();

    if (res.code == 0) {
      _tencent = Tencent.fromJson(res.message);
      setState(() {
        _loginRes = 'openId:${_tencent.openId}, accessToken:${_tencent.accessToken}, expires:${_tencent.expiresTime}';
      });
    }
  }

  _shareQq() async {
    var res = await FlutterQqBridge.shareToQQ(ShareQqContent(
      title: 'Remeet-只有00后的脱单神器',
      summary: '我们只想做个简单干净的聊天软件,帮你遇见喜欢的人。',
      targetUrl: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.haisong.remeet',
      imageUrl: 'http://pp.myapp.com/ma_icon/0/icon_52621236_1517135649/96',
      appName: 'Remeet',
    ));

    setState(() {
      _shareQqRes = 'share -> code: ${res.code}, message:${res.message}';
    });
  }

  _shareQzone() async {
    var res = await FlutterQqBridge.shareToQzone(ShareQqContent(
      title: 'Remeet-只有00后的脱单神器',
      summary: '我们只想做个简单干净的聊天软件,帮你遇见喜欢的人。',
      targetUrl: 'http://a.app.qq.com/o/simple.jsp?pkgname=com.haisong.remeet',
      imageUrl: 'http://pp.myapp.com/ma_icon/0/icon_52621236_1517135649/96',
      appName: 'Remeet',
    ));

    setState(() {
      _shareQzoneRes = 'share -> code: ${res.code}, message:${res.message}';
    });
  }

  _user() async {
    if (_tencent != null) {
      var res = await FlutterQqBridge.getUserInfo(_tencent);
      if (res.code == 0) {
        _qqUser = QqUser.fromJson(res.message);
        setState(() {
          _userInfo = 'nickname:${_qqUser.nickname}, '
              'gender:${_qqUser.gender}, '
              'year:${_qqUser.year}, '
              'province:${_qqUser.province}, '
              'city:${_qqUser.city}, '
              'figureurl:${_qqUser.figureurl},';
        });
      }
    }
  }

  @override
  Widget build(BuildContext context) {
    FlutterQqBridge.registerQq('1107027380', '1106056827');
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Padding(padding: EdgeInsets.all(30.0),
                  child: GestureDetector(
                    onTap: _login,
                    child: Text('qq login \n $_loginRes', style: TextStyle(fontSize: 20.0, color: Colors.black),),
                  )
              ),

              Padding(padding: EdgeInsets.all(30.0),
                  child: GestureDetector(
                    onTap: _user,
                    child: Text('qq user \n $_userInfo', style: TextStyle(fontSize: 20.0, color: Colors.black),),
                  )
              ),

              Padding(padding: EdgeInsets.all(30.0),
                  child: GestureDetector(
                    onTap: _shareQq,
                    child: Text('qq share \n $_shareQqRes', style: TextStyle(fontSize: 20.0, color: Colors.black),),
                  )
              ),

              Padding(padding: EdgeInsets.all(30.0),
                  child: GestureDetector(
                    onTap: _shareQzone,
                    child: Text('qzone share \n $_shareQzoneRes', style: TextStyle(fontSize: 20.0, color: Colors.black),),
                  )
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_qq_bridge: ^0.0.3

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_qq_bridge/flutter_qq_bridge.dart';
  
Version Uploaded Documentation Archive
0.0.3 Aug 15, 2018 Go to the documentation of flutter_qq_bridge 0.0.3 Download flutter_qq_bridge 0.0.3 archive
0.0.2 Aug 8, 2018 Go to the documentation of flutter_qq_bridge 0.0.2 Download flutter_qq_bridge 0.0.2 archive
0.0.1 Jul 27, 2018 Go to the documentation of flutter_qq_bridge 0.0.1 Download flutter_qq_bridge 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
17
Health:
Code health derived from static analysis. [more]
90
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7
  • Flutter: 1.0.0

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs (-10 points)

48 out of 48 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Maintenance suggestions

The description is too short. (-20 points)

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-v0.1 release. (-10 points)

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8