flutter 集成微信登录、分享功能

1.微信开放平台创建应用

点击“创建移动应用”,填写相关信息后提交审核

审核通过后申请分享和登录的权限

2.ios相关配置

1.Associated Domains:

在xcode中依次点击:左侧根目录Runner--》TARGETS下的Runner--》Signing & Capabilities--》+Capability--》添加Associated Domains

在Domains中填写域名,例如你的域名为www.abc.com,那个填写的格式为:applinks:www.abc.com

2.apple-app-site-association文件配置

创建文件并在文件内写入:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "teamID.BundleID",
                "paths": [ "/app/*" ]
            }
        ]
    }
}

appID由teamID和BundleID组成,均可在apple开发者中心查看

certificates,identifiers&Profiles下点击identifiers,点击自己的应用后可以看到Edit your App ID Configuration下有应用的相关信息,teamID为App ID Prefix​下内容

将获取到的teamID和BundleID按照teamID.BundleID填入appID后

将配置好的apple-app-site-association文件部署到服务器上

3.URLscheme

在xcode中依次点击:左侧根目录Runner--》TARGETS下的Runner--》Info--》点击URL Types展开--》在​Identifier​​​写入weixin​

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是flutter集成fluwx实现微信登录的步骤和代码: 1. 首先在项目的 pubspec.yaml 文件中添加依赖: ```dart dependencies: fluwx: ^1.2.0 ``` 2. 在项目的 AndroidManifest.xml 文件中添加以下配置: ```xml <activity android:name=".wxapi.WXEntryActivity" android:exported="true" android:launchMode="singleTask" android:taskAffinity="" android:theme="@android:style/Theme.Translucent.NoTitleBar" /> ``` 3. 在项目的 Info.plist 文件中添加以下配置: ```xml <key>CFBundleURLTypes</key> <array> <dict> <key>CFBundleTypeRole</key> <string>Editor</string> <key>CFBundleURLName</key> <string>weixin</string> <key>CFBundleURLSchemes</key> <array> <string>你的AppID</string> </array> </dict> </array> <key>LSApplicationQueriesSchemes</key> <array> <string>weixin</string> </array> ``` 4. 在你的代码中引入 fluwx 包: ```dart import 'package:fluwx/fluwx.dart' as fluwx; ``` 5. 在你的代码中注册 fluwx: ```dart fluwx.registerWxApi( appId: "你的AppID", universalLink: "你的Universal Link", ); ``` 6. 在你的代码中实现微信登录: ```dart // 检查是否安装微信 bool isInstalled = await fluwx.isWeChatInstalled(); if (!isInstalled) { // 提示用户安装微信 return; } // 发送微信登录请求 fluwx.sendWeChatAuth( scope: "snsapi_userinfo", // 授权作用域 state: "wechat_login", // 自定义状态值 ).then((response) { // 处理登录结果 if (response.errCode == fluwx.WeChatSDK.ERR_OK) { // 登录成功,获取用户信息 String code = response.code; fluwx .getWeChatUserInfo( code: code, ) .then((userInfo) { // 处理用户信息 }); } else { // 登录失败 } }); ``` 以上就是使用 fluwx 实现微信登录的全部步骤和代码。需要注意的是,你需要将代码中的 "你的AppID" 和 "你的Universal Link" 替换为你在微信开放平台上注册的应用的实际值。同时,你还需要在微信开放平台上配置你的应用,以便 fluwx 能够正确地与微信进行交互。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值