打印/下载
配置
案例

支付宝(iOS)

flutter/ios/Runner

  <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>alipay</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>${ YOUR APP SCHEME NAME }</string>
            </array>
        </dict>
    </array>

微信(iOS)

flutter/ios/Runner

  <key>LSApplicationQueriesSchemes</key>
    <array>
        <string>weixin</string>
        <string>weixinULAPI</string>
    </array>
    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>
  • 配置项目的Universal Links,同时和微信公众平台配置的保持一致
  • Xcode打开Associated Domains开关,将Universal Links域名加到配置上
  • 检查有没有WechatOpenSDK,没有的话用CocoaPods 集成
  • 在 Xcode 中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序 id
  • 在Xcode中,选择你的工程设置项,选中“TARGETS”一栏,在 “info”标签栏的“LSApplicationQueriesSchemes“添加weixin 和weixinULAPI(重要)
  • 微信文档

UniversalLink(iOS)

https://webmis.vip/.well-known/apple-app-site-association

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "ABCDE12345(团队ID).com.example.app(包名)",
        "paths": ["/app/*"]
      }
    ]
  }
}

xcode > Capabilities > Associated Domains

applinks:webmis.vip
applinks:www.webmis.vip
  • 从这里填入的域名请求文件apple-app-site-association
import 'package:flutter/material.dart';
import 'package:webmis/library/plus/pay.dart';

class Demo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => DemoState();
}
class DemoState extends State<Demo> {

  Map<String,dynamic> _location;
  var _mapController;

  /* 构造函数 */
  @override
  void initState() {
    super.initState();
  }

  /* 销毁 */
  @override
  void dispose(){
    super.dispose();
    MapGeolocation.dispose();
  }

  /* Widget */
  @override
  // ignore: must_call_super
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          GestureDetector(
            child: Container(
              height: 30,
              child: Center(
                child: Text('支付宝'),
              ),
            ),
            onTap: (){
              Pay.alipay('https://webmis.vip/api',{}).then((res){
                setState(()=>_payRes=res.toString());
              }).catchError((e){
                setState(()=>_payRes=e.toString());
              });
            },
          ),
          GestureDetector(
            child: Container(
              height: 30,
              child: Center(
                child: Text('微信'),
              ),
            ),
            onTap: (){
              Pay.wxapy('https://webmis.vip/api',{}).then((res){
                setState(()=>_payRes=res.toString());
              }).catchError((e){
                setState(()=>_payRes=e.toString());
              });
            },
          ),
          Text(_payRes),
        ],
      ),
    );
  }

}
{{copy}}