@wwdrew/expo-spotify-sdk 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +32 -2
  2. package/android/build.gradle +4 -5
  3. package/android/libs/SETUP.md +9 -24
  4. package/android/spotify-native-sdk.gradle +118 -0
  5. package/android/src/main/java/expo/modules/spotifysdk/ExpoSpotifySDKModule.kt +12 -1
  6. package/android/src/main/java/expo/modules/spotifysdk/SpotifyAppRemoteCoordinator.kt +32 -0
  7. package/build/app-remote/index.d.ts +34 -0
  8. package/build/app-remote/index.d.ts.map +1 -1
  9. package/build/app-remote/index.js +36 -0
  10. package/build/app-remote/index.js.map +1 -1
  11. package/ios/ExpoSpotifyAppDelegate.swift +8 -1
  12. package/ios/ExpoSpotifySDK.podspec +26 -2
  13. package/ios/ExpoSpotifySDKModule.swift +16 -1
  14. package/ios/SpotifyAppRemoteCoordinator.swift +108 -0
  15. package/ios/spotify-native-sdk-versions.json +12 -0
  16. package/package.json +10 -4
  17. package/ios/SpotifySDK/Licenses/MPMessagePack-LICENSE.md +0 -20
  18. package/ios/SpotifySDK/SpotifyiOS.xcframework/Info.plist +0 -40
  19. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemote.h +0 -287
  20. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteAlbum.h +0 -18
  21. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteArtist.h +0 -18
  22. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteCommon.h +0 -37
  23. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteConnectionParams.h +0 -65
  24. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteConnectivityAPI.h +0 -55
  25. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteConnectivityState.h +0 -15
  26. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteContentAPI.h +0 -78
  27. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteContentItem.h +0 -49
  28. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteCrossfadeState.h +0 -18
  29. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteImageAPI.h +0 -25
  30. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteImageRepresentable.h +0 -16
  31. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteLibraryState.h +0 -19
  32. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemotePlaybackOptions.h +0 -32
  33. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemotePlaybackRestrictions.h +0 -32
  34. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemotePlayerAPI.h +0 -267
  35. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemotePlayerState.h +0 -40
  36. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemotePodcastPlaybackSpeed.h +0 -15
  37. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteTrack.h +0 -52
  38. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteUserAPI.h +0 -102
  39. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTAppRemoteUserCapabilities.h +0 -15
  40. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTConfiguration.h +0 -66
  41. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTError.h +0 -31
  42. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTLogin.h +0 -10
  43. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTMacros.h +0 -125
  44. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTScope.h +0 -75
  45. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTSession.h +0 -33
  46. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SPTSessionManager.h +0 -170
  47. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SpotifyAppRemote.h +0 -28
  48. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Headers/SpotifyiOS.h +0 -7
  49. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Info.plist +0 -0
  50. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/Modules/module.modulemap +0 -5
  51. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/PrivacyInfo.xcprivacy +0 -14
  52. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64/SpotifyiOS.framework/SpotifyiOS +0 -0
  53. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemote.h +0 -287
  54. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteAlbum.h +0 -18
  55. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteArtist.h +0 -18
  56. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteCommon.h +0 -37
  57. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteConnectionParams.h +0 -65
  58. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteConnectivityAPI.h +0 -55
  59. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteConnectivityState.h +0 -15
  60. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteContentAPI.h +0 -78
  61. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteContentItem.h +0 -49
  62. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteCrossfadeState.h +0 -18
  63. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteImageAPI.h +0 -25
  64. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteImageRepresentable.h +0 -16
  65. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteLibraryState.h +0 -19
  66. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemotePlaybackOptions.h +0 -32
  67. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemotePlaybackRestrictions.h +0 -32
  68. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemotePlayerAPI.h +0 -267
  69. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemotePlayerState.h +0 -40
  70. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemotePodcastPlaybackSpeed.h +0 -15
  71. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteTrack.h +0 -52
  72. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteUserAPI.h +0 -102
  73. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTAppRemoteUserCapabilities.h +0 -15
  74. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTConfiguration.h +0 -66
  75. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTError.h +0 -31
  76. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTLogin.h +0 -10
  77. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTMacros.h +0 -125
  78. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTScope.h +0 -75
  79. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTSession.h +0 -33
  80. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SPTSessionManager.h +0 -170
  81. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SpotifyAppRemote.h +0 -28
  82. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Headers/SpotifyiOS.h +0 -7
  83. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Info.plist +0 -0
  84. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/Modules/module.modulemap +0 -5
  85. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/PrivacyInfo.xcprivacy +0 -14
  86. package/ios/SpotifySDK/SpotifyiOS.xcframework/ios-arm64_x86_64-simulator/SpotifyiOS.framework/SpotifyiOS +0 -0
@@ -25,6 +25,14 @@ actor SpotifyAppRemoteCoordinator {
25
25
  private var appRemote: SPTAppRemote?
26
26
  private var connectContinuation: CheckedContinuation<Void, Error>?
27
27
 
28
+ /// The `SPTAppRemote` awaiting an `authorizeAndPlay()` redirect, exposed
29
+ /// synchronously to the URL-redirect path. Mirrors the auth coordinator's
30
+ /// `nonisolated(unsafe)` `sessionManager`: it is only written from the
31
+ /// actor's executor (or the main-thread redirect handler) and read on the
32
+ /// main thread, so occasional cross-actor access is acceptable. `nil`
33
+ /// whenever no authorize-and-play flow is in flight.
34
+ nonisolated(unsafe) private var pendingAuthorizeRemote: SPTAppRemote?
35
+
28
36
  nonisolated(unsafe) private(set) var connectionStateString: String = "disconnected"
29
37
 
30
38
  var onConnectionStateChange: ((String) -> Void)?
@@ -97,6 +105,103 @@ actor SpotifyAppRemoteCoordinator {
97
105
  }
98
106
  }
99
107
 
108
+ /// Wakes the Spotify app (via `authorizeAndPlayURI`), starts playback, and
109
+ /// then completes the App Remote connection once Spotify redirects back.
110
+ ///
111
+ /// Unlike `connect()`, this works even when the Spotify app has been
112
+ /// suspended: `authorizeAndPlayURI` performs an app-switch to Spotify, which
113
+ /// revives it. Spotify then redirects back to the host app with an access
114
+ /// token; `handleAuthorizeRedirect(_:)` consumes that redirect and calls
115
+ /// `connect()` on the same `SPTAppRemote` instance.
116
+ ///
117
+ /// The `connectContinuation` is reused for the whole flow, so `didConnect()`
118
+ /// / `didFailToConnect(error:)` resolve it exactly as for `connect()`.
119
+ func authorizeAndPlay(uri: String, accessToken: String) async throws {
120
+ if appRemote?.isConnected == true {
121
+ // Already connected — honour the request by (re)starting playback.
122
+ if uri.isEmpty {
123
+ try await playerResume()
124
+ } else {
125
+ try await playerPlay(uri: uri)
126
+ }
127
+ return
128
+ }
129
+ guard connectContinuation == nil else {
130
+ throw AppRemoteError.connectionFailed("A connection attempt is already in progress")
131
+ }
132
+
133
+ transitionState("connecting")
134
+
135
+ let params = SPTAppRemoteConnectionParams(
136
+ accessToken: accessToken,
137
+ defaultImageSize: CGSize.zero,
138
+ imageFormat: .any
139
+ )
140
+ let remote = SPTAppRemote(
141
+ configuration: sptConfiguration,
142
+ connectionParameters: params,
143
+ logLevel: .error
144
+ )
145
+ remote.delegate = connectionBridge
146
+ appRemote = remote
147
+ pendingAuthorizeRemote = remote
148
+
149
+ try await withCheckedThrowingContinuation { (cont: CheckedContinuation<Void, Error>) in
150
+ self.connectContinuation = cont
151
+ Task { @MainActor in
152
+ // `authorizeAndPlayURI` app-switches to Spotify to wake it. `success`
153
+ // is false when the Spotify app could not be opened (e.g. not
154
+ // installed) — no redirect will arrive, so fail the continuation now.
155
+ // On success we await the redirect, handled by
156
+ // `handleAuthorizeRedirect(_:)`, which completes the connection.
157
+ let success = await remote.authorizeAndPlayURI(uri)
158
+ if !success {
159
+ await self.didFailToConnect(error: NSError(
160
+ domain: "ExpoSpotifySDK",
161
+ code: -1,
162
+ userInfo: [NSLocalizedDescriptionKey: "authorizeAndPlay: could not open the Spotify app (is it installed?)"]
163
+ ))
164
+ }
165
+ }
166
+ }
167
+ }
168
+
169
+ /// Consumes a redirect URL produced by an `authorizeAndPlay()` app-switch.
170
+ /// Returns `true` if an authorize flow was pending and the URL was handled
171
+ /// (so the AppDelegate should not also forward it to the auth coordinator).
172
+ ///
173
+ /// Synchronous + `nonisolated` because the AppDelegate `open url` hook
174
+ /// expects an immediate `Bool`, matching `SpotifyAuthCoordinator.handleOpenURL`.
175
+ nonisolated func handleAuthorizeRedirect(_ url: URL) -> Bool {
176
+ guard let remote = pendingAuthorizeRemote else { return false }
177
+ let consume: () -> Bool = { [self] in
178
+ MainActor.assumeIsolated {
179
+ let params = remote.authorizationParameters(from: url)
180
+ if let token = params?[SPTAppRemoteAccessTokenKey] {
181
+ remote.connectionParameters.accessToken = token
182
+ pendingAuthorizeRemote = nil
183
+ remote.connect()
184
+ return true
185
+ } else if let errorDescription = params?[SPTAppRemoteErrorDescriptionKey] {
186
+ pendingAuthorizeRemote = nil
187
+ Task {
188
+ await self.didFailToConnect(error: NSError(
189
+ domain: "ExpoSpotifySDK",
190
+ code: -2,
191
+ userInfo: [NSLocalizedDescriptionKey: errorDescription]
192
+ ))
193
+ }
194
+ return true
195
+ }
196
+ return false
197
+ }
198
+ }
199
+ if Thread.isMainThread {
200
+ return consume()
201
+ }
202
+ return DispatchQueue.main.sync(execute: consume)
203
+ }
204
+
100
205
  func disconnect() {
101
206
  if let cont = connectContinuation {
102
207
  connectContinuation = nil
@@ -106,6 +211,7 @@ actor SpotifyAppRemoteCoordinator {
106
211
  teardownCapabilitiesSubscription()
107
212
  appRemote?.disconnect()
108
213
  appRemote = nil
214
+ pendingAuthorizeRemote = nil
109
215
  transitionState("disconnected")
110
216
  }
111
217
 
@@ -120,6 +226,7 @@ actor SpotifyAppRemoteCoordinator {
120
226
  // MARK: — Connection delegate callbacks
121
227
 
122
228
  func didConnect() {
229
+ pendingAuthorizeRemote = nil
123
230
  transitionState("connected")
124
231
  setupPlayerSubscription()
125
232
  setupCapabilitiesSubscription()
@@ -130,6 +237,7 @@ actor SpotifyAppRemoteCoordinator {
130
237
 
131
238
  func didFailToConnect(error: Error?) {
132
239
  appRemote = nil
240
+ pendingAuthorizeRemote = nil
133
241
  let msg = error.map { describeNSError($0 as NSError) } ?? "Unknown connection failure"
134
242
  let remoteError = AppRemoteError.connectionFailed(msg)
135
243
  transitionState("disconnected")
@@ -0,0 +1,12 @@
1
+ {
2
+ "ios": {
3
+ "spmRepositoryUrl": "https://github.com/spotify/ios-sdk.git",
4
+ "spmVersion": "5.0.1",
5
+ "spmProduct": "SpotifyiOS"
6
+ },
7
+ "android": {
8
+ "appRemoteVersion": "0.8.0",
9
+ "appRemoteReleaseTag": "v0.8.0-appremote_v2.1.0-auth",
10
+ "appRemoteSha256": "b5a6dd880eaf01f63a871cba9ef7af77c341f8a94ffc8fdf2e9021f9a9d4c198"
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wwdrew/expo-spotify-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Expo module wrapping the native Spotify iOS (v5) and Android (v4) SDKs for OAuth authentication and App Remote playback control",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -17,7 +17,7 @@
17
17
  "scripts": {
18
18
  "build": "tsc",
19
19
  "build:plugin": "tsc -p plugin/tsconfig.json",
20
- "clean": "rm -rf build plugin/build",
20
+ "clean": "rm -rf build plugin/build android/build",
21
21
  "lint": "eslint src",
22
22
  "test": "jest --config jest.config.js",
23
23
  "prepublishOnly": "yarn clean && yarn build && yarn build:plugin",
@@ -37,8 +37,14 @@
37
37
  "plugin/index.d.ts",
38
38
  "plugin/build",
39
39
  "build",
40
- "android",
41
- "ios",
40
+ "android/build.gradle",
41
+ "android/spotify-native-sdk.gradle",
42
+ "android/consumer-rules.pro",
43
+ "android/src",
44
+ "android/libs/SETUP.md",
45
+ "ios/spotify-native-sdk-versions.json",
46
+ "ios/*.swift",
47
+ "ios/*.podspec",
42
48
  "app.plugin.js",
43
49
  "expo-module.config.json"
44
50
  ],
@@ -1,20 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 Gabriel Handford
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,40 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>AvailableLibraries</key>
6
- <array>
7
- <dict>
8
- <key>LibraryIdentifier</key>
9
- <string>ios-arm64</string>
10
- <key>LibraryPath</key>
11
- <string>SpotifyiOS.framework</string>
12
- <key>SupportedArchitectures</key>
13
- <array>
14
- <string>arm64</string>
15
- </array>
16
- <key>SupportedPlatform</key>
17
- <string>ios</string>
18
- </dict>
19
- <dict>
20
- <key>LibraryIdentifier</key>
21
- <string>ios-arm64_x86_64-simulator</string>
22
- <key>LibraryPath</key>
23
- <string>SpotifyiOS.framework</string>
24
- <key>SupportedArchitectures</key>
25
- <array>
26
- <string>arm64</string>
27
- <string>x86_64</string>
28
- </array>
29
- <key>SupportedPlatform</key>
30
- <string>ios</string>
31
- <key>SupportedPlatformVariant</key>
32
- <string>simulator</string>
33
- </dict>
34
- </array>
35
- <key>CFBundlePackageType</key>
36
- <string>XFWK</string>
37
- <key>XCFrameworkFormatVersion</key>
38
- <string>1.0</string>
39
- </dict>
40
- </plist>
@@ -1,287 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- @class SPTAppRemote;
4
- @class SPTAppRemoteConnectionParams;
5
- @class SPTConfiguration;
6
-
7
- @protocol SPTAppRemoteImageAPI;
8
- @protocol SPTAppRemotePlayerAPI;
9
- @protocol SPTAppRemoteUserAPI;
10
- @protocol SPTAppRemoteContentAPI;
11
- @protocol SPTAppRemoteConnectivityAPI;
12
-
13
- NS_ASSUME_NONNULL_BEGIN
14
-
15
- extern NSString *const SPTAppRemoteAccessTokenKey;
16
- extern NSString *const SPTAppRemoteErrorKey;
17
- extern NSString *const SPTAppRemoteErrorDescriptionKey;
18
-
19
- /// The severity of log messages that the App Remote should log to console.
20
- typedef NS_ENUM(NSUInteger, SPTAppRemoteLogLevel) {
21
- /// Do not log at all.
22
- SPTAppRemoteLogLevelNone = 0,
23
- /// Log debug, info and error messages.
24
- SPTAppRemoteLogLevelDebug = 1,
25
- /// Log info and error messages.
26
- SPTAppRemoteLogLevelInfo = 2,
27
- /// Log only error messages.
28
- SPTAppRemoteLogLevelError = 3,
29
- };
30
-
31
- /**
32
- * The `SPTAppRemoteDelegate` receives updates from the `SPTAppRemote` whenever something has
33
- * happened with the connection.
34
- */
35
- @protocol SPTAppRemoteDelegate <NSObject>
36
-
37
- /**
38
- * Called when the App Remote has established connection with the Spotify app.
39
- *
40
- * @param appRemote The transport that has connected.
41
- */
42
- - (void)appRemoteDidEstablishConnection:(SPTAppRemote *)appRemote;
43
-
44
- /**
45
- * Called when the connection attempt made by the App Remote failed.
46
- *
47
- * @param appRemote The App Remote that failed to connect.
48
- * @param error The error that occurred.
49
- */
50
- - (void)appRemote:(SPTAppRemote *)appRemote didFailConnectionAttemptWithError:(nullable NSError *)error;
51
-
52
- /**
53
- * Called when the App Remote has disconnected.
54
- *
55
- * @note All APIs will be released by the App Remote at this point. The will no longer be usable,
56
- * and so you should release them as well.
57
- *
58
- * @param appRemote The App Remote that disconnected.
59
- * @param error The error that caused the disconnect, or `nil` if the disconnect was explicit.
60
- */
61
- - (void)appRemote:(SPTAppRemote *)appRemote didDisconnectWithError:(nullable NSError *)error;
62
-
63
- @end
64
-
65
- /**
66
- * The `SPTAppRemote` is the main entry point for interacting with the Spotify app using the Spotify App Remote for
67
- * iOS.
68
- */
69
- @interface SPTAppRemote : NSObject
70
-
71
- #pragma mark Lifecycle
72
-
73
- /**
74
- * Convenience Initializer for a new App Remote instance
75
- *
76
- * @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
77
- * @param logLevel The lowest severity to log to console.
78
- *
79
- * @return A fresh new App Remote, ready to connect.
80
- */
81
- - (instancetype)initWithConfiguration:(SPTConfiguration *)configuration logLevel:(SPTAppRemoteLogLevel)logLevel;
82
-
83
- /**
84
- * Designated Initializer for a new App Remote instance
85
- *
86
- * @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
87
- * @param connectionParameters `SPTAppRemoteConnectionParams` for custom image sizes and types, and to hold the
88
- * accessToken
89
- * @param logLevel The lowest severity to log to console.
90
- *
91
- * @return A fresh new App Remote, ready to connect.
92
- */
93
- - (instancetype)initWithConfiguration:(SPTConfiguration *)configuration
94
- connectionParameters:(SPTAppRemoteConnectionParams *)connectionParameters
95
- logLevel:(SPTAppRemoteLogLevel)logLevel NS_DESIGNATED_INITIALIZER;
96
- #pragma mark Class Methods
97
-
98
- /**
99
- * Determine the current version of the Spotify App Remote
100
- *
101
- * @return The current version of the Spotify App Remote
102
- */
103
- + (NSString *)appRemoteVersion;
104
-
105
- /**
106
- * The Spotify app iTunes item identifier for use with `SKStoreProductViewController` for installing Spotify from the
107
- * App Store.
108
- *
109
- * @return An `NSNumber` representing the Spotify iTunes item identifier to be used for the
110
- * `SKStoreProductParameterITunesItemIdentifier` key
111
- */
112
- + (NSNumber *)spotifyItunesItemIdentifier;
113
-
114
- #pragma mark Connection
115
-
116
- /**
117
- * The parameters to use during connection.
118
- */
119
- @property (nonatomic, strong, readonly) SPTAppRemoteConnectionParams *connectionParameters;
120
-
121
- /**
122
- * `YES` if the App Remote is connected to the Spotify application, otherwise `NO`.
123
- *
124
- * @note Not KVO’able.
125
- *
126
- * See The `SPTAppRemoteDelegate` in order to receive updates when the connection status changes.
127
- */
128
- @property (nonatomic, assign, readonly, getter=isConnected) BOOL connected;
129
-
130
- /**
131
- * The delegate to notify for connection status changes and other events originating from the App Remote.
132
- */
133
- @property (nonatomic, weak) id<SPTAppRemoteDelegate> delegate;
134
-
135
- /**
136
- * Attempts to connect to the Spotify application.
137
- *
138
- * @discussion If the Spotify app is not running you will need to use authorizeAndPlayURI: to wake it up
139
- */
140
- - (void)connect;
141
-
142
- /**
143
- * Attempts to connect to the Spotify application with a given session identifier.
144
- *
145
- * @discussion If the Spotify app is not running you will need to use authorizeAndPlayURI: to wake it up.
146
- *
147
- * @discussion If `authorizeAndPlayURI` was used without a given session identifier, `connect` should be used instead of
148
- * this method.
149
- *
150
- * @param sessionIdentifier The unique session identifier which was used when calling
151
- * `authorizeAndPlayURI:asRadio:additionalScopes:sessionIdentifier:`
152
- */
153
- - (void)connectWithSessionIdentifier:(NSUUID *)sessionIdentifier;
154
-
155
- /**
156
- * Disconnect from the Spotify application
157
- */
158
- - (void)disconnect;
159
-
160
- /**
161
- * Open Spotify app to obtain access token and start playback.
162
- * The passed URI will start playing unless Spotify is already playing.
163
- *
164
- * @param URI The URI to play. Use a blank string to attempt to play the user's last song
165
- * @param completionHandler `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise
166
- * `NO`.
167
- *
168
- * Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
169
- * the Spotify app is installed and can attempt to handle the authorization request.
170
- */
171
- - (void)authorizeAndPlayURI:(NSString *)URI completionHandler:(void (^__nullable)(BOOL success))completionHandler;
172
-
173
- /**
174
- * Open Spotify app to obtain access token and start playback.
175
- *
176
- * @param playURI The URI to play. Use a blank string to attempt to play the user's last song
177
- * @param asRadio `YES` to start radio for the given URI.
178
- * @param completionHandler `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise
179
- * `NO`.
180
- *
181
- * Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
182
- * the Spotify app is installed and can attempt to handle the authorization request.
183
- */
184
- - (void)authorizeAndPlayURI:(NSString *)playURI
185
- asRadio:(BOOL)asRadio
186
- completionHandler:(void (^__nullable)(BOOL success))completionHandler;
187
-
188
- /**
189
- * Open Spotify app to obtain access token and start playback.
190
- *
191
- * @param playURI The URI to play. Use a blank string to attempt to play the user's last song
192
- * @param asRadio `YES` to start radio for the given URI.
193
- * @param additionalScopes An array of scopes in addition to `app-remote-control`. Can be nil if you only need
194
- * `app-remote-control`
195
- * @param completionHandler `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise
196
- * `NO`.
197
- *
198
- * Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
199
- * the Spotify app is installed and can attempt to handle the authorization request.
200
- */
201
- - (void)authorizeAndPlayURI:(NSString *)playURI
202
- asRadio:(BOOL)asRadio
203
- additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
204
- completionHandler:(void (^__nullable)(BOOL success))completionHandler;
205
-
206
- /**
207
- * Open Spotify app to obtain access token and start playback.
208
- *
209
- * @param playURI The URI to play. Use a blank string to attempt to play the user's last song
210
- * @param asRadio `YES` to start radio for the given URI.
211
- * @param additionalScopes An array of scopes in addition to `app-remote-control`. Can be nil if you only need
212
- * `app-remote-control`
213
- * @param sessionIdentifier An optional unique identifier for this specific session, which is used for analytics
214
- * purposes. Every new attempt to connect to the Spotify app should have a new identifier, but the identifier used here
215
- * should then be reused for the accompanied call to `connectWithSessionIdentifier:`.
216
- * @param completionHandler `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise
217
- * `NO`.
218
- *
219
- * Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
220
- * the Spotify app is installed and can attempt to handle the authorization request.
221
- */
222
- - (void)authorizeAndPlayURI:(NSString *)playURI
223
- asRadio:(BOOL)asRadio
224
- additionalScopes:(nullable NSArray<NSString *> *)additionalScopes
225
- sessionIdentifier:(nullable NSUUID *)sessionIdentifier
226
- completionHandler:(void (^__nullable)(BOOL success))completionHandler;
227
- /**
228
- * Parse out an access token or error description from a url passed to application:openURL:options:
229
- *
230
- * @param url The URL returned from the Spotify app after calling authorizeAndPlayURI
231
- *
232
- * @return A dictionary containing the access token or error description from the provided URL.
233
- * Will return nil if the URL Scheme does not match the redirect URI provided.
234
- * Use `SPTAppRemoteAccessTokenKey` and `SPTAppRemoteErrorDescriptionKey` to get the appropriate values.
235
- */
236
- - (nullable NSDictionary<NSString *, NSString *> *)authorizationParametersFromURL:(NSURL *)url;
237
-
238
- #pragma mark APIs
239
-
240
- /**
241
- * The API used to control the Spotify player.
242
- *
243
- * @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
244
- * disconnect.
245
- */
246
- @property (nullable, nonatomic, strong, readonly) id<SPTAppRemotePlayerAPI> playerAPI;
247
-
248
- /**
249
- * The API used to fetch images from the Spotify app.
250
- *
251
- * @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
252
- * disconnect.
253
- */
254
- @property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteImageAPI> imageAPI;
255
-
256
- /**
257
- * The API used to fetch user data from the Spotify app.
258
- *
259
- * @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
260
- * disconnect.
261
- */
262
- @property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteUserAPI> userAPI;
263
-
264
- /**
265
- * The API used to fetch content from the Spotify app.
266
- *
267
- * @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
268
- * disconnect.
269
- */
270
- @property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteContentAPI> contentAPI;
271
-
272
- /**
273
- * The API used to get connectivity data from the Spotify app.
274
- *
275
- * @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
276
- * disconnect.
277
- */
278
- @property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteConnectivityAPI> connectivityAPI;
279
-
280
- #pragma mark Unavailable initializers
281
-
282
- - (instancetype)init NS_UNAVAILABLE;
283
- + (instancetype)new NS_UNAVAILABLE;
284
-
285
- @end
286
-
287
- NS_ASSUME_NONNULL_END
@@ -1,18 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- NS_ASSUME_NONNULL_BEGIN
4
-
5
- /**
6
- * The `SPTAppRemoteAlbum` represents an Album entity.
7
- */
8
- @protocol SPTAppRemoteAlbum <NSObject>
9
-
10
- /// The name of the album.
11
- @property (nonatomic, copy, readonly) NSString *name;
12
-
13
- /// The URI of the album.
14
- @property (nonatomic, copy, readonly) NSString *URI;
15
-
16
- @end
17
-
18
- NS_ASSUME_NONNULL_END
@@ -1,18 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- NS_ASSUME_NONNULL_BEGIN
4
-
5
- /**
6
- * The `SPTAppRemoteArtist` represents an artist.
7
- */
8
- @protocol SPTAppRemoteArtist <NSObject>
9
-
10
- /// The name of the artist.
11
- @property (nonatomic, copy, readonly) NSString *name;
12
-
13
- /// The URI of the artist.
14
- @property (nonatomic, copy, readonly) NSString *URI;
15
-
16
- @end
17
-
18
- NS_ASSUME_NONNULL_END
@@ -1,37 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- /**
4
- * Common header definitions
5
- */
6
-
7
- NS_ASSUME_NONNULL_BEGIN
8
-
9
- /// The error domain for user facing errors that occur in the App Remote.
10
- extern NSString *const SPTAppRemoteErrorDomain;
11
-
12
- /// The error codes in the `SPTAppRemoteErrorDomain` domain.
13
- typedef NS_ENUM(NSInteger, SPTAppRemoteErrorCode) {
14
- /// An unknown error.
15
- SPTAppRemoteUnknownError = -1,
16
-
17
- /// The background wakeup of the Spotify app failed.
18
- SPTAppRemoteBackgroundWakeupFailedError = -1000,
19
- /// The connection attempt to the Spotify app failed.
20
- SPTAppRemoteConnectionAttemptFailedError = -1001,
21
- /// The conncetion to the Spotify app was terminated.
22
- SPTAppRemoteConnectionTerminatedError = -1002,
23
- /// The arguments supplied are invalid.
24
- SPTAppRemoteInvalidArgumentsError = -2000,
25
- /// The request has failed for some reason.
26
- SPTAppRemoteRequestFailedError = -2001,
27
- };
28
-
29
- /**
30
- * A callback block used by many App Remote API methods.
31
- *
32
- * @param result The result of the operation, or `nil` if the operation failed.
33
- * @param error An error object, or `nil` if the operation was a success.
34
- */
35
- typedef void (^SPTAppRemoteCallback)(id _Nullable result, NSError *_Nullable error);
36
-
37
- NS_ASSUME_NONNULL_END
@@ -1,65 +0,0 @@
1
- #import <Foundation/Foundation.h>
2
-
3
- /// Available image formats to receive from the Spotify app.
4
- typedef NS_ENUM(NSUInteger, SPTAppRemoteConnectionParamsImageFormat) {
5
- /// Any image format is acceptable. Use this if you don't care about which image format is sent.
6
- SPTAppRemoteConnectionParamsImageFormatAny = 0,
7
- /// JPEG image format.
8
- SPTAppRemoteConnectionParamsImageFormatJPEG,
9
- /// PNG image format.
10
- SPTAppRemoteConnectionParamsImageFormatPNG,
11
- };
12
-
13
- struct CGSize;
14
-
15
- NS_ASSUME_NONNULL_BEGIN
16
-
17
- /**
18
- * The `SPTAppRemoteconnectionParams` represents connection parameters required in order to initiate a connection
19
- * with the Spotify app.
20
- */
21
- @interface SPTAppRemoteConnectionParams : NSObject
22
-
23
- /// The access token used to authorize the user with the Spotify app.
24
- @property (nonatomic, copy, readwrite, nullable) NSString *accessToken;
25
-
26
- /// The desired size of received images. (0,0) acts as a wildcard and accepts any size.
27
- @property (nonatomic, assign, readonly) struct CGSize defaultImageSize;
28
-
29
- /// The desired image format of received images.
30
- @property (nonatomic, assign, readonly) SPTAppRemoteConnectionParamsImageFormat imageFormat;
31
-
32
- /**
33
- * Initialize a set of new connection parameters.
34
- *
35
- * @discussion This is the designated initializer.
36
- *
37
- * @param accessToken The access token obtained after authentication.
38
- * @param defaultImageSize The desired size of received images. (0,0) acts as a wildcard and accepts any size.
39
- * @param imageFormat The desired image format of received images.
40
- *
41
- * @return A set of connection parameters ready to be used when initiating a connection to the Spotify app.
42
- */
43
- - (instancetype)initWithAccessToken:(nullable NSString *)accessToken
44
- defaultImageSize:(struct CGSize)defaultImageSize
45
- imageFormat:(SPTAppRemoteConnectionParamsImageFormat)imageFormat NS_DESIGNATED_INITIALIZER;
46
-
47
- #pragma mark Static properties
48
-
49
- /// Version of the protocol
50
- @property (nonatomic, assign, readonly) NSInteger protocolVersion;
51
-
52
- /// Roles
53
- @property (nonatomic, copy, readonly) NSDictionary *roles;
54
-
55
- /// Authentication methods supported
56
- @property (nonatomic, copy, readonly) NSArray *authenticationMethods;
57
-
58
- #pragma mark Unavailable initializers
59
-
60
- - (instancetype)init NS_UNAVAILABLE;
61
- + (instancetype)new NS_UNAVAILABLE;
62
-
63
- @end
64
-
65
- NS_ASSUME_NONNULL_END