App Remote Sample User Is Not Logged In Spotify Sdk

Add another device that supports Spotify or has the app (like a speaker or laptop). Connect both devices to the same Wi-Fi network, and log in to Spotify. Listen out loud. Bitcoin nowadays is not only a cryptocurrency or a digital payment system. Actually, thanks to its unique features bitcoin has become a real instrument for investment, saving and even earning more money. In this article we want to talk about 3 most popular bitcoin app SDK, that can help you to develop your own app.

In this article, we’re sharing tips for connecting Spotify to your mobile iOS application. The guide is based on our web and mobile development experience and explores the stages of SDK connection: the process of login, token authentication, and the built-in Spotify player management.

Spotify offers an application programming interface (API) and a software development kit (SDK).

An API is a collection of routines, data structures, and classes designed specifically to interact with a piece of software. An SDK comprises of the API and tools for its management.

When creating an application, it’s better to use an SDK (if there’s one available), as it simplifies the development. Although the Spotify iOS SDK is in beta (ver. beta-25), it’s stable enough to use. Note that using Spotify’s SDK for commercial projects requires their team’s official written approval.

With Spotify integrated with your app, its users can receive user data, play audio and share public data. The latter includes sharing different Spotify items (albums, artists and playlists), and managing collaborative playlists. However, the ability is limited to public items only.

Implementing the Spotify iOS SDK

App Remote Sample User Is Not Logged In Spotify Sdk

For this article, we decided to show you the integration of Spotify’s iOS SDK with a mobile application for listening to music from several audio streaming services. Here, users can link to and undock their Spotify accounts, and log into several devices without re-connecting to the integrated services.

Keep in mind that although there is an official tutorial for implementing Spotify’s SDK, it can only introduce the basic functionality. The process of connecting the SDK to a real product is significantly different in terms of login logic and token management.

First things first, you need to create an XCode project, register a Spotify account and make it premium. It’s necessary for streaming. For those not sure it’s worth the purchase, there’s a free trial.

Registering your app in Spotify

Go to the Spotify’s Dashboard and log into your account. Find a Create an App button there. Enter your name and application description. Then examine the following fields:

Now find this button . Enter your name and app description. After this we are interested in the following fields:

  • Client ID - your app’s unique identifier, which is required for the SDK integration.

  • Client Secret - your app’s secret key, which is used on the server.

  • Redirect URL - a link returning to your application in case of login readdressing to the native app or Safari. Here, we used projectname://spotify/callback

  • Bundle ID - your app’s bundle ID.

Creating a SpotifyLoginController

We’re using a custom login, and not the one given in the tutorial because we need to receive a server authentication code.

First, let’s create a controller with UIWebView (go with the UIWebViewController if you wish; we prefer using UIViewController with an additional UIWebView; the delegate is self).

Then, we need to implement a basic Spotify initialization in viewDidLoad:

App Remote Sample User Is Not Logged In Spotify Sdk Version

Here’s a closer look:

  • SPTAuthStreamingScope, SPTAuthPlaylistReadPrivateScope, SPTAuthPlaylistModifyPublicScope, and SPTAuthPlaylistModifyPrivateScope - are our app’s access rights

  • SpotifyRedirectURI is the redirect URL we specified in the Spotify app settings
  • SpotifyTokenSwapURL and SpotifyTokenRefreshURLb are something we’re going to discuss in a little while

When the controller appears in viewWillAppear, we need to initialize a login link:

Look at the following parameters:

  • client_id - is our app’s client ID
  • scope - is the access permission
  • redirect_uri - is a redirect URL that lets us return to the app and spot the completion of login
  • nosignup = true - disables automatic login
  • show_dialog = true - is a required “Is it really you?” user confirmation
  • response_type = code - is a type of returned value (you can get code or access token here - we’re interested in the former).

Here’s how the response is processed:

A successful login implementation results into a session, which is available through SPTAuth.defaultInstance().session. The peculiarity of Spotify’s sessions is the duration of their lifespan. At the time of writing, it’s 1 hour long. Once this period expires, you have to call the SPTAuth.defaultInstance().renewSession method.

Seemingly not an issue, you just have to add a SPTAuth.defaultInstance().session.isValid() method validation, but here’s a catch: all sessions are stored locally on devices.

Storing and updating tokens

App Remote Sample User Is Not Logged In Spotify Sdk Windows 10

If you want user to login to several devices without signing into their Spotify over and over again, you’re going to have to do the following:

  • Remember we mentioned SpotifyTokenSwapURL and SpotifyTokenRefreshURL? Those are links to the server requests that implement Spotify token updates. When updating a session, you need to fix the renewSession method:

We highly recommend that you reassign swap and refresh links before making any session updates. Otherwise, you might accidentally call renewSession in places, where SPTAuth.defaultInstance() hasn’t been configured yet.

  • Implement swap and refresh methods on the server. Here’s an example of this process in Ruby.

  • Once it has been working for an hour or so, call the renewSession method from your SDK, which then queries your server, gets the necessary data, creates a session and stores it on the device (again, locally).

With the following methods, the newly created session can be transformed into a string and back:

A transformed session can be stored either locally or on a server, but you need to encrypt it first.

Songs stream

Spotify SDK allows your app’s users to listen to entire songs without being redirected to the Spotify application.

Audio streaming is done not through the usual AVPlayer, but through the SPTAudioStreamingController. For this example, we saved a Spotify player item as a singleton in the Utils class, which makes it accessible from anywhere:

When launching our app (or once we have a connected Spotify account), we can call the player initialization:

In this example, a Spotify Premium check block (the error code is 9, which means a standard account that doesn’t permit audio streaming) is commented due to request instability (which is plausible given that the SDK is in beta). Streaming is only available when there are no errors, regardless of their type.

The main methods of Spotify’s player

App
  • Track listing:

  • Play and Pause

  • Stop:

  • The current position:

  • The overall track duration:

  • Rewind:

This concludes our article on implementing Spotify’s iOS SDK for mobile application development. We hope you’ve found something worth learning.

Do your consider integrating Spotify with your mobile application? Contact our sales department today to start working on your project.

P.S. Do not forget to logout from Spotify

Useful links

App developers should take into account individual manufacturer QA requirements - see App Publishing. Please review these requirements prior to designing your Smart TV application. Please also check the Development Guidelines and Diversity Handling Guidelines for further details.

As a guideline, the Smart TV Alliance has published the requirements below. We hope developers will find these useful, but please note that manufacturer requirements are definitive and always take precedence.

NO

CONTENT

RESULT

BASIC

1

The app provider should not change the source code of the app after submitting the app to validation until the validation report has been received.

Mandatory

Pass / Fail

2

The SDK app validation tools should run on all of the source files (HTML, CSS, and JavaScript) and show no errors.

Mandatory

Pass / Fail

3

The images you use should be optimized and not exceed 1 megapixel.

Recommendation

Pass / Fail

4

The app should be fully navigable with the remote control using the following keys: 4 ways (Up / Down / Left / Right) + OK + Back (Exception: color key functionality indication buttons)

Mandatory

Pass / Fail

5

The app should only use a <audio> or <video> HTML5 element for playback.

Mandatory

Pass / Fail / Not Applicable

6

The app should not contain reference to a different manufacturer than the app is running on. (i.e. brand name of manufacturer)

Mandatory

Pass / Fail

7

The app should not contain any viruses, infections, malware or spyware.

Mandatory

Pass / Fail

8

The app should not infringe on copyright.

Mandatory

Pass / Fail

9

Your media encoding should be compatible with the Smart TV Alliance specification

Mandatory

Pass / Fail / Not Applicable

10

The app icon being submitted should be rectangular (not rounded edge) and should NOT use transparency.

Mandatory

Pass / Fail

FUNCTION

11

When audio or video is paused, the app should show a sign that indicates this (at least temporarily).

Recommendation

Pass / Fail / Not Applicable

12

The app should display media playtime and duration correctly.

Recommendation

Pass / Fail / Not Applicable

13

The App should show a loading UI when it is loading (start-up, video/audio playback start).

Mandatory

Pass / Fail

14

If the app detect the user has entered invalid credentials or invalid payment data, it should inform the user with a clear message.

Mandatory

Pass / Fail / Not Applicable

15

The app should provide with logging out functionality once a user has logged in.

Mandatory

Pass / Fail / Not Applicable

16

In case of an automatic login system, the app should handle a change in user credentials correctly.

Mandatory

Pass / Fail / Not Applicable

17

The app should be fully navigable with a pointer device (cursor) + OK + Back

Mandatory

Pass / Fail

18

The app should provide with logical spatial navigation.

Mandatory

Pass / Fail

19

When the back key is pressed at the top level of the application or on-screen exit button (optional) is pressed, the app should follow 'Back navigation' section in the 'Application Development and UI Guidelines'. The app may give a confirmation message when exiting the app. The TV device is to navigate back to the source application that called the application, but there could be exceptions.

Mandatory

Pass / Fail

20

The app should close the full screen mode when the remote control Back key is pressed during full screen video playback.
NOTE: in case the app consists of showing a full screen video playback only, this requirement is not applicable.

Mandatory

Pass / Fail

21

The app should use hierarchical back behavior instead of historical back behavior.

Recommendation

Pass / Fail

22

When pressing the remote control back key repeatedly, it should eventually exit the app. The app may give a confirmation message when exiting the app.

Mandatory

Pass / Fail

23

LG's Q.Menu on-screen button should be implemented when providing the full screen video playback. (Refer to the Diversity handling guideline).
And the app should hide this on-screen button for other platforms.

Recommendation

Pass / Fail

24

When playing media, there are no hiccup, block pattern (macro blocks), freezing, stuttering and audio/video out of sync.

Mandatory

Pass / Fail / Not Applicable

25

If the app implements the playback option UI, playback options should work seamlessly as a user would expect. The playback options should be available through on- screen playback buttons and through the remote control's playback buttons.

Mandatory

Pass / Fail / Not Applicable

26

When a video finishes playback, the app should return to a visibly usable state.

Mandatory

Pass / Fail / Not Applicable

27

When a user tries to access (a part of) the application which is restricted for his geographical area, a message should be shown to the user he is not able to view/open that (part of the) app.

Mandatory

Pass / Fail / Not Applicable

28

When a network connection is not available and the app requires the connection, it should provide with a meaningful error message and error handling.

Recommendation

Pass / Fail / Not Applicable

29

The default browser scrollbar should be hidden by using CSS 'overflow: hidden'

Mandatory

Pass / Fail

30

The app should never leave the screen completely black. (e.g. while loading contents when having a slow network).

Mandatory

Pass / Fail

31

The app should use VK_constants instead of key codes. Please refer to Section 4.2 of Diversity Handling Guideline.

Mandatory

Pass / Fail

32

JavaScript code is executed only after all required HTML element(s) are loaded.

Recommendation

Pass / Fail

LANGUAGE

33

All translation of text (including text of image) should be correct.

Recommendation

Pass / Fail / Not Applicable

34

When a user changes language selection, the chosen language should display properly.

Mandatory

Pass / Fail / Not Applicable

35

There is no spelling, punctuation or grammatical errors.

Recommendation

Pass / Fail / Not Applicable

36

Emoticons and special characters should be correctly displayed when used.

Mandatory

Pass / Fail / Not Applicable

ON SCREEN BUTTONS

37

For (horizontal or vertical) scrolling lists, app should provide on-screen scrolling buttons to browse through the list. Scrolling lists should be usable with remote control keys and a pointer device.

Recommendation

Pass / Fail

38

When implementing the remote control's colored keys, your app should provide on-screen button which indicate the functionality behind these keys. These should be navigable with a pointer device (cursor).

Mandatory

Pass / Fail / Not Applicable

39

If the App uses text entry it should support an on-screen keyboard. (Please refer to the diversity handling guidelines for implementation details)

Mandatory

Pass / Fail / Not Applicable

UI

40

The app size should support 1280 x 720 pixels.

Mandatory

Pass / Fail

41

All text, clickable items and company brand should be placed within the safe area of the screen. Safe area is 1216 x 666 pixels for the 1280 x 720 pixel resolution.

Mandatory

Pass / Fail

42

Clickable elements should be at least 54 x 54 pixels in size

Mandatory

Pass / Fail

43

The font size of all text in your app should always be at least 18 points.

Recommendation

Pass / Fail / Not Applicable

44

All text should have enough contrast to ensure they are clearly readable.

Recommendation

Pass / Fail / Not Applicable

45

The app should not show text outside the border of its container. (for any language)

Mandatory

Pass / Fail

46

The app should not show truncated text without using '...' at the end.

Mandatory

Pass / Fail

47

The app should not contain text with weird unexpected symbols. (as a result from wrong encoding for example)

Mandatory

Pass / Fail

48

If there is a mouse over action or a focus action, the app should show a different highlight.

Mandatory

Pass / Fail

49

The App should have three different highlights for idle, focus and active and should show the highlight for 'active' if the element is active. (e.g. 'tab-like' items or 'category- indicating').

Mandatory

Pass / Fail

50

The app should always show only one highlight for focus at the same time.

Mandatory

Pass / Fail