Skip to content

Commit 0b3e547

Browse files
authored
Merge pull request #461 from spotify/release_v5.0.1
Spotify iOS SDK v5.0.1
2 parents af71ec0 + 1ebe747 commit 0b3e547

File tree

89 files changed

+794
-1702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+794
-1702
lines changed

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
# Changelog
22

3+
## Spotify iOS SDK v5.0.1
4+
5+
What's New:
6+
7+
- Replace deprecated keyWindow with proper window scene handling
8+
- Clean up auth sessions in dealloc
9+
- Update demo apps to support SceneDelegate
10+
- Update documentation
11+
12+
## Spotify iOS SDK v5.0.0
13+
14+
What's New:
15+
16+
- Replace SPTAuthorizationMethod (NS_ENUM) with SPTAuthorizationOptions (NS_OPTIONS)
17+
- Add the new option 'spotifySchemeNotRegistered' to avoid using 'canOpenURL' if you have reached the 50-entry limit in your Info.plist file and cannot add the Spotify scheme.
18+
19+
## Spotify iOS SDK v4.0.1
20+
21+
What's New:
22+
23+
- Fixed an issue with SPTAuthorizationMethodUniversalLinks
24+
25+
## Spotify iOS SDK v4.0.0
26+
27+
What's New:
28+
29+
- Replace SPTAuthorizationOptions (NS_OPTIONS) with SPTAuthorizationMethod (NS_ENUM)
30+
- Add a new configuration method (SPTAuthorizationMethodUniversalLinks) that doesn't require to add the 'spotify' scheme to your Info.plist
31+
332
## Spotify iOS SDK v3.0.0
433

534
What's New:
@@ -134,4 +163,4 @@ What's New
134163
What's New
135164

136165
- Initial iOS SDK release
137-
- Includes authentication and playback control capabilities
166+
- Includes authentication and playback control capabilities
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import UIKit
22

3-
@UIApplicationMain
3+
@main
44
class AppDelegate: UIResponder,
5-
UIApplicationDelegate
6-
{
7-
8-
}
5+
UIApplicationDelegate {}

DemoProjects/NowPlayingView/NowPlayingView/ConnectionStatusIndicatorView.swift

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import UIKit
22

33
/// Connection status view
44
class ConnectionStatusIndicatorView : UIView {
5-
5+
66
enum State {
77
case disconnected
88
case connecting
99
case connected
1010
}
11-
11+
1212
var state: State = .disconnected {
1313
didSet {
1414
self.setNeedsDisplay()
@@ -20,36 +20,36 @@ class ConnectionStatusIndicatorView : UIView {
2020
displayLink?.add(to: RunLoop.main, forMode: RunLoop.Mode.common)
2121
} else {
2222
displayLink?.remove(from: RunLoop.main, forMode: RunLoop.Mode.common)
23-
displayLink = nil;
23+
displayLink = nil
2424
}
2525
}
2626
}
27-
27+
2828
var displayLink: CADisplayLink?
29-
29+
3030
override func didMoveToSuperview() {
3131
super.didMoveToSuperview()
32-
self.clearsContextBeforeDrawing = true;
32+
self.clearsContextBeforeDrawing = true
3333
self.backgroundColor = UIColor.clear
3434
}
35-
35+
3636
override func draw(_ rect: CGRect) {
3737
guard let context = UIGraphicsGetCurrentContext() else {
3838
return
3939
}
40-
40+
4141
let size = self.bounds.size
4242
let path = CGPath(roundedRect: self.bounds, cornerWidth: size.width/2, cornerHeight: size.height/2, transform: nil)
4343
context.addPath(path)
44-
44+
4545
context.setFillColor(fillColor())
4646
context.fillPath()
4747
}
48-
48+
4949
private func timebasedValue() -> CGFloat {
5050
return CGFloat(abs(sin(Date().timeIntervalSinceReferenceDate*4)))
5151
}
52-
52+
5353
private func fillColor() -> CGColor {
5454
switch state {
5555
case .disconnected:

DemoProjects/NowPlayingView/NowPlayingView/ContentCollectionViewController.swift

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,122 @@
1-
import UIKit
21
import SpotifyiOS
2+
import UIKit
33

44
class ContentCollectionViewController : UICollectionViewController, UICollectionViewDelegateFlowLayout {
5-
5+
66
var containerItem: SPTAppRemoteContentItem? = nil {
77
didSet {
88
needsReload = true
99
}
1010
}
11+
1112
var contentItems = [SPTAppRemoteContentItem]()
1213
var needsReload = true
13-
14+
1415
var appRemote: SPTAppRemote? {
15-
get {
16-
return (UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.appRemote
17-
}
16+
return (UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.appRemote
1817
}
19-
18+
2019
func loadContent() {
2120
guard needsReload == true else {
2221
return
2322
}
24-
23+
2524
if let container = containerItem {
26-
appRemote?.contentAPI?.fetchChildren(of: container) { (items, error) in
25+
appRemote?.contentAPI?.fetchChildren(of: container) { items, _ in
2726
if let contentItems = items as? [SPTAppRemoteContentItem] {
2827
self.contentItems = contentItems
2928
}
3029
self.collectionView?.reloadData()
3130
}
3231
} else {
33-
appRemote?.contentAPI?.fetchRecommendedContentItems(forType: SPTAppRemoteContentTypeDefault, flattenContainers: true) { (items, error) in
32+
appRemote?.contentAPI?.fetchRecommendedContentItems(forType: SPTAppRemoteContentTypeDefault, flattenContainers: true) { items, _ in
3433
if let contentItems = items as? [SPTAppRemoteContentItem] {
3534
self.contentItems = contentItems
3635
}
3736
self.collectionView?.reloadData()
3837
}
3938
}
40-
39+
4140
needsReload = false
4241
}
43-
42+
4443
override func viewWillAppear(_ animated: Bool) {
4544
super.viewWillAppear(animated)
46-
45+
4746
containerItem = nil
4847
}
49-
48+
5049
override func viewDidAppear(_ animated: Bool) {
5150
super.viewDidAppear(animated)
52-
51+
5352
self.navigationItem.title = containerItem?.title ?? "Spotify"
5453
loadContent()
5554
}
56-
55+
5756
// MARK: UICollectionViewDataSource
57+
5858
override func numberOfSections(in collectionView: UICollectionView) -> Int {
5959
return 1
6060
}
61-
61+
6262
override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
6363
return contentItems.count
6464
}
65-
65+
6666
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
6767
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "ContentItemCell", for: indexPath) as! ContentItemCell
6868
let item = contentItems[indexPath.item]
69-
69+
7070
cell.titleLabel?.text = item.title
7171
cell.subtitleLabel?.text = item.subtitle
72-
72+
7373
cell.imageView.image = nil
74-
appRemote?.imageAPI?.fetchImage(forItem: item, with: scaledSizeForCell(cell)) { (image, error) in
74+
appRemote?.imageAPI?.fetchImage(forItem: item, with: scaledSizeForCell(cell)) { image, error in
7575
guard let image = image as? UIImage, error == nil,
7676
let cell = collectionView.cellForItem(at: indexPath) as? ContentItemCell else {
7777
return
7878
}
7979
cell.imageView?.image = image
8080
}
81-
81+
8282
return cell
8383
}
84-
84+
8585
private func scaledSizeForCell(_ cell: UICollectionViewCell) -> CGSize {
8686
let scale = UIScreen.main.scale
8787
let size = cell.frame.size
8888
return CGSize(width: size.width * scale, height: size.height * scale)
8989
}
90-
90+
9191
// MARK: UICollectionViewDelegateFlowLayout
92+
9293
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
9394
let width = collectionView.frame.width / 2.0
9495
return CGSize(width: width, height: width)
9596
}
96-
97+
9798
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
9899
return 0.0
99100
}
100-
101+
101102
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
102103
return 0.0
103104
}
104-
105+
105106
override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
106107
guard let id = restorationIdentifier,
107108
let newVc = storyboard?.instantiateViewController(withIdentifier: id) as? ContentCollectionViewController else {
108109
return
109110
}
110-
111+
111112
let selectedItem = contentItems[indexPath.item]
112-
113+
113114
if selectedItem.isContainer {
114115
newVc.containerItem = selectedItem
115-
116+
116117
navigationController?.pushViewController(newVc, animated: true)
117118
} else {
118-
appRemote?.playerAPI?.play(selectedItem, callback: { [weak self = self] result, error in
119+
appRemote?.playerAPI?.play(selectedItem, callback: { [weak self = self] _, error in
119120
if let errorMessage = (error as NSError?)?.userInfo["error-identifier"] as? String {
120121
let alert = UIAlertController(title: NSLocalizedString("Oops!", comment: ""), message: errorMessage, preferredStyle: .alert)
121122
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default, handler: nil))

DemoProjects/NowPlayingView/NowPlayingView/ContentItemCell.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ class ContentItemCell : UICollectionViewCell {
44
@IBOutlet var imageView: UIImageView!
55
@IBOutlet var titleLabel: UILabel!
66
@IBOutlet var subtitleLabel: UILabel!
7-
}
7+
}

DemoProjects/NowPlayingView/NowPlayingView/My-Extensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension Dictionary {
1717
let valueString = value as! String
1818
let encodedKey = keyString.encodeStringAsUrlParameter(key as! String)
1919
let encodedValue = valueString.encodeStringAsUrlParameter(value as! String)
20-
let encoded = String(format: "%@=%@", encodedKey, encodedValue);
20+
let encoded = String(format: "%@=%@", encodedKey, encodedValue)
2121
pairs.append(encoded)
2222
}
2323

DemoProjects/NowPlayingView/NowPlayingView/PlaybackButtonGraphics.swift

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,39 @@ import UIKit
22

33
class PlaybackButtonGraphics {
44
class func imageWithFilledPolygons(_ lines: [[CGPoint]]) -> UIImage {
5-
let context = CGContext(data: nil,
6-
width: 64, height: 64,
7-
bitsPerComponent: 8, bytesPerRow: 8*64*4,
8-
space: CGColorSpaceCreateDeviceRGB(),
9-
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue);
10-
5+
let context = CGContext(
6+
data: nil,
7+
width: 64,
8+
height: 64,
9+
bitsPerComponent: 8,
10+
bytesPerRow: 8*64*4,
11+
space: CGColorSpaceCreateDeviceRGB(),
12+
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
13+
)
14+
1115
let path = CGMutablePath()
1216
for linePoints in lines {
1317
path.addLines(between: linePoints)
1418
}
15-
19+
1620
context?.addPath(path)
1721
context?.fillPath()
18-
22+
1923
if let image = context?.makeImage() {
2024
return UIImage(cgImage: image, scale: UIScreen.main.scale, orientation: .up)
2125
}
22-
26+
2327
return UIImage()
2428
}
25-
29+
2630
class func playButtonImage() -> UIImage {
2731
return imageWithFilledPolygons([[
2832
CGPoint(x: 64, y: 32),
2933
CGPoint(x: 0, y: 64),
3034
CGPoint(x: 0, y: 0),
3135
]])
3236
}
33-
37+
3438
class func nextButtonImage() -> UIImage {
3539
return imageWithFilledPolygons([
3640
[
@@ -41,9 +45,10 @@ class PlaybackButtonGraphics {
4145
CGPoint(x: 32, y: 32),
4246
CGPoint(x: 0, y: 48),
4347
CGPoint(x: 0, y: 16),
44-
]])
48+
],
49+
])
4550
}
46-
51+
4752
class func previousButtonImage() -> UIImage {
4853
return imageWithFilledPolygons([
4954
[
@@ -54,22 +59,27 @@ class PlaybackButtonGraphics {
5459
CGPoint(x: 0, y: 32),
5560
CGPoint(x: 32, y: 48),
5661
CGPoint(x: 32, y: 16),
57-
]])
62+
],
63+
])
5864
}
59-
65+
6066
class func pauseButtonImage() -> UIImage {
61-
let context = CGContext(data: nil,
62-
width: 64, height: 64,
63-
bitsPerComponent: 8, bytesPerRow: 8*64*4,
64-
space: CGColorSpaceCreateDeviceRGB(),
65-
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue);
66-
67-
context?.fill(CGRect(x: 0, y: 0, width: 20, height: 64));
68-
context?.fill(CGRect(x: 44, y: 0, width: 20, height: 64));
67+
let context = CGContext(
68+
data: nil,
69+
width: 64,
70+
height: 64,
71+
bitsPerComponent: 8,
72+
bytesPerRow: 8*64*4,
73+
space: CGColorSpaceCreateDeviceRGB(),
74+
bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue
75+
)
76+
77+
context?.fill(CGRect(x: 0, y: 0, width: 20, height: 64))
78+
context?.fill(CGRect(x: 44, y: 0, width: 20, height: 64))
6979
if let image = context?.makeImage() {
7080
return UIImage(cgImage: image, scale: UIScreen.main.scale, orientation: .up)
7181
}
72-
82+
7383
return UIImage()
7484
}
7585
}

0 commit comments

Comments
 (0)