Hey everybody this is Caleb with Debb slopes dot com and welcome to the in-app purchase target topic.
I'm so stoked to teach you everything you need to know about consumable and non consumable in-app purchases.
There's a lot to learn so we're going to dive right into it now.
Let's go ahead and let's begin by actually creating our ex code project.
So pull up an X code and we're going to dive right into it.
Let's go ahead and just click on Create new X code project just like that.
Choose a single view application and we're going to need to pay attention here to our product name.
So I'm going to think what do I want to call this.
I'm going to call it food Zilah just like that.
And now our organization identifier has calmed down slopes and our bundle identifier is calm.
Depth slopes that food Zilah.
This of course is going to be different for you simply because you're going to have a different organization
identifier.
But we will need this later on.
We're also going to need the product name.
So let's go ahead leave everything until it and go ahead and click next.
Just like that and I'm going to go ahead and just go ahead and save it here to my folder that I have
used here.
Beautiful save wherever and you'll see that it automatically manages all the signing for you which is
going to come in handy.
What else.
Let's see we have everything here.
Why don't we go ahead and add in our assets.
So we're going to drop on the images we'll be using and you can download these from the source code.
There's a little button with a folder and a little download icon if you tap on that.
It will allow you to download those files or if you're on an iPhone you can airdrop them straight to
your Mac.
Pretty cool.
So go ahead and drag in these image sets.
And as you can see they all add in properly.
We have a close button and we also have some pictures of food because in this course we're going to
make a restaurant app that lets you basically go on choose a food item and you can buy it using it in
that purchase.
We're going to have ads displayed which will basically allow you to use a non consumable purchase to
hide the ads.
It's going to be pretty cool.
That's a pretty common way that non consumables are used in consumer facing apps.
So now that our assets are properly added Let's go ahead.
I want to show you actually a demo of a finished version of food Zilah.
So I'm going to go ahead and collapse this and pull open my simulator.
All right.
So here we go.
There is my iPhone by the way for testing in-app purchases.
Sometimes the simulator can be finicky sometimes it might work sometimes it might not work.
So with that in mind I'm going to go ahead and show you this on my iPhone how it works.
I have it set up right here in front of me.
So in our app what you can do here is you can go ahead and select a food item you can see a picture
its price its name and you also see an ad a very annoying ad mind you.
Now if I wanted to go ahead and buy this salmon meal I could tap by item for 999 and of course it's
going to ask for the password for my test account which will create those later on.
Sandbox users are going to log in and it will present me with a pop up saying do you want to buy one
meal for 999.
If I tap by you'll see it will present me with your purchase was successful and it also presents hope
you're hungry.
You just bought a meal.
There is a consumable purchase.
So check it out.
I can tap it again.
I can buy it again over and over and over again your purchase was successful.
But what if I wanted to remove these ads.
All I need to do is tap on buy hide ads for 99 cents and this is an example of a non consumable in that
purchase.
If I tap buy it says hey you've already purchased this would you like to get it again for free.
That's also a cool thing about non consumable purchases which we'll talk about later on.
If I tap OK.
It says your purchase was successful.
And take a look.
The ads are gone.
The button is gone and we now have a clean ad for user experience.
That's pretty cool and all but another thing I need to show you is restoring our purchases.
Let's say we've already purchased the hiding adds functionality but maybe I got a new phone and I re
download this app and boom the ads are back but with Restore we have the ability to restore those in-app
purchases just like in many other apps you've probably used before.
So I want to show you how that works but in order to do that I'm going to have to go ahead and uninstall
this and then bring it back up so just a moment.
All right.
Here we go.
So check it out guys.
If I open up the app you'll see the ads are back.
If I close it and I tap the restore button it's going to restore the purchases that I've already made.
So when I tap restore and check it out if I go into Samman you'll see my purchases have been restored
just like that.
Super super cool.
Now of course we are using user defaults to store the hidden and shown status of the ad.
So if I go out and quit and come back in you'll notice the ads are still gone.
Super super cool.
So this is what we're going to build.
We have now properly set up our X code project with our assets.
We've also given it a name and we've paid attention to the special bundle identifier.
So let's go ahead and head over to the next video where we're going to dive into iTunes Connect the
place where we're going to create this on Apple's and their server and then link the two together.
Very very cool.
Let's go ahead and do it right now.