Closed viestat closed 6 years ago
@viestat omg dude you rock! I will test this against our project over the weekend.
@viestat I have been testing and came across an error on startAuthenticationFlow
, I submitted a PR against the beta-25
branch that seems to help with the problem.
This message also shows in the console in Xcode: Warning: Attempt to present <UINavigationController: 0x7f8fe15c0c00> on <UIViewController: 0x7f8fe0e14660> while a presentation is in progress!
It might make sense to use the suggestion on issue #10 and use dispatch_async
I feel like this type of authentication is somewhat problematic and frankly not ideal since users have to constantly re-auth, it might solve a lot of problems to use as a second option Authorization Code Flow
@viestat Having issues with almost all the NativeEventEmitter
events, the only one that is firing is audioStreamingDidLogin
, everything else does not fire. Here is an example of our implementation
const SpotifyAuth = require('NativeModules').SpotifyAuth;
const NativeEventEmitter = require('NativeEventEmitter');
class Player extends Component {
componentWillMount() {
this.spotify = new NativeEventEmitter(SpotifyAuth);
}
componentDidMount() {
this.spotify.addListener('didStartPlayingTrack', this.onPlaying);
this.spotify.addListener('didChangePlaybackStatus', (isPlaying) => console.log('didChangePlaybackStatus.isPlaying:', isPlaying));
this.spotify.addListener('didChangePosition', this.onChangePosition);
this.spotify.addListener('didReceiveError', (error) => console.log('didReceiveError:', error))
this.spotify.addListener('audioStreamingDidLogin', (error) => console.log('audioStreamingDidLogin:', error))
this.spotify.addListener('didReceivePlaybackEvent', (event) => console.log('didReceivePlaybackEvent:', event))
this.spotify.addListener('didSeekToPosition', (position) => console.log('didSeekToPosition:', position))
this.spotify.addListener('didChangeMetadata', (metadata) => console.log('didChangeMetadata:', metadata))
this.spotify.addListener('didStopPlayingTrack', (trackUri) => console.log('didStopPlayingTrack:', trackUri))
this.spotify.addListener('audioStreamingDidSkipToNextTrack', () => console.log('audioStreamingDidSkipToNextTrack'))
this.spotify.addListener('audioStreamingDidSkipToPreviousTrack', () => console.log('audioStreamingDidSkipToPreviousTrack'))
this.spotify.addListener('audioStreamingDidBecomeActivePlaybackDevice', () => console.log('audioStreamingDidBecomeActivePlaybackDevice'))
this.spotify.addListener('audioStreamingDidBecomeInactivePlaybackDevice', () => console.log('audioStreamingDidBecomeInactivePlaybackDevice'))
this.spotify.addListener('audioStreamingDidLosePermissionForPlayback', () => console.log('audioStreamingDidLosePermissionForPlayback'))
this.spotify.addListener('audioStreamingDidPopQueue', () => console.log('audioStreamingDidPopQueue'))
}
}
@digitaldavenyc I will be working on a fix to the issues you highlighted thanks for your support and patience :)
@viestat Looking forward to it!
I'd be happy to assist with any README updates or further code fixes. I tried looking into the issues with NativeEventEmitter
and don't see anything wrong with the implementation, have you been able to test the NativeEventEmitter
events firing successfully?
Do you think it makes sense to rename the SpotifyAuth
class to SpotifyModule
or update the README references to SpotifyAuth
?
@digitaldavenyc Regarding the the NativeEventEmitter
events, they do not seem to fire even directly in the native side. So it might be a bug in the SDK itself. I will continue looking into it but you might find that info useful.
@viestat are you sure it's an issue with the SDK? It's highly unlikely Spotify would release an SDK with that many broken events. I checked their GitHub issues and didn't see any issues with their events firing. It looks like these events have been part of the SDK since version 20. If it is in fact an issue with Spotify, we should open an issue.
I saw your changes to playbackState, these should be helpful in getting beta-25 version ready until we resolve this NativeEvent issue. Thanks!
@viestat I think the issue is you need to add the following line to SpotifyAuth.m: self.player.playbackDelegate = self;
At this location in your PR: https://github.com/viestat/react-native-spotify/pull/16/files#diff-3cb2dd92e545372fdf88500ec7772f2bR46
The reason you're not seeing events trigger is because you are registering SpotifyAuth as the SPTAudioStreamingDelegate but not the SPTAudioStreamingPlaybackDelegate (so you only get the audio streaming related events and not the playback related events)
@mross22 You are Amazing! that did it :) !!!!
Implementation for the newest version of Spotify SDK
TODO: