Skip to content

Commit

Permalink
Call AuthorizeAndPlayURI on main thread (#221)
Browse files Browse the repository at this point in the history
* fix: call a`AuthorizeAndPlayURI` on main thread which internally calls `UIAppliation.openURL`

* set min supported iOS version to 12.0

* fix the indentation
  • Loading branch information
haashem authored Oct 3, 2024
1 parent 555f2de commit 20d6f85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions ios/Classes/SwiftSpotifySdkPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ public class SwiftSpotifySdkPlugin: NSObject, FlutterPlugin {
if accessToken != nil {
appRemote?.connect()
} else {
let appRemote = self.appRemote
Task {
// Note: A blank string will play the user's last song or pick a random one.
if await appRemote?.authorizeAndPlayURI(spotifyUri, asRadio: asRadio ?? false, additionalScopes: scopes) == false {
throw SpotifyError.spotifyNotInstalledError
// Note: A blank string will play the user's last song or pick a random one.
self.appRemote?.authorizeAndPlayURI(spotifyUri, asRadio: asRadio ?? false, additionalScopes: scopes) { success in
if (!success) {
self.connectionStatusHandler?.connectionResult?(FlutterError(code: "spotifyNotInstalled", message: "Spotify app is not installed", details: nil))
}
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions ios/spotify_sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Unofficial Spotify Flutter SDK.
s.source = { :path => '.' }
s.source_files = 'Classes/**/*'
s.dependency 'Flutter'
s.platform = :ios, '9.0'
s.ios.deployment_target = '9.0'
s.platform = :ios, '12.0'
s.ios.deployment_target = '12.0'
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'VALID_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
s.swift_version = '5.0'
Expand Down

0 comments on commit 20d6f85

Please sign in to comment.