To return a random popular YouTube video for the user, or a random restaurant from Yelp.
- Click the “Restaurants” button
- Enter a valid location
- If it contains invalid characters, you will receive an alert letting you know to enter a location without the characters.
- If you receive any other error from the Yelp server, you will receive an alert that explains the error. You will then need to restart the app to try again.
- Once the location is presented to you
- you can go to the Yelp page by clicking the photo of the restaurant, name of the restaurant, or the address of the restaurant.
- You can click the “Find another restaurant” button if you’d like to find another restaurant. You would repeat the process of entering a valid location.
- You can also click the “Find a Youtube Video Instead” if you’d like to find a YouTube video instead. You would need to sign in if you haven’t already, or if your auth token wasn’t stored for any other reason. Otherwise, you’ll be presented with a video.
- Click the “Youtube Video” button
- You will likely need to sign in at this point, as you didn’t already sign in before.
- If you sign in with an email that isn’t already authorized to use the app, you will receive this message (see How to Use Randomizer). You can press Cancel. You will then receive an alert saying that you canceled the Sign-in. You can press OK, and try signing in again with a proper account if you have one.
- If you cancel the sign in, you will receive an alert saying that you canceled the Sign-in. You can press OK, and try signing in again
- Once the video is presented to you
- You can go to the YouTube video page by clicking the video’s thumbnail, clicking the name of the video, or clicking the channel name.
- You can find another video by clicking “Find Another Video”. You should be able to immediately get presented with a new video, as you’ve already signed in. If you receive an error along the lines of “you haven’t been authorized”, please restart the app.
- You can find a restaurant instead by clicking the “Find a Restaurant Instead” button.
If you don’t have a preference of a YouTube video or restaurant, click the “Literally Anything” button. Follow the applicable steps based on the storyboard presented to you.
Because this can get a little complicated to set up, I suggest just looking at my code and demo video. I am unable to add test users directly to my Google Cloud project because of quota reasons.
If you want to use this app, there are a few things you’ll need to do.
- Go to https://console.cloud.google.com/apis and choose or create the project that you’ll be using
- Scroll down to the bottom of the page to see if you already have YouTube Data API v3 enabled.
- If you don't have YouTube Data API v3 enabled ...
- Click “Enable APIs and Services” at the top of the page
- Search for “YouTube Data API v3” and click the API result that comes up
- Click Enable
- Once it’s enabled, go back to https://console.cloud.google.com/apis and click “OAuth consent screen” on the side
- If the OAuth Consent Screen isn’t already configured …
- I have it set to External Users. I don’t know if this will work for Internal Users, because the option of Internal Users is disabled for me. If in doubt, use external users.
- Click Create
- I believe there’s many OAuth configurations that could work here, so if you already have a configuration that will work you can skip this step. Here’s my specific configuration
- I have the app name set to
Randomizer
- I have “User Support Email” set to my own email
- I have nothing for App Logo or App Domain
- I have “Developer Contact Information” set to my own email
- Click "Save and Continue"
- I have no scopes for this project. Click "Save and Continue"
- I have my own username as a Test User
- I have the app name set to
- Click the “Credentials” tab on the left side
- Select “Create Credentials” at the top, then click “OAuth client ID”
- Select iOS as the application type
- Name it whatever you would like. Randomizer probably makes the most sense.
- Use
sharell-codes.Randomizer
for the Bundle ID, then click Create - Navigate back to https://console.cloud.google.com/apis/credentials. Under “Actions” for the appropriate OAuth Client, click “Download OAuth Client”. Then, click “DOWNLOAD PLIST”
- Download Randomizer Public.zip
- Find the folder and unzip it.
- Open your terminal and run
cd <insert_project_directory>
- Then, run
open Randomizer.xcworkspace
- Click File > Add Files to “Randomizer” …
- Locate the Google PLIST file you downloaded earlier and select it. Then, click “Options”, and select “Copy Items if needed”, “Create Folder References”, and select all boxes for “Add To Targets”. Then Click Add
- Replace the
insert CLIENT_ID
andinsert REVERSED_CLIENT_ID
values in info.plist. The place to insert the reversed client ID is specifically under Information Property List > URL Types > Item 1 > URL Schemes > Item 0. You can find these values in the Google PLIST. - Replace
insert CLIENT_ID
in line 19 of AppDelegate.swift with your client ID.
- Get API key at https://www.yelp.com/developers/v3/manage_app
- Replace "insert key here" in line 18 of FindRestaurantViewController.swift with your API key that you received from Yelp
- Close the project.
You’ll need to run pod install before running it every time.
- Open up the terminal.
- Run
cd <insert_project_directory>
. - Run
pod install
. - Run
open Randomizer.xcworkspace
. - Product > Run or Click the play button in the upper left corner of Xcode.