SwiftUI 2.0: In-App Purchase - Getting Started From Scratch (2020)

แชร์
ฝัง
  • เผยแพร่เมื่อ 8 ต.ค. 2024
  • In this tutorial we are going to learn about Apple's StoreKit framework, which allows us to provide In-App Purchases to our apps.
    By the end of this tutorial you will implement a fully working SwiftUI App with In-App purchase capabilities. This demo app was inspired by a WWDC 2020 presentation, where a similar app was built.
    Get the Smoothie assets for our demo app here:
    bit.ly/2UFXGB4
    Part 2 is now available at:
    • SwiftUI 2.0: In-App Pu...

ความคิดเห็น • 70

  • @scottw2181
    @scottw2181 3 ปีที่แล้ว +11

    Absolutely epic video, this is what I've been searching for a long time. Using typealis for completion handlers is a great way to avoid mistakes, thanks for showing awesome clean code practices too. Crazy good. Can't wait for the follow up video as mentioned by some others. But a subscription companion video might be good, just showing the differences without having to repeat yourself for setting up the Store class which I used for subscriptions and it works perfect (which means you're a rock star). Thank you so much for what you do!

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Hi Scott, that’s awesome! Great to hear that you were successful with the tutorial. I also like your idea for the follow up video and will consider it. Thanks for your support!

  • @andrejkling3886
    @andrejkling3886 2 ปีที่แล้ว +1

    It’s will good if we can see your tutorials in close future… 👍 thank you. All the Best

  • @VicRoseOfficial
    @VicRoseOfficial 3 ปีที่แล้ว +3

    If you don't mind me asking, how did you learn how to do this? This is such complex code. It's impressive. I really appreciate you taking out the time to make these videos and teach us how to code.
    Could you please do a SwiftUI video on how to connect background lock screen controls for audio and make them Now Playable for audio that's streamable from a database in Firebase? Thank you.

  • @abdulwahabkhan4316
    @abdulwahabkhan4316 3 ปีที่แล้ว

    Quite long video but really worth it ... Not only cover In-App Purchase but also tell about clean code :) .... Thankx a lot for such a great content :)

  • @danno5645
    @danno5645 3 ปีที่แล้ว +1

    Great video! A follow up to show how to work with user defaults would be fantastic, so that the purchased content will be unlocked still after the app has been terminated and launched again.
    Thanks for making this video! I have been searching for months for a video showing how to do in-app purchase with SwiftUI. This has been super helpful!

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Thanks Danno! Glad it was helpful. A follow up video on storing the purchase state in user defaults is already planned and will be uploaded soon! :)

    • @danno5645
      @danno5645 3 ปีที่แล้ว

      @@BeyondOnesAndZeros Excellent!

  • @mdmamunurrasid4213
    @mdmamunurrasid4213 2 ปีที่แล้ว

    Really fantastic. Everything is become clear. Not a single second wastes. Thank you

  • @dsellis08
    @dsellis08 3 ปีที่แล้ว +9

    Is the source code of this posted anywhere? I'm having trouble getting it completely finished. I'm getting hanging in both the simulator and on a device. Unsure if I've just typo'd somewhere or if I have a deeper issue with my Xcode version or something. Would like to do a C&P of the code to check it compiles fine here.

  • @ediwatdahek
    @ediwatdahek 3 ปีที่แล้ว +2

    Great video, very helpful! I really like your clean style of programming.
    Can't wait for the video on subscriptions :)

  • @danno5645
    @danno5645 3 ปีที่แล้ว

    Hello again! I was just checking back to see if you are still planning on doing a follow up video showing how to store the purchase state in user defaults. I've been checking back on your channel each day to see if the video has been posted. I'm really excited for the follow up video!

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Almost done, will upload after editing. Thanks for your patience :)

    • @danno5645
      @danno5645 3 ปีที่แล้ว

      @@BeyondOnesAndZeros Awesome! I’m really excited, thanks again!

  • @nizz4m
    @nizz4m 3 ปีที่แล้ว +1

    Thank you for the great videos. Very details and precise. Keep it up a good work !

  • @dsellis08
    @dsellis08 3 ปีที่แล้ว +1

    This video is awesome! Hoping you do one for subscriptions to - like checking if they're still valid and stuff. I'm so close to having a releasable app but struggling to get it over the line with subscriptions!

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Thanks Dave, I will indeed extend this tutorial with subscription bases IAPs in the near future.

    • @ediwatdahek
      @ediwatdahek 3 ปีที่แล้ว

      @@BeyondOnesAndZeros is there an eta for the subscription video?

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      @@ediwatdahek Definitely before end of this month. Hopefully this weekend If I can find some time. Sorry for the delay :)

  • @shobhanksharma65
    @shobhanksharma65 3 ปีที่แล้ว

    Amazing video! How do I make sure that if a product is purchased on an iPhone and if the application is then installed on an iPad, the product still shows as purchased?

  • @romarioraff
    @romarioraff 3 ปีที่แล้ว

    Amazing video! Thank you! I configured App Store Connect with the products, however, the products are not showing up in App. Do you happen to know what the issue is?

  • @andrejkling3886
    @andrejkling3886 3 ปีที่แล้ว

    Keep going... your tutorials is awesome

  • @Savagechester
    @Savagechester 3 ปีที่แล้ว

    super tutorial. thanks a lot. I try to implement your Store class in my swift/storyboard project. How would you trigger the purchase of a recipe using your class from a UIButton?

  • @andrejkling3886
    @andrejkling3886 3 ปีที่แล้ว +1

    Excellent.... thanks a lot. KEEP GOING

  • @arman-arman
    @arman-arman 3 ปีที่แล้ว

    Thank you very much! Can you please upload somewhere

  • @Michael-lt5yn
    @Michael-lt5yn 3 ปีที่แล้ว +1

    Great tutorial! I'm working me through the end, but it didn't work in my app. Can you provide the code to find my error? That would be really nice!
    My Demo App ist compiling but after a few seconds a receive an "Thread 1: EXC_BAD_ACCESS (code=2, address=0x7ffedf61aff8)" error an can't find the problem. Comparing to your code would help me al lot :-)

  • @jackshephard7920
    @jackshephard7920 3 ปีที่แล้ว

    So concise and gold, thx!

  • @devhopes
    @devhopes 3 ปีที่แล้ว

    Great tutorial. Very informative and helpful.. Good Work! Thank You 😊👍🏻

  • @clementpignet
    @clementpignet 3 ปีที่แล้ว +2

    Hi ! Thank you for this awesome video ! When I close my app and reload it, it still get in unpaid version, did I miss something ? or should I save in userDefault that paid version had been purchased Or something like that ?

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Hi Clement, that is correct that is one way of keeping track of the purchase. In general you have to provide your users a "Restore Purchase" button (otherwise apple won't accept your app) so they can retrieve their purchases in case they got a new phone or etc. But you do not want to use the "Restore Purchase" button logic to reload the purchases every time the app starts, since this would lead to too many requests on the AppStore servers.
      As you mentioned userDefaults is one way however has the disadvantage that users with a jailbroken phone may be able to edit it. Apple however goes further and also provides you the capability to do Purchase Receipt Validation with your own server, but this would require you to set up a server and do some encryption and decryption.

    • @clementpignet
      @clementpignet 3 ปีที่แล้ว

      @@BeyondOnesAndZeros My app would not be used by power users... jailbreaked phone... but if they do, it's ok.... Can you help me where should I put my userDefault to store "Premium" to true. Is it in the switch case .purchased, .restored: ?

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      @@clementpignet Yes, that would be the location. You basically check if the "premium" is set to "true" and if not, you set it to "true" for both cases (.purchased, .restored). Also consider using the @AppStorage propertyWrapper for easier reading and writing. E.g., @AppStorage("premiumEnabled") var premiumEnabled: Bool = false

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว

      One more thing.. would love to see your app mentioned in the comments once it goes live on the AppStore. I think it would be quite inspiring for other viewers as well! :)

  • @ArtStudioTop
    @ArtStudioTop 3 ปีที่แล้ว

    Great job. Could you expand this topic about save purchase info in Core Data from your class Store?

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว

      Thanks, ArtStudio! I have a question regarding your request. What kind of purchase info are you intending to store in Core Data?

    • @ArtStudioTop
      @ArtStudioTop 3 ปีที่แล้ว

      @@BeyondOnesAndZeros I mean consumables. For example game coins.

  • @abdouett3676
    @abdouett3676 3 ปีที่แล้ว

    Thank you! Really nice way of programming.

  • @qsaluan
    @qsaluan 3 ปีที่แล้ว

    Great tutorial yet again! Thank you for your work on this. I did have one question however. In using your tutorial code on a real device when the user taps purchase it routes them to sign in with their apple ID and password even if they are already signed in. Is this behavior something to be expected with the sandbox environment and TestFlight? I have 5 or 6 users that downloaded the beta of my app on TestFlight and the same sign in issue occurred. Thanks for your help!

  • @littlechef3692
    @littlechef3692 ปีที่แล้ว

    great video . keep it up

  • @michaellatta
    @michaellatta 3 ปีที่แล้ว

    Thanks for the store kit part, but the swift UI partshould be using combine, not completion handlers

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Thanks Michael, appreciate your feedback. I encourage you to use Combine if you can however it can be quite confusing for people who have never worked with Combine before. The focus was on StoreKit and how you can use it in combination with SwiftUI. I think you can start out with the completion handler version and modify it with publishers and subscribers once you gain more experience with Combine. I may cover it in a separate video.

  • @batuhankrbb
    @batuhankrbb 3 ปีที่แล้ว

    Hello, can you leave the link of the project? I really need it because probably there is something I missed. I need to compare mine with yours.

  • @markme7092
    @markme7092 3 ปีที่แล้ว +2

    Please make video for add subscription

    • @BeyondOnesAndZeros
      @BeyondOnesAndZeros  3 ปีที่แล้ว +1

      Hi Mark, I tried to not overload this tutorial because there is a lot to cover. Will definitely cover subscription based purchases in a separate video.

    • @scottw2181
      @scottw2181 3 ปีที่แล้ว

      I followed this tutorial for subscriptions, monthly and annual, and it works just the same. The only difference I encountered was the UI logic for users.. show a screen to subscribe to option = if subscribed to option show main screen of app.. for example.. Try it out, that's how you learn best!

  • @azizbibitov6641
    @azizbibitov6641 2 ปีที่แล้ว

    Great Job Thanks !

  • @LDLefebvre
    @LDLefebvre 2 ปีที่แล้ว

    If I set up an online store where sellers put their own price, how do i set this up given that apple only has tier and doesn't allow to input a specific amount. Is there a way to do that?

  • @SerpkoBakotiinii
    @SerpkoBakotiinii 3 ปีที่แล้ว

    Are you download status of each bill on start or the app, or just store all purchases in the core Data? And what is the best approach for this?

  • @nat.serrano
    @nat.serrano 2 ปีที่แล้ว

    can we use environment object instead of stateobject?

  • @Chudchuececn
    @Chudchuececn 3 ปีที่แล้ว

    Thank you!

  • @DirkKunert
    @DirkKunert 3 ปีที่แล้ว

    Excellent!

  •  3 ปีที่แล้ว

    Done! 👏

  • @olegoleg1838
    @olegoleg1838 2 ปีที่แล้ว

    wtf, it is a simple feature, why is there so much code?????? you have the products and they are either bought or not, why all the drama wtf