我尝试启动电子邮件页面并拨打电话。我尝试 URL 启动器在 ios 上执行与在 Android 上相同的操作。
我使用这个 URL 启动器示例:
Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
margin: const EdgeInsets.symmetric(vertical: 5),
color: Theme.of(context).primaryColor,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text('${_con.restaurant.phone} \n${_con.restaurant.mobile}',
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.bodyText1,),
),
SizedBox(width: 10),
SizedBox(
width: 42,
height: 42,
child: FlatButton(
padding: EdgeInsets.all(0),
onPressed: () {
launch("tel:${_con.restaurant.mobile}");
},
child: Icon(
Cretello_app.contact2,
color: Theme.of(context).primaryColor,
size: 24,
),
color: Theme.of(context).accentColor.withOpacity(0.9),
shape: StadiumBorder(),
),
),
],
),
),
iOS 模拟器没有安装默认的电子邮件和电话应用程序。这就是为什么
tel
和 mailto
链接无法在 iOS 模拟器中打开,如 docs 中所述。
仅当安装了应用程序时才支持 URL 方案 可以支持它们的设备。例如,iOS 模拟器没有 安装了默认电子邮件或电话应用程序,因此无法打开
:或tel
链接。mailto:
添加到您的 Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>mailto</string>
<string>tel</string>
</array>