繁体   English   中英

如何在颤振中重定向到 iOS 上的 whatsapp

[英]how to redirect to whatsapp on iOS in flutter

发生的事情是我制作了一个带有重定向到whatsapp的按钮的应用程序问题是在 Android 中如果它可以工作而不在 iOS 中我已经使用正常方法完成了我认为您必须将某些内容放入iOS文件中但是我不知道 那是

谢谢。

ListTile(
    leading:  Icon(FontAwesomeIcons.headset,color: Colors.black,),
    title: Text('Centro de ayuda '),
    onTap: () async => await launch("https://wa.me/${numero}?text=Hola mi nombre es "+prefs.name+' y necesito ayuda con mi orden de Timugo')            
)

你可以添加 Flutter 启动 WhatsApp。

安装:首先,在 pubspec.yaml 文件中添加 flutter_launch_whatsapp 作为依赖项。

在 iOS 中添加以下 Info.plist :

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>whatsapp</string>
</array>

例子:

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

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

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

class _MyAppState extends State<MyApp> {

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

  void whatsAppOpen() async {
    await FlutterLaunch.launchWathsApp(phone: "5534992016545", message: "Hello");
  }

  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: new Text('Plugin example app'),
        ),
        body: new Center(
          child: FlatButton(
            child: Text("Open WhatsApp"),
            onPressed: () {
              whatsAppOpen();
            },
          )
        ),
      ),
    );
  }
}

以上参考来自: https : //pub.dev/packages/flutter_launch

或者

你可以试试下面的代码:

var whatsappUrl ="whatsapp://send?phone=$phone";
await canLaunch(whatsappUrl)? launch(whatsappUrl):print("open whatsapp app link or do a snackbar with notification that there is no whatsapp installed");

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM