我们可以通过点击 Flutter 应用中的按钮进行 WhatsApp 视频通话吗?
问问题
401 次
2 回答
1
您可以参考 WhatsApp 官方网站并使用通用链接(查看更多)。例如,您可以sample text
使用以下 URL 发送:
const url = "https://wa.me/<number>?text=SAMPLE TEXT";
如果您尝试打开此 URL 并且用户在他/她的手机中有 WhatsApp,则此消息将在此应用程序中打开。您可以text
用给定的关键字替换来拨打电话。
于 2021-07-09T06:23:22.143 回答
0
然后添加此依赖项:
dependencies:
call_with_whatsapp: ^0.0.1
然后 :
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:call_with_whatsapp/call_with_whatsapp.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
void _requestPermission() {
CallWithWhatsapp.requestPermissions().then((x){
print("success");
}).catchError((e){
print(e);
});
}
void _openStore() {
CallWithWhatsapp.openInPlayStore().then((x){
print("success");
}).catchError((e){
print(e);
});
}
void _initiateCall() {
CallWithWhatsapp.initiateCall("01753230535").then((x){
print("success");
}).catchError((e){
print(e);
});
}
void _createNewContact() {
CallWithWhatsapp.createContact("AAAAA AAAA", "0111111").then((x){
print("success");
}).catchError((e){
print(e);
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body:SafeArea(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
onPressed: _requestPermission,
child: Text(
"Request permission",
),
),
RaisedButton(
onPressed: _openStore,
child: Text(
"Open In Playstore",
),
),
RaisedButton(
onPressed: _initiateCall,
child: Text(
"Initiate Call",
),
),
RaisedButton(
onPressed: _createNewContact,
child: Text(
"Create contact",
),
),
],
),
),
),
),
);
}
}
于 2021-12-23T06:33:39.120 回答