connectToSpotifyRemote static method
Connects to Spotify Remote, returning a bool
for confirmation
Required parameters are the clientId
and the redirectUrl
to
authenticate with the Spotify Api
iOS specific: You can optionally pass an accessToken
that you have persisted from a previous session. This will prevent redirecting to the Spotify if the token is still valid. It will be ignored on platforms other than iOS.
iOS specific: You can optionally pass a spotifyUri
. A blank string will play the user's last song or pick a random one. It will be ignored on platforms other than iOS.
Throws a PlatformException if connecting to the remote api failed
Throws a MissingPluginException if the method is not implemented on
the native platforms.
Implementation
static Future<bool> connectToSpotifyRemote(
{required String clientId,
required String redirectUrl,
String spotifyUri = '',
bool asRadio = false,
String? scope,
String playerName = 'Spotify SDK',
String? accessToken}) async {
try {
return await _channel.invokeMethod(MethodNames.connectToSpotify, {
ParamNames.clientId: clientId,
ParamNames.redirectUrl: redirectUrl,
ParamNames.playerName: playerName,
ParamNames.accessToken: accessToken,
ParamNames.scope: scope,
ParamNames.spotifyUri: spotifyUri,
ParamNames.asRadio: asRadio,
});
} on Exception catch (e) {
_logException(MethodNames.connectToSpotify, e);
rethrow;
}
}