Mah*_*thy 3 url launcher flutter
ElevatedButton(
onPressed: () async {
const url ='https://www.facebook.com';
if (await canLaunch(url)) {
await launch(url,forceWebView: true,enableJavaScript: true);
} else {
// can't launch url
}
},
);
Run Code Online (Sandbox Code Playgroud)
I/UrlLauncher( 7566): component name for https://www.facebook.com is null
Run Code Online (Sandbox Code Playgroud)
小智 8
添加每个平台的查询,请按照此链接中的文档进行操作URL Launcher API Reference
iOS 将传递给 canLaunchUrl 的任何 URL 方案添加为 Info.plist 文件中的 LSApplicationQueriesSchemes 条目。
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
Run Code Online (Sandbox Code Playgroud)
Android 从 API 30 开始 Android 需要在 AndroidManifest.xml 中配置包可见性,否则 canLaunchUrl 将返回 false。必须将元素作为根元素的子元素添加到清单中。
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
<!-- If your app makes calls -->
<intent>
<action android:name="android.intent.action.DIAL" />
<data android:scheme="tel" />
</intent>
<!-- If your sends SMS messages -->
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="smsto" />
</intent>
<!-- If your app sends emails -->
<intent>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
</intent>
</queries>
Run Code Online (Sandbox Code Playgroud)
这对我有用!
| 归档时间: |
|
| 查看次数: |
3446 次 |
| 最近记录: |