import { TNSSpotifyAuth } from 'nativescript-spotify' ; import { Config } from '../services/config.service' ; declare var UIApplicationDelegate ; var FRESH_LAUNCH = true ; export class SpotifyAppDelegate extends UIResponder { public static ObjCProtocols = [ UIApplicationDelegate ] ; public applicationDidFinishLaunchingWithOptions ( application , launchOptions ) { return true ; } public applicationOpenURLSourceApplicationAnnotation ( application , url , sourceApplication , annotation ) { console . log ( 'applicationOpenURLSourceApplicationAnnotation:' ) ; if ( url ) { let scheme = url . scheme ; let path = url . path ; let query = url . query ; console . log ( `scheme: ${ scheme }, path: ${ path }, query: ${ query }` ) ; let urlString = url . absoluteString ; console . log ( urlString ) ; if ( urlString . indexOf ( 'spotifylogin' ) > - 1 ) { return TNSSpotifyAuth . HANDLE_AUTH_CALLBACK ( url ) ; } else if ( query && query . indexOf ( 'n=' ) > - 1 && query . indexOf ( 'ti=' ) > - 1 ) { Config . SHARE_URL$ . next ( urlString ) ; } } return true ; } public applicationDidBecomeActive ( application ) { if ( FRESH_LAUNCH ) { console . log ( `FRESH_LAUNCH` ) ; FRESH_LAUNCH = false ; } } }