From b31401b8c5286fab2cb1c26fc241c9fde6961cb3 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:13:38 +0200 Subject: [PATCH 01/11] Added optional Authorization Code Flow --- .DS_Store | Bin 0 -> 6148 bytes README.md | 82 +++++++++++------- spotifyModule/ios/SpotifyAuth.m | 39 +++++++-- .../spotifyModule.xcodeproj/project.pbxproj | 7 ++ 4 files changed, 90 insertions(+), 38 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4338be314097d9ebe44fb1be7d518b369738778e GIT binary patch literal 6148 zcmeHKJxc>o5S-N%0TEJKzQ5o_c zOTT*_p2l(D@xPUAS$8Nqe~+?KKnh3!DIf);Kq}x(mA1S}RFnczKni>-;NOQvckBwM z#Q1bD#0WrKFdfF{m?enK6U44?N@Rv+NhK!LYQ(UlGvBJNE1VLO4vU+4PTg!Zp;+9` ze2a2em#8QOq`;{Hm$_Vd|G%UEF#n&Dw2}f+;9n_Vi_ODk%~z`4I(s?qwT=ErKNxGH noFQ5Y6`uzbl*)gU)==iTV+6U1U<=FBJF!S9~7Z literal 0 HcmV?d00001 diff --git a/README.md b/README.md index a8ef64a..c675cf2 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ___ 4. Please folow the instructions on the **"Creating Your Client ID, Secret and Callback URI"** and **"Setting Up Your Build Environment"** sections of the [*Spotify iOS SDK Tutorial*](https://developer.spotify.com/technologies/spotify-ios-sdk/tutorial/) >**Important Note!** When adding frameworks to the list in the "**Link Binary With Libraries**" section you wll need to add `WebKit.framework` in addition to those mentioned in the tutorial. -5. From this project directory, go to `react-native-spotify/spotifyModule/ios` and copy the following files to the `ios` directory of your project: +5. From this project directory, go to `react-native-spotify/SpotifyAuth/ios` and copy the following files to the `ios` directory of your project: * `SpotifyLoginViewController.m` * `SpotifyLoginViewController.h` * `SpotifyAuth.m` @@ -87,7 +87,7 @@ ___ ###Auth: -**setClientID:setRedirectURL:setRequestedScopes:callback** +**options:callback** > **You need this to Auth a user, without it you cant use any other methods!** @@ -99,11 +99,35 @@ Set your Client ID, Redirect URL, Scopes and **start the auth process** |Client ID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Redirect URL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Scopes|`(Array)` list of scopes of your app, [see here](https://developer.spotify.com/web-api/using-scopes/) | +|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authentication Code Flow)| +|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authentication Code Flow)| |Callback|`(Function)`a callback to handle the login success/error| -Example: +### Implicit Grant Flow" + +````` +const options = { + clientID: 'your-clientID', + redirectURL: 'your-app-schema://callback', + requestedScopes: ['streaming',...] +}; + +SpotifyAuth.login(options,(error)=>{console.log(error)}); +````` + +### Authentication Code Flow + +````` +const options = { + clientID: 'your-clientID', + redirectURL: 'your-app-schema://callback', + requestedScopes: ['streaming',...], + tokenSwapURL: 'http://your.backend.com/token/swap', + tokenRefreshURL: 'http://your.backend.com/token/refresh' +}; -`SpotifyAuth.setClientID('your-clientID','your-redirectURL',['streaming',...],(error)=>{console.log(error)});` +SpotifyAuth.login(options,(error)=>{console.log(error)}); +````` ###SPTAudioStreamingController Class: ### *Properties:* @@ -118,7 +142,7 @@ Returns true when SPTAudioStreamingController is initialized, otherwise false Example: -`SpotifyModule.initialized((res)=>{console.log(res);});` +`SpotifyAuth.initialized((res)=>{console.log(res);});` **[loggedIn](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/loggedIn)** @@ -131,7 +155,7 @@ Returns true if the receiver is logged into the Spotify service, otherwise false Example: -`SpotifyModule.loggedIn((res)=>{console.log(res);});` +`SpotifyAuth.loggedIn((res)=>{console.log(res);});` **[isPlaying](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/isPlaying)** @@ -144,7 +168,7 @@ Returns true if the receiver is playing audio, otherwise false Example: -`SpotifyModule.isPlaying((res)=>{console.log(res);});` +`SpotifyAuth.isPlaying((res)=>{console.log(res);});` **[volume](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/volume)** @@ -157,7 +181,7 @@ Returns the volume Example: -`SpotifyModule.volume((res)=>{console.log(res);});` +`SpotifyAuth.volume((res)=>{console.log(res);});` **[shuffle](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/shuffle)** @@ -170,7 +194,7 @@ Returns true if the receiver expects shuffled playback, otherwise false Example: -`SpotifyModule.shuffle((res)=>{console.log(res);});` +`SpotifyAuth.shuffle((res)=>{console.log(res);});` **[repeat](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/repeat)** @@ -183,7 +207,7 @@ Returns true if the receiver expects repeated playback, otherwise false Example: -`SpotifyModule.repeat((res)=>{console.log(res);});` +`SpotifyAuth.repeat((res)=>{console.log(res);});` **[currentPlaybackPosition](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/currentPlaybackPosition)** @@ -196,7 +220,7 @@ Returns the current approximate playback position of the current track Example: -`SpotifyModule.currentPlaybackPosition((res)=>{console.log(res);});` +`SpotifyAuth.currentPlaybackPosition((res)=>{console.log(res);});` **[currentTrackDuration](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/currentTrackDuration)** @@ -209,7 +233,7 @@ Returns the length of the current track Example: -`SpotifyModule.currentTrackDuration((res)=>{console.log(res);});` +`SpotifyAuth.currentTrackDuration((res)=>{console.log(res);});` **[currentTrackURI](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/currentTrackURI)** @@ -222,7 +246,7 @@ Returns the current track URI, playing or not Example: -`SpotifyModule.currentTrackURI((res)=>{console.log(res);});` +`SpotifyAuth.currentTrackURI((res)=>{console.log(res);});` **[currentTrackIndex](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/currentTrackIndex)** @@ -235,7 +259,7 @@ Returns the currenly playing track index Example: -`SpotifyModule.currentTrackIndex((res)=>{console.log(res);});` +`SpotifyAuth.currentTrackIndex((res)=>{console.log(res);});` **[targetBitrate](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/targetBitrate)** @@ -248,7 +272,7 @@ Returns the current streaming bitrate the receiver is using Example: -`SpotifyModule.targetBitrate((res)=>{console.log(res);});` +`SpotifyAuth.targetBitrate((res)=>{console.log(res);});` ### *Methods:* @@ -262,7 +286,7 @@ Logout from Spotify Example: -`SpotifyModule.logout();` +`SpotifyAuth.logout();` **[-setVolume:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/setVolume:callback:)** @@ -275,7 +299,7 @@ Set playback volume to the given level. Volume is a value between `0.0` and `1.0 Example: -`SpotifyModule.setVolume(0.8,(error)=>{console.log(error);});` +`SpotifyAuth.setVolume(0.8,(error)=>{console.log(error);});` **[-setTargetBitrate:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/setTargetBitrate:callback:)** @@ -288,7 +312,7 @@ Set the target streaming bitrate. `0` for low, `1` for normal and `2` for high Example: -`SpotifyModule.setTargetBitrate(2,(error)=>{console.log(error);});` +`SpotifyAuth.setTargetBitrate(2,(error)=>{console.log(error);});` **[-seekToOffset:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/seekToOffset:callback:)** @@ -301,7 +325,7 @@ Seek playback to a given location in the current track (in secconds). Example: -`SpotifyModule.seekToOffset(110,(error)=>{console.log(error);});` +`SpotifyAuth.seekToOffset(110,(error)=>{console.log(error);});` **[-playURIs:withOptions:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/playURIs:withOptions:callback:)** @@ -315,7 +339,7 @@ Play a list of Spotify URIs.(at most 100 tracks).`SPTPlayOptions` containing ext Example: -`SpotifyModule.playURIs(["spotify:track:6HxIUB3fLRS8W3LfYPE8tP",...], {trackIndex :0, startTime:12.0},(error)=>{console.log(error)});` +`SpotifyAuth.playURIs(["spotify:track:6HxIUB3fLRS8W3LfYPE8tP",...], {trackIndex :0, startTime:12.0},(error)=>{console.log(error)});` **[-replaceURIs:withCurrentTrack:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/replaceURIs:withCurrentTrack:callback:)** @@ -329,7 +353,7 @@ Example: Example: -`SpotifyModule.replaceURIs(["spotify:track:6HxIUB3fLRS8W3LfYPE8tP",...], 0, (error)=>{console.log(error)});` +`SpotifyAuth.replaceURIs(["spotify:track:6HxIUB3fLRS8W3LfYPE8tP",...], 0, (error)=>{console.log(error)});` **[-playURI:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/playURI:callback:)** @@ -342,7 +366,7 @@ Play a Spotify URI. Example: -`SpotifyModule.playURI("spotify:track:6HxIUB3fLRS8W3LfYPE8tP",(error)=>{console.log(error);});` +`SpotifyAuth.playURI("spotify:track:6HxIUB3fLRS8W3LfYPE8tP",(error)=>{console.log(error);});` **[-queueURI:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/queueURI:callback:)** @@ -355,7 +379,7 @@ Queue a Spotify URI. Example: -`SpotifyModule.queueURI("spotify:track:6HxIUB3fLRS8W3LfYPE8tP",(error)=>{console.log(error);});` +`SpotifyAuth.queueURI("spotify:track:6HxIUB3fLRS8W3LfYPE8tP",(error)=>{console.log(error);});` **[-setIsPlaying:callback:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/setIsPlaying:callback:)** @@ -368,7 +392,7 @@ Set the "playing" status of the receiver. Example: -`SpotifyModule.setIsPlaying(true,(error)=>{console.log(error);});` +`SpotifyAuth.setIsPlaying(true,(error)=>{console.log(error);});` **[-stop:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/stop:)** @@ -380,7 +404,7 @@ Stop playback and clear the queue and list of tracks. Example: -`SpotifyModule.stop((error)=>{console.log(error);});` +`SpotifyAuth.stop((error)=>{console.log(error);});` **[-skipNext:](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/skipNext:)** @@ -392,7 +416,7 @@ Go to the next track in the queue Example: -`SpotifyModule.skipNext((error)=>{console.log(error);});` +`SpotifyAuth.skipNext((error)=>{console.log(error);});` **[-skipPrevious:(RCTResponseSenderBlock)block](https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTAudioStreamingController.html#//api/name/skipPrevious:)** @@ -404,7 +428,7 @@ Go to the previous track in the queue Example: -`SpotifyModule.skipPrevious((error)=>{console.log(error);});` +`SpotifyAuth.skipPrevious((error)=>{console.log(error);});` ___ @@ -425,7 +449,7 @@ Go to the previous track in the queue *You need to have a session first* Example: ```javascript -SpotifyModule.performSearchWithQuery('lacri','artist',0,'US',(err, res)=>{ +SpotifyAuth.performSearchWithQuery('lacri','artist',0,'US',(err, res)=>{ console.log('error', err); console.log('result', res); }); @@ -438,7 +462,7 @@ ___ >Included in the repo. -![alt text](https://github.com/viestat/react-native-spotify/blob/master/spotifyModuleDemoEdit.gif?raw=true = 250x "Demo") +![alt text](https://github.com/viestat/react-native-spotify/blob/master/SpotifyAuthDemoEdit.gif?raw=true = 250x "Demo") ___ diff --git a/spotifyModule/ios/SpotifyAuth.m b/spotifyModule/ios/SpotifyAuth.m index c11e1c2..b1a484d 100644 --- a/spotifyModule/ios/SpotifyAuth.m +++ b/spotifyModule/ios/SpotifyAuth.m @@ -16,6 +16,8 @@ @interface SpotifyAuth () @property (nonatomic, strong) SPTAudioStreamingController *player; @property (nonatomic, strong) NSString *clientID; @property (nonatomic, strong) NSArray *requestedScopes; +@property (nonatomic, strong) NSURL *tokenSwapURL; +@property (nonatomic, strong) NSURL *tokenRefreshURL; @end @implementation SpotifyAuth @@ -23,17 +25,23 @@ @implementation SpotifyAuth RCT_EXPORT_MODULE() //Start Auth process -RCT_EXPORT_METHOD(setClientID:(NSString *) clientID - setRedirectURL:(NSString *) redirectURL - setRequestedScopes:(NSArray *) requestedScopes +RCT_EXPORT_METHOD(login:(NSDictionary *) options callback:(RCTResponseSenderBlock)block) { + NSString *clientID = options[@"clientID"]; + NSString *redirectURL = options[@"redirectURL"]; + NSArray *requestedScopes = options[@"requestedScopes"]; + NSURL *tokenSwapURL = [NSURL URLWithString:options[@"tokenSwapURL"]]; + NSURL *tokenRefreshURL = [NSURL URLWithString:options[@"tokenRefreshURL"]]; + SpotifyAuth *sharedManager = [SpotifyAuth sharedManager]; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; //set the sharedManager properties [sharedManager setClientID:clientID]; [sharedManager setRequestedScopes:requestedScopes]; [sharedManager setMyScheme:redirectURL]; + [sharedManager setTokenSwapURL:tokenSwapURL]; + [sharedManager setTokenRefreshURL:tokenRefreshURL]; //Observer for successful login [center addObserverForName:@"loginRes" object:nil queue:nil usingBlock:^(NSNotification *notification) @@ -47,7 +55,7 @@ @implementation SpotifyAuth }]; - [self startAuth:clientID setRedirectURL:redirectURL setRequestedScopes:requestedScopes]; + [self startAuth:clientID setRedirectURL:redirectURL setRequestedScopes:requestedScopes setTokenSwapURL:tokenSwapURL setTokenRefreshURL:tokenRefreshURL]; } ///////////////////////////////// @@ -390,7 +398,11 @@ @implementation SpotifyAuth ///////////////////////////////// -- (BOOL)startAuth:(NSString *) clientID setRedirectURL:(NSString *) redirectURL setRequestedScopes:(NSArray *) requestedScopes { +- (BOOL)startAuth:(NSString *) clientID + setRedirectURL:(NSString *) redirectURL + setRequestedScopes:(NSArray *) requestedScopes + setTokenSwapURL:(NSURL *) tokenSwapURL + setTokenRefreshURL:(NSURL *) tokenRefreshURL { NSMutableArray *scopes = [NSMutableArray array]; //Turn scope arry of strings into an array of SPTAuth...Scope objects for (int i = 0; i < [requestedScopes count]; i++) { @@ -422,9 +434,11 @@ - (BOOL)startAuth:(NSString *) clientID setRedirectURL:(NSString *) redirectURL FOUNDATION_EXPORT NSString * const SPTAuthStreamingScope; */ [[SPTAuth defaultInstance] setClientID:clientID]; + [[SPTAuth defaultInstance] setTokenSwapURL:tokenSwapURL]; + [[SPTAuth defaultInstance] setTokenRefreshURL:tokenRefreshURL]; [[SPTAuth defaultInstance] setRedirectURL:[NSURL URLWithString:redirectURL]]; [[SPTAuth defaultInstance] setRequestedScopes:scopes]; - + // Construct a login URL NSURL *loginURL = [[SPTAuth defaultInstance] loginURL]; @@ -436,14 +450,13 @@ - (BOOL)startAuth:(NSString *) clientID setRedirectURL:(NSString *) redirectURL //Present the webView over the rootView [delegate.window.rootViewController presentViewController: controller animated:YES completion:nil]; - - return YES; } -(void)urlCallback: (NSURL *)url { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; NSMutableDictionary *loginRes = [NSMutableDictionary dictionary]; + if ([[SPTAuth defaultInstance] canHandleURL:url]) { [[SPTAuth defaultInstance] handleAuthCallbackWithTriggeredAuthURL:url callback:^(NSError *error, SPTSession *session) { @@ -487,7 +500,7 @@ -(void)checkSession{ if(error != nil){ NSLog(@"Error: %@", error); //launch the login again - [sharedManager startAuth:sharedManager.clientID setRedirectURL:sharedManager.myScheme setRequestedScopes:sharedManager.requestedScopes]; + [sharedManager startAuth:sharedManager.clientID setRedirectURL:sharedManager.myScheme setRequestedScopes:sharedManager.requestedScopes setTokenSwapURL:sharedManager.tokenSwapURL setTokenRefreshURL:sharedManager.tokenRefreshURL]; } else { [sharedManager setSession:session]; [[sharedManager player] loginWithAccessToken:session.accessToken]; @@ -513,6 +526,14 @@ -(void)setRequestedScopes:(NSArray *)requestedScopes{ _requestedScopes = requestedScopes; } +-(void)setTokenSwapURL:(NSURL *)tokenSwapURL{ + _tokenSwapURL = tokenSwapURL; +} + +-(void)setTokenRefreshURL:(NSURL *)tokenRefreshURL{ + _tokenRefreshURL = tokenRefreshURL; +} + + (id)sharedManager { static SpotifyAuth *sharedMyManager = nil; @synchronized(self) { diff --git a/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj b/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj index 75e212f..2ea917a 100644 --- a/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj +++ b/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj @@ -393,6 +393,9 @@ CreatedOnToolsVersion = 6.2; TestTargetID = 13B07F861A680F5B00A75B9A; }; + 13B07F861A680F5B00A75B9A = { + DevelopmentTeam = 5479AH9JUJ; + }; }; }; buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "spotifyModule" */; @@ -642,6 +645,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; + DEVELOPMENT_TEAM = 5479AH9JUJ; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -652,6 +656,7 @@ "$(SRCROOT)/../node_modules/react-native/React/**", ); INFOPLIST_FILE = spotifyModule/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ( "$(inherited)", @@ -666,6 +671,7 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = 5479AH9JUJ; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -676,6 +682,7 @@ "$(SRCROOT)/../node_modules/react-native/React/**", ); INFOPLIST_FILE = spotifyModule/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ( "$(inherited)", From 94af10c425eaae9fd69bf88ca0a892d1cc622792 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:14:39 +0200 Subject: [PATCH 02/11] Added gitignore --- .gitignore | 1 + README.md | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md index c675cf2..b07cb1b 100644 --- a/README.md +++ b/README.md @@ -99,8 +99,8 @@ Set your Client ID, Redirect URL, Scopes and **start the auth process** |Client ID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Redirect URL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Scopes|`(Array)` list of scopes of your app, [see here](https://developer.spotify.com/web-api/using-scopes/) | -|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authentication Code Flow)| -|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authentication Code Flow)| +|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authorization Code Flow)| +|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authorization Code Flow)| |Callback|`(Function)`a callback to handle the login success/error| ### Implicit Grant Flow" @@ -115,7 +115,7 @@ const options = { SpotifyAuth.login(options,(error)=>{console.log(error)}); ````` -### Authentication Code Flow +### Authorization Code Flow ````` const options = { From 37a2de04034b77d8b191e45f617cb571706c033d Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:14:55 +0200 Subject: [PATCH 03/11] Removed DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 4338be314097d9ebe44fb1be7d518b369738778e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJxc>o5S-N%0TEJKzQ5o_c zOTT*_p2l(D@xPUAS$8Nqe~+?KKnh3!DIf);Kq}x(mA1S}RFnczKni>-;NOQvckBwM z#Q1bD#0WrKFdfF{m?enK6U44?N@Rv+NhK!LYQ(UlGvBJNE1VLO4vU+4PTg!Zp;+9` ze2a2em#8QOq`;{Hm$_Vd|G%UEF#n&Dw2}f+;9n_Vi_ODk%~z`4I(s?qwT=ErKNxGH noFQ5Y6`uzbl*)gU)==iTV+6U1U<=FBJF!S9~7Z From 84e487ae4d847a279818808efb2edf514ae40e6e Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:17:28 +0200 Subject: [PATCH 04/11] Fixed README --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index b07cb1b..81add29 100644 --- a/README.md +++ b/README.md @@ -67,16 +67,23 @@ var SpotifyAuth = NativeModules.SpotifyAuth; class yourComponent extends Component { //Some code ... + someMethod(){ //You need this to Auth a user, without it you cant use any method! - SpotifyAuth.setClientID('Your ClientId','Your redirectURL', ['streaming'], (error)=>{ - if(error){ + + const options = { + clientID: 'your-clientID', + redirectURL: 'your-app-schema://callback', + requestedScopes: ['streaming',...] + }; + + SpotifyAuth.login(options, (error) => { + if (error) { //handle error } else { //handle success } - }); - } + }); } ``` @@ -103,7 +110,7 @@ Set your Client ID, Redirect URL, Scopes and **start the auth process** |Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authorization Code Flow)| |Callback|`(Function)`a callback to handle the login success/error| -### Implicit Grant Flow" +### Implicit Grant Flow ````` const options = { From c909fa32ffd0ba88b29936febe9b308e59dca6b9 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:19:00 +0200 Subject: [PATCH 05/11] Fixed README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 81add29..548e063 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,8 @@ Set your Client ID, Redirect URL, Scopes and **start the auth process** |Client ID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Redirect URL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |Scopes|`(Array)` list of scopes of your app, [see here](https://developer.spotify.com/web-api/using-scopes/) | -|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authorization Code Flow)| -|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authorization Code Flow)| +|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| +|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| |Callback|`(Function)`a callback to handle the login success/error| ### Implicit Grant Flow From dfe07f403d7eea871a93df6ecc8f163f2adfc3f3 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:21:08 +0200 Subject: [PATCH 06/11] Fixed README --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 548e063..fa226d0 100644 --- a/README.md +++ b/README.md @@ -103,12 +103,12 @@ Set your Client ID, Redirect URL, Scopes and **start the auth process** | Parameter |description| | ------ |:-------------------------------| -|Client ID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| -|Redirect URL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| -|Scopes|`(Array)` list of scopes of your app, [see here](https://developer.spotify.com/web-api/using-scopes/) | -|Token Swap URL|`(String)` The backend URL to exchange authorization code for access token (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| -|Token Refresh URL|`(String)` The backend URL to refresh an authorization code (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| -|Callback|`(Function)`a callback to handle the login success/error| +|clientID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| +|redirectURL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| +|requestedScopes|`(Array)` list of scopes of your app, [see here](https://developer.spotify.com/web-api/using-scopes/) | +|tokenSwapURL|`(String)` Backend URL to exchange authorization code for access token (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| +|tokenRefreshURL|`(String)` Backend URL to refresh an access token (only Authorization Code Flow [see here](https://developer.spotify.com/web-api/authorization-guide/#supported-authorization-flows))| +|callback|`(Function)`a callback to handle the login success/error| ### Implicit Grant Flow From 36fbf1e20514dc5fd648746827e62ce7d03631fb Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:21:44 +0200 Subject: [PATCH 07/11] Fixed README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa226d0..ccad25b 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ ___ Set your Client ID, Redirect URL, Scopes and **start the auth process** -| Parameter |description| +| Option |description| | ------ |:-------------------------------| |clientID|`(String)` The client ID of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| |redirectURL|`(String)` The Redirect URL of your [registered Spotify app](https://developer.spotify.com/my-applications/#!/applications)| From 3279278b966e312537a1e1269bee0a5603cf21d7 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:27:02 +0200 Subject: [PATCH 08/11] Fixed README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ccad25b..0e628bf 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ___ 4. Please folow the instructions on the **"Creating Your Client ID, Secret and Callback URI"** and **"Setting Up Your Build Environment"** sections of the [*Spotify iOS SDK Tutorial*](https://developer.spotify.com/technologies/spotify-ios-sdk/tutorial/) >**Important Note!** When adding frameworks to the list in the "**Link Binary With Libraries**" section you wll need to add `WebKit.framework` in addition to those mentioned in the tutorial. -5. From this project directory, go to `react-native-spotify/SpotifyAuth/ios` and copy the following files to the `ios` directory of your project: +5. From this project directory, go to `react-native-spotify/SpotifyModule/ios` and copy the following files to the `ios` directory of your project: * `SpotifyLoginViewController.m` * `SpotifyLoginViewController.h` * `SpotifyAuth.m` From ca24fcbe45eba19691962d28f41dc9ff0c16ee2c Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:28:35 +0200 Subject: [PATCH 09/11] Fixed README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e628bf..87c4851 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ ___ 4. Please folow the instructions on the **"Creating Your Client ID, Secret and Callback URI"** and **"Setting Up Your Build Environment"** sections of the [*Spotify iOS SDK Tutorial*](https://developer.spotify.com/technologies/spotify-ios-sdk/tutorial/) >**Important Note!** When adding frameworks to the list in the "**Link Binary With Libraries**" section you wll need to add `WebKit.framework` in addition to those mentioned in the tutorial. -5. From this project directory, go to `react-native-spotify/SpotifyModule/ios` and copy the following files to the `ios` directory of your project: +5. From this project directory, go to `react-native-spotify/spotifyModule/ios` and copy the following files to the `ios` directory of your project: * `SpotifyLoginViewController.m` * `SpotifyLoginViewController.h` * `SpotifyAuth.m` From 9bf7d6a0de41bc9e3dc36d4a08bd4747bd2d0912 Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:31:54 +0200 Subject: [PATCH 10/11] Fixed Xcode project --- spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj | 7 ------- .../xcshareddata/xcschemes/spotifyModule.xcscheme | 0 2 files changed, 7 deletions(-) mode change 100644 => 100755 spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj mode change 100644 => 100755 spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme diff --git a/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj b/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj old mode 100644 new mode 100755 index 2ea917a..75e212f --- a/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj +++ b/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj @@ -393,9 +393,6 @@ CreatedOnToolsVersion = 6.2; TestTargetID = 13B07F861A680F5B00A75B9A; }; - 13B07F861A680F5B00A75B9A = { - DevelopmentTeam = 5479AH9JUJ; - }; }; }; buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "spotifyModule" */; @@ -645,7 +642,6 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; DEAD_CODE_STRIPPING = NO; - DEVELOPMENT_TEAM = 5479AH9JUJ; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -656,7 +652,6 @@ "$(SRCROOT)/../node_modules/react-native/React/**", ); INFOPLIST_FILE = spotifyModule/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ( "$(inherited)", @@ -671,7 +666,6 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = 5479AH9JUJ; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)", @@ -682,7 +676,6 @@ "$(SRCROOT)/../node_modules/react-native/React/**", ); INFOPLIST_FILE = spotifyModule/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; OTHER_LDFLAGS = ( "$(inherited)", diff --git a/spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme b/spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme old mode 100644 new mode 100755 From a9da45d3314a757dc80b8b24969bbc1376e8961a Mon Sep 17 00:00:00 2001 From: moooji Date: Sat, 24 Sep 2016 00:33:20 +0200 Subject: [PATCH 11/11] Fixed Xcode project --- spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj | 0 .../xcshareddata/xcschemes/spotifyModule.xcscheme | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj mode change 100755 => 100644 spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme diff --git a/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj b/spotifyModule/ios/spotifyModule.xcodeproj/project.pbxproj old mode 100755 new mode 100644 diff --git a/spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme b/spotifyModule/ios/spotifyModule.xcodeproj/xcshareddata/xcschemes/spotifyModule.xcscheme old mode 100755 new mode 100644