flutter_qq 0.0.4

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

flutter_qq

Flutter plugin for QQ.

Getting Started

android

  1. Add the following to your project's AndroidManifest.xml and replace [QQ APPId] with your own QQ AppId
<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="[QQ APPId]" />
    </intent-filter>
</activity>

iOS

  1. Add the followings to your project's Info.plist
<key>CFBundleURLTypes</key>
<array>
  <dict>
    <key>CFBundleTypeRole</key>
    <string>Editor</string>
    <key>CFBundleURLName</key>
    <string>tencent</string>
    <key>CFBundleURLSchemes</key>
    <array>
      <string>tencent1107493622</string>
    </array>
  </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
  <string>mqq</string>
  <string>mqqapi</string>
  <string>mqqwpa</string>
  <string>mqqbrowser</string>
  <string>mttbrowser</string>
  <string>mqqOpensdkSSoLogin</string>
  <string>mqqopensdkapiV2</string>
  <string>mqqopensdkapiV3</string>
  <string>mqqopensdkapiV4</string>
  <string>wtloginmqq2</string>
  <string>mqzone</string>
  <string>mqzoneopensdk</string>
  <string>mqzoneopensdkapi</string>
  <string>mqzoneopensdkapi19</string>
  <string>mqzoneopensdkapiV2</string>
  <string>mqqapiwallet</string>
  <string>mqqopensdkfriend</string>
  <string>mqqopensdkdataline</string>
  <string>mqqgamebindinggroup</string>
  <string>mqqopensdkgrouptribeshare</string>
  <string>tencentapi.qq.reqContent</string>
  <string>tencentapi.qzone.reqContent</string>
</array>
<key>NSMicrophoneUsageDescription</key>
<string>microphoneUsageDescription</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
<key>NSCameraUsageDescription</key>
<string>cameraUsageDesciption</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIBackgroundModes</key>
<array>
  <string>fetch</string>
  <string>remote-notification</string>
</array>
  1. Add the followings to your project's AppDelegate.m
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
            options:(NSDictionary<NSString*, id> *)options
{
    NSString * urlStr = [url absoluteString];
    [[NSNotificationCenter defaultCenter]
     postNotificationName:@"QQ" object:nil userInfo:@{@"url":urlStr}];
    return YES;
}

Not Complete

  1. SHARE_TO_QQ_TYPE.AUDIO
  2. SHARE_TO_QZONE_TYPE.PUBLISH_VIDEO
  3. SHARE_TO_QQ_TYPE.APP & SHARE_TO_QZONE_TYPE.APP
  4. SHARE_TO_QZONE_TYPE.IMAGE_TEXT,android & ios don't have same action

Api Documentation

Data struct

  1. QQResult
fieldtypedescription
codeint错误码 0:成功 1:发生错误 2:用户取消
messageString错误详情
responseMap只在login时返回

response格式为:

{
  "openid":"xxxxx",
  "accessToken":"XXXXXXXXX",
  "expiresAt":"xxxxxxxxx",
}
  1. QZONE_FLAG(enum)
fielddescription
DEFAULT默认
AUTO_OPEN在好友选择列表会自动打开分享到qzone的弹窗
ITEM_HIDE在好友选择列表隐藏了qzone分享选项
  1. SHARE_TO_QQ_TYPE(enum)
fielddescription
DEFAULT默认
AUDIO音频
IMAGE图片
APP应用
  1. SHARE_TO_QZONE_TYPE(enum)
fielddescription
IMAGE_TEXT默认
PUBLISH_MOOD说说
PUBLISH_VIDEO视频
IMAGE图片
APP应用
  1. ShareQQContent
fieldtypedescription
shareTypeSHARE_TO_QQ_TYPE分享类型
titleStringtitle
targetUrlStringtargetUrl
summaryStringsummary
imageUrlStringimageUrl(shareType为IMAGE时,只支持imageLocalUrl)
imageLocalUrlStringimageLocalUrl
appNameStringappName
audioUrlStringaudioUrl(只有shareType为AUDIO时支持)
qzoneFlagQZONE_FLAGqzone flag
  1. ShareQzoneContent
fieldtypedescription
shareTypeSHARE_TO_QZONE_TYPE分享类型
titleStringtitle
targetUrlStringtargetUrl
summaryStringsummary
imageUrlsList<String>imageUrl
sceneStringscene
callbackStringcallback

Method

  1. registerQQ
FlutterQq.registerQQ('YOUR_QQ_APPId');
  1. isQQInstalled
Future<Null> _handleisQQInstalled() async {
  var result = await FlutterQq.isQQInstalled();
  var output;
  if (result) {
    output = "QQ已安装";
  } else {
    output = "QQ未安装";
  }
  setState(() {
    _output = output;
  });
}
  1. login
Future<Null> _handleLogin() async {
  try {
    var qqResult = await FlutterQq.login();
    var output;
    if (qqResult.code == 0) {
      output = "登录成功" + qqResult.response.toString();
    } else if (qqResult.code == 1) {
      output = "登录失败" + qqResult.message;
    } else {
      output = "用户取消";
    }
    setState(() {
      _output = output;
    });
  } catch (error) {
    print("flutter_plugin_qq_example:" + error.toString());
  }
}
  1. shareToQQ
Future<Null> _handleShareToQQ() async {
  ShareQQContent shareContent = new ShareQQContent(
    title: "测试title",
    targetUrl: "https://www.baidu.com",
    summary: "测试summary",
    imageUrl: "http://inews.gtimg.com/newsapp_bt/0/876781763/1000",
  );
  try {
    var qqResult = await FlutterQq.shareToQQ(shareContent);
    var output;
    if (qqResult.code == 0) {
      output = "分享成功";
    } else if (qqResult.code == 1) {
      output = "分享失败" + qqResult.message;
    } else {
      output = "用户取消";
    }
    setState(() {
      _output = output;
    });
  } catch (error) {
    print("flutter_plugin_qq_example:" + error.toString());
  }
}
  1. shareToQzone
Future<Null> _handleShareToQZone() async {
  ShareQzoneContent shareContent = new ShareQzoneContent(
    title: "测试title",
    targetUrl: "https://www.baidu.com",
    summary: "测试summary",
    imageUrls: ["http://inews.gtimg.com/newsapp_bt/0/876781763/1000"],
  );
  try {
    var qqResult = await FlutterQq.shareToQzone(shareContent);
    var output;
    if (qqResult.code == 0) {
      output = "分享成功";
    } else if (qqResult.code == 1) {
      output = "分享失败" + qqResult.message;
    } else {
      output = "用户取消";
    }
    setState(() {
      _output = output;
    });
  } catch (error) {
    print("flutter_plugin_qq_example:" + error.toString());
  }
}

How To Contribute

android

  1. add your own flutter.sdk path to local.properties
flutter.sdk=YOUR_OWN_FLUTTER_SDK_PATH
  1. PR

[0.0.4] - 2018.8.6.

  • fix bug

[0.0.3] - 2018.8.6.

  • fix bug

[0.0.2] - 2018.8.6.

  • support ios
  • complete doc

[0.0.1] - 2018.5.28.

  • support android

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_qq/flutter_qq.dart';
import 'package:image_picker/image_picker.dart';

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

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

class _MyAppState extends State<MyApp> {
  List<File> _images = new List();
  String _output = '---';

  @override
  initState() {
    super.initState();
  }

  Future _chooseImage() async {
    var image = await ImagePicker.pickImage(source: ImageSource.gallery);
    _images.add(image);
  }

  Future<Null> _handleisQQInstalled() async {
    var result = await FlutterQq.isQQInstalled();
    var output;
    if (result) {
      output = "QQ已安装";
    } else {
      output = "QQ未安装";
    }
    setState(() {
      _output = output;
    });
  }

  Future<Null> _handleLogin() async {
    try {
      var qqResult = await FlutterQq.login();
      var output;
      if (qqResult.code == 0) {
        if(qqResult.response==null){
          output = "登录成功qqResult.response==null";
          return;
        }
        output = "登录成功" + qqResult.response.toString();
      } else {
        output = "登录失败" + qqResult.message;
      }
      setState(() {
        _output = output;
      });
    } catch (error) {
      print("flutter_plugin_qq_example:" + error.toString());
    }
  }

  Future<Null> _handleShareToQQ() async {
    // ShareQQContent shareContent = new ShareQQContent(
    //   shareType: SHARE_TO_QQ_TYPE.DEFAULT,
    //   title: "测试title",
    //   targetUrl: "https://www.baidu.com",
    //   summary: "测试summary",
    //   imageUrl: "http://inews.gtimg.com/newsapp_bt/0/876781763/1000",
    // );
    ShareQQContent shareContent = new ShareQQContent(
      shareType: SHARE_TO_QQ_TYPE.IMAGE,
      title: "测试title",
      targetUrl: "https://www.baidu.com",
      summary: "测试summary",
      imageLocalUrl: _images[0].path
    );
    try {
      var qqResult = await FlutterQq.shareToQQ(shareContent);
      var output;
      if (qqResult.code == 0) {
        output = "分享成功";
      } else if (qqResult.code == 1) {
        output = "分享失败" + qqResult.message;
      } else {
        output = "用户取消";
      }
      setState(() {
        _output = output;
      });
    } catch (error) {
      print("flutter_plugin_qq_example:" + error.toString());

    }
  }

  Future<Null> _handleShareToQZone() async {
    ShareQzoneContent shareContent = new ShareQzoneContent(
      shareType: SHARE_TO_QZONE_TYPE.IMAGE_TEXT,
      title: "测试title",
      targetUrl: "https://www.baidu.com",
      summary: "测试summary",
      imageUrl: "http://inews.gtimg.com/newsapp_bt/0/876781763/1000",
    );
//     List<String> paths = new List();
//     for(File image in _images){
//       paths.add(image.path);
//     }
//     ShareQzoneContent shareContent = new ShareQzoneContent(
//       shareType: SHARE_TO_QZONE_TYPE.IMAGE,
//       title: "测试title",
//       targetUrl: "https://www.baidu.com",
//       summary: "测试summary",
//       imageUrls: paths,
//     );
    try {
      var qqResult = await FlutterQq.shareToQzone(shareContent);
      var output;
      if (qqResult.code == 0) {
        output = "分享成功";
      } else if (qqResult.code == 1) {
        output = "分享失败" + qqResult.message;
      } else {
        output = "用户取消";
      }
      setState(() {
        _output = output;
      });
    } catch (error) {
      print("flutter_plugin_qq_example:" + error.toString());
    }
  }

  @override
  Widget build(BuildContext context) {
    FlutterQq.registerQQ('1107493622');
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin QQ example app'),
        ),
        body: new Column(
          children: <Widget>[
            new Text(_output),
            new RaisedButton(
              onPressed: _chooseImage,
              child: new Text('chooseImage'),
            ),
            new RaisedButton(
              onPressed: _handleisQQInstalled,
              child: new Text('isQQInstalled'),
            ),
            new RaisedButton(
              onPressed: _handleLogin,
              child: new Text('login'),
            ),
            new RaisedButton(
              onPressed: _handleShareToQQ,
              child: new Text('ShareToQQ'),
            ),
            new RaisedButton(
              onPressed: _handleShareToQZone,
              child: new Text('ShareToQZone'),
            ),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_qq: ^0.0.4

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/flutter_qq.dart';
  
Version Uploaded Documentation Archive
0.0.4 Aug 6, 2018 Go to the documentation of flutter_qq 0.0.4 Download flutter_qq 0.0.4 archive
0.0.3 Aug 6, 2018 Go to the documentation of flutter_qq 0.0.3 Download flutter_qq 0.0.3 archive
0.0.2 Aug 6, 2018 Go to the documentation of flutter_qq 0.0.2 Download flutter_qq 0.0.2 archive
0.0.1 May 28, 2018 Go to the documentation of flutter_qq 0.0.1 Download flutter_qq 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
52
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]
67
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)

70 out of 70 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 >=2.0.0-dev.28.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
Dev dependencies
image_picker ^0.4.6