如何在Flutter中使用external_app_launcher包打开Spotify深度链接
实现跳转Spotify指定深度链接页面的方法
你当前代码仅能打开首页的原因是没有传入目标深度链接参数,按照以下方式修改即可:
1. 完整调用代码
// 你的目标Spotify页面路径 final targetPlaylistPath = 'playlist/37i9dQZF1DWX5ZOsG2Ogi1?si=41c6a392cf7d4a2b'; await LaunchApp.openApp( androidPackageName: 'com.spotify.music', // iOS端拼接Spotify scheme和目标路径 iosUrlScheme: 'spotify://$targetPlaylistPath', // Android端传入完整https格式的深度链接即可 deeplink: 'https://open.spotify.com/$targetPlaylistPath', // 可选配置:用户未安装Spotify时是否跳转应用商店,不需要可设为false openStore: true, );
2. iOS端额外前置配置
需要在项目ios/Runner/Info.plist文件中添加如下配置,否则iOS系统会禁止拉起Spotify应用:
<key>LSApplicationQueriesSchemes</key> <array> <string>spotify</string> </array>
注意事项
- 如果需要跳转其他类型的Spotify页面,只需要替换
targetPlaylistPath的内容即可,比如艺人页路径为artist/xxx、专辑页路径为album/xxx - Android端可以直接传入https格式的Spotify公开链接,系统会自动唤醒Spotify应用加载对应页面
内容的提问来源于stack exchange,提问作者Rabbiot Rabbiot
相关产品推荐
相关产品推荐

