-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.mc
44 lines (35 loc) · 1.26 KB
/
App.mc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Copyright 2015-2016 by Garmin Ltd. or its subsidiaries.
// Subject to Garmin SDK License Agreement and Wearables
// Application Developer Agreement.
//
using Toybox.Application as App;
const ApiUrl = "https://api.spotify.com/v1/";
const RedirectUri = "http://localhost";
// The Application class is the bootstrap for the
// widget. It handles app lifecycle
class SpotifyWidget extends App.AppBase {
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state) {
}
// onStop() is called when your application is exiting
function onStop(state) {
}
// Return the initial view of your application here
function getInitialView() {
// Needed when developing in sim because sim's oauth browser
// doesn't support JS, which spotify's auth page needs.
// setProperty("refresh_token", $.RefreshToken);
var token = getProperty("refresh_token");
if(!System.getDeviceSettings().phoneConnected) {
return [new ConnectToGcmView() ];
} else if ( token == null ) {
return [ new LoginView(), new LoginDelegate() ];
} else {
return [ new SpotifyView(), new SpotifyButtonDelegate() ];
}
}
}