Skip to content

Commit

Permalink
Spotify iOS SDK v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfreeman committed Sep 11, 2018
0 parents commit 25971e2
Show file tree
Hide file tree
Showing 141 changed files with 18,265 additions and 0 deletions.
1 change: 1 addition & 0 deletions DemoProjects/.ruby-version
@@ -0,0 +1 @@
2.5.1
382 changes: 382 additions & 0 deletions DemoProjects/NowPlayingView/NowPlayingView.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0940"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F4F973EB1CAD60320036411D"
BuildableName = "NowPlayingView.app"
BlueprintName = "NowPlayingView"
ReferencedContainer = "container:NowPlayingView.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F4F973EB1CAD60320036411D"
BuildableName = "NowPlayingView.app"
BlueprintName = "NowPlayingView"
ReferencedContainer = "container:NowPlayingView.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F4F973EB1CAD60320036411D"
BuildableName = "NowPlayingView.app"
BlueprintName = "NowPlayingView"
ReferencedContainer = "container:NowPlayingView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F4F973EB1CAD60320036411D"
BuildableName = "NowPlayingView.app"
BlueprintName = "NowPlayingView"
ReferencedContainer = "container:NowPlayingView.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
90 changes: 90 additions & 0 deletions DemoProjects/NowPlayingView/NowPlayingView/AppDelegate.swift
@@ -0,0 +1,90 @@
import UIKit

@UIApplicationMain
class AppDelegate: UIResponder,
UIApplicationDelegate, SPTAppRemoteDelegate {

fileprivate let redirectUri = URL(string:"comspotifytestsdk://")!
fileprivate let clientIdentifier = "089d841ccc194c10a77afad9e1c11d54"
fileprivate let name = "Now Playing View"

// keys
static fileprivate let kAccessTokenKey = "access-token-key"

var accessToken = UserDefaults.standard.string(forKey: kAccessTokenKey) {
didSet {
let defaults = UserDefaults.standard
defaults.set(accessToken, forKey: AppDelegate.kAccessTokenKey)
defaults.synchronize()
}
}


var playerViewController: ViewController {
get {
let navController = self.window?.rootViewController?.childViewControllers[0] as! UINavigationController
return navController.topViewController as! ViewController
}
}

var window: UIWindow?

lazy var appRemote: SPTAppRemote = {
let configuration = SPTConfiguration(clientID: self.clientIdentifier, redirectURL: self.redirectUri)
let appRemote = SPTAppRemote(configuration: configuration, logLevel: .debug)
appRemote.connectionParameters.accessToken = self.accessToken
appRemote.delegate = self
return appRemote
}()

class var sharedInstance: AppDelegate {
get {
return UIApplication.shared.delegate as! AppDelegate
}
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {
let parameters = appRemote.authorizationParameters(from: url);

if let access_token = parameters?[SPTAppRemoteAccessTokenKey] {
appRemote.connectionParameters.accessToken = access_token
self.accessToken = access_token
} else if let error_description = parameters?[SPTAppRemoteErrorDescriptionKey] {
playerViewController.showError(error_description);
}

return true
}

func applicationWillResignActive(_ application: UIApplication) {
playerViewController.appRemoteDisconnect()
appRemote.disconnect()
}

func applicationDidBecomeActive(_ application: UIApplication) {
self.connect();
}

func connect() {
playerViewController.appRemoteConnecting()
appRemote.connect()
}

// MARK: AppRemoteDelegate

func appRemoteDidEstablishConnection(_ appRemote: SPTAppRemote) {
self.appRemote = appRemote
playerViewController.appRemoteConnected()
}

func appRemote(_ appRemote: SPTAppRemote, didFailConnectionAttemptWithError error: Error?) {
print("didFailConnectionAttemptWithError")
playerViewController.appRemoteDisconnect()
}

func appRemote(_ appRemote: SPTAppRemote, didDisconnectWithError error: Error?) {
print("didDisconnectWithError")
playerViewController.appRemoteDisconnect()
}

}
@@ -0,0 +1,48 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" initialViewController="01J-lp-oVM">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<layoutGuides>
<viewControllerLayoutGuide type="top" id="Llm-lL-Icb"/>
<viewControllerLayoutGuide type="bottom" id="xb3-aO-Qok"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>

0 comments on commit 25971e2

Please sign in to comment.