timflapper / cordova-spotify-plugin

This plugin provides a PhoneGap / Cordova API for the Spotify iOS SDK.
MIT License
48 stars 12 forks source link

Javascript error: Can't find variable: spotify #4

Open traecadenhead opened 9 years ago

traecadenhead commented 9 years ago

After a long and vicious battle, I finally got the plugin installed and building. However, when I try to call the spotify.authenticate method in javascript, I'm getting the js error "can't find variable: spotify." My first thought was that it was not loading all of the plugin javascript files, but I've checked everything and all 7 js files from the plugin are loading fine. I looked at the js files, though, and didn't see any sort of "spotify" object - for instance in the auth.js file it looks like the object is "auth" instead of "spotify". I'm including a screenshot of my cordova_plugins.js file just in case references there may be wrong (as far as I can tell they should be correct).

shot

Any pointers?

timflapper commented 9 years ago

@traecadenhead, it's true there is no spotify object. You can see in the plugin.xml that the spotify object is a base object that all these different files (auth.js, etc..) get merged into. The spotify object does exist however. The command spotify.authenticate(....); should work after the installation is complete. You do have to wait until the app is loaded completely by Cordova. Maybe you're trying to call the method too soon?

adriaanmeuris commented 8 years ago

Same here, willing to help. The plugin is definitely installed:

phonegap plugin add https://github.com/timflapper/cordova-spotify-plugin.git
...
phonegap plugin add https://github.com/timflapper/cordova-spotify-plugin.git
...
Plugin "com.timflapper.spotify" already installed on ios.

I'm started out with the default Phonegap Hello World app, in which a deviceReady event listener is already available:

document.addEventListener('deviceready', this.onDeviceReady, false);

However, the spotify object is not available in the onDeviceReady function. I tried logging all available objects, but I'm unable to work with the Spotify plugin.

A console.log(typeof spotify); in the onDeviceReady gives undefined.

Any ideas how I can proceed debugging?