In app purchases in React Native (Android)

แชร์
ฝัง
  • เผยแพร่เมื่อ 1 ส.ค. 2024
  • In this video I'll show how to get up and running with in app purchases (subscriptions) in React Native for android.
    Good news is that you can use the simulator as long as the Google Play store is installed the emulator and you're logged into your google account.
    Important note: In android you can have multiple subscriptions running at the same time, it doesn't just change the subscription like in iOS which is really neat so make sure you've the logic in place to handle that!
    Libraries used:
    googleapis
    react-native-iap
    The steps showed in the video:
    Pre steps:
    - Sign up for the Google Developer program
    - Submit a release, upload apb and get it approved
    - Create service account in Google Developer Console
    - Add owner rights to the service account and link it in the Google Play Console
    - Add subscriptions in the Google Play console and activate them
    In the app:
    - getSubscriptions()
    - requestSubscription(productId)
    - purchaseUpdatedListener
    - Save Receipt in backend
    - finishTransaction()
    Backend:
    - Backend code, receipt validation, (productId, receiptToken), check for paymentState === 1

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

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

    Very good guide! Thanks from Brazil!

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

    Thanks for the explanation. Very useful.

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

    Great guide.
    BTW You can force any Google page to use English by adding a query parameter hl=en on the URL

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

    On making a new build do I have to upload the apb of new build and get it approved again for the purchase to work?

  • @nilampednekar9256
    @nilampednekar9256 7 หลายเดือนก่อน

    How I can manage multiple user on single play store I'd or on apple id on one device?

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

    How to downgrade and upgrade subscriptions? The documentation is so limited. Cant find how to do it.

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

    If we have Android, iOS and Web version of app and if i purchase subscription in iOS using in all, will it work in web and mobile version.

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

    In the Pre steps, i.e submit a release, upload apb and get it approved step,
    Should I upload the apb version of the app without integrating payment system in the react native app?

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

      Dont need to upload a version with the payment system in place :) its up to you

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

    Hello bro, i have two questions
    1:- did i need to publish my app before integrating react native iap in the app
    2:- Can i test the app in dev mode because as far as i know only the release build can be uploaded for testing and in release mode react native debugger does not work

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

      You need to upload at least one build to Google play, you can test the app with simulator OR device with Android (be sure youre logged in with your Google account)

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

    Hi how can i handle the subscription cancel and resubscribe from the google play store in the app. because I need to update the database if the state of the subscription changes.

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

      Rashi Jain if you verify the receipt every time the user opens the app, you will know the currrent status of the subscription and you can update your database accordingly 🙂

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

    Hi . Can you help me ? When I test the subscriptions ,I got error "the item you were attempting to purchase could not be found". It's works perfect if i installed from GG play .

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

      Lawson Nguyen I’ve not had that error before so Im afraid that i cant help with this one

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

      @@jonasgroendahl add test gmail account in google pay store.

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

    Please can you send link to github repo

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

    Hello there, thank you for the tutorial.
    I have a problem when accessing the android.test.purchased by hitting the requestPurchase(), it shows the requested item is not found. I tested this APK in Alpha but none success. Do you have a similar problem?

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

      Oda Nicola it sounds like you’re testing the ones in the example. You should create your own products for your own appId after doing the initial setup steps

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

      @@jonasgroendahl Oh yeah, i don't even try any of your examples, this is my own app. What should i do? I created a new product too but it won't be retrieved. Should i have a service like the video says for the products? My app isn't game category.

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

      Oda Nicola was your app approved? Might need to wait for that :)

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

      @@jonasgroendahl oh yeah, now it is working fine. I need to publish and wait for the approval. Thank you for your reply.

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

      Oda Nicola perfect, usually it takes 1 Day :)

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

    does Iap.purchaseUpdatedListener works for subscriptions?, or jus for iap consumables?

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

    Hi for me android crashes before launching the app. did u face any similar issues ?

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

      Abid pp No, try remove code bit by bit to figure out what it’s crashing it - old trick 😄

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

      @@jonasgroendahl Can u tell me which version of react-naive , react-native-iap you used in your code.?

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

      @@abidpp51 "react-native-iap": "^4.4.9", "react-native": "0.62.2" :)

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

    Can you please tell me that how to unsubscribe in react native using in app purchases.

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

      swati shree you need to link to the Google play store sub page to cancel subscriptions

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

      @@jonasgroendahl can i redirect to my app after cancel the subscription using that sub page?

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

    Is the code on github somewhere?

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

      I'm afraid not, I took stuff from a product I was working on :)

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

    Can you provide the code on GitHub