Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions example/index.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ class logIn extends Component {
style={styles.button}
onPress={() => {
//Start Auth process
SpotifyModule.loggedIn((res) => {
SpotifyModule.loggedIn((res, accessToken) => {
console.warn(res)
if(!res) {
SpotifyModule.startAuthenticationFlow((error) => {
if(!error){
SpotifyModule.startAuthenticationFlow((error, str) => {
if(!error){
console.log("New Access Token = "+str);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change this to template literals:
`New Access Token ${str}`

this.props.navigator.replace({
component: logInSuccess,
title: 'Success'
Expand All @@ -47,6 +48,7 @@ class logIn extends Component {
}
});
} else {
console.log("Cached Access Token = "+accessToken);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here too :)

this.props.navigator.replace({
component: logInSuccess,
title: 'Success'
Expand Down
16 changes: 12 additions & 4 deletions example/ios/SpotifyAuth.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ @implementation SpotifyAuth
RCT_EXPORT_METHOD(loggedIn:(RCTResponseSenderBlock)block)
{
SPTAudioStreamingController *sharedIn = [SPTAudioStreamingController sharedInstance];
block(@[@([sharedIn loggedIn])]);
if([sharedIn loggedIn]) {
block(@[@([sharedIn loggedIn]), self.auth.session.accessToken]);

} else {
block(@[@([sharedIn loggedIn])]);
}
}

//Returns the volume, as a value between 0.0 and 1.0.
Expand Down Expand Up @@ -478,6 +483,7 @@ - (void)audioStreaming:(SPTAudioStreamingController *)audioStreaming didStartPla
- (void)audioStreaming:(SPTAudioStreamingController *)audioStreaming didStopPlayingTrack:(NSString *)trackUri
{
[self sendEventWithName:@"didStopPlayingTrack" body:@{@"trackUri": trackUri}];

}

/** Called when the audio streaming object requests playback skips to the next track.
Expand Down Expand Up @@ -615,9 +621,9 @@ - (void)audioStreamingDidPopQueue:(SPTAudioStreamingController *)audioStreaming
{
//if there is an error key in the userInfo dictionary send the error, otherwise null
if(notification.userInfo[@"error"] != nil){
block(@[notification.userInfo[@"error"]]);
} else {
block(@[[NSNull null]]);
block(@[notification.userInfo[@"error"], @"not wow"]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a more descriptive message.

} else if(notification.userInfo[@"token"] != nil) {
block(@[[NSNull null], notification.userInfo[@"token"]]);
}

}];
Expand Down Expand Up @@ -687,6 +693,8 @@ -(void)urlCallback: (NSURL *)url {

} else {
if (session) {
loginRes[@"token"] = session.accessToken;
[center postNotificationName:@"loginRes" object:nil userInfo:loginRes];
// login to the player
[self.player loginWithAccessToken:self.auth.session.accessToken];
}
Expand Down