Giter Club home page Giter Club logo

Comments (14)

JJMoon avatar JJMoon commented on June 26, 2024 2

@KjellConnelly
Sorry for delay. I will implement that method soon. Happy new year.. !!

from react-native-iap.

JJMoon avatar JJMoon commented on June 26, 2024

We wil update soon. Maybe before 2018.

from react-native-iap.

KjellConnelly avatar KjellConnelly commented on June 26, 2024

@JJMoon @dooboolab
Btw how do we restore purchases on Android? I know Google Play allows you to query for non consumable purchases, but then that leaves me with a few questions:

  1. Is the idea to query for IAPs when the app loads, and restore functionality on each app load (saving locally of course so the app can work offline as well)?
  2. Which function should I use? I see:
    refreshPurchaseItemsAndroid() getPurchasedItemsAndroid()
    Maybe an example is in order for the readme?
  3. Do these only work for Google Play? How about Amazon/others?

from react-native-iap.

hyochan avatar hyochan commented on June 26, 2024

@KjellConnelly
Answering you questions~

  1. You need to query for IAPs at first. When you want to query items offline and you are sure that lists of items won't change~ you can save them in LocalStorage.
  2. Sorry for that. As we told in head of this repo, we are interested in making IAP the same behavior between IOS and ANDOIRD platform. Therefore we missed out that tutorial officially. getPurchasedItemsAndroid() is a method to get a list of items you purchased in your app. refreshPurchaseItemsAndroid() is a method to refresh that item so you can buy the same item again.
  3. We've only tested on Google Play. We've not tested on Amazon/others yet.

Hope my answer helps you.

Thank you.

from react-native-iap.

KjellConnelly avatar KjellConnelly commented on June 26, 2024

@dooboolab Thanks for the reply :) Could you help me understand a bit better how the process works for Android? I am coming from an iOS background, so I will use iOS terms to try to make sense of this.

Imagine the situation where I have two IAPs

  1. Premium Version ($3.99), non-consumable.
  2. 100 Coins ($0.99), consumable.

In iOS, I would first query for the product IDs, then call the buy function. This returns Promise once the buy function has completed (success or failure).

On iOS, I would do something with LocalStorage such as setting a saved object:

if (item.productId == 'com.website.100coins') {
    savedData = {
        coins: savedData.coins + 100,
        premium: savedData.premium
    }
} else if (item.productId == 'com.website.premium') {
    savedData = {
        coins: savedData.coins,
        premium: true
    }
}

And then I would have a Restore button, and when you tap it, the Restore function is called, which returns the non-consumable purchases that the user has made in the past using that iTunes account.


For Android, it looks like I query for the productIds just as on iOS. And when the purchase happens, I also save to LocalStorage. But if I remember correctly, I need to then tell Google Play that the consumable has been consumed (for the coins, and once I save to local storage).

But when it comes to the Restore Button, I'm a bit confused.

By your description, it looks like those two functions do the following:

getPurchasedItemsAndroid(): This will return probably an array of IAPs that this user has purchased using your app. This will include all consumable, and non-consumable purchases. In my case, where I have Coins and a Premium Version, I would just iterate through this array to check to see if the user has bought the Premium Version before when they tap the Restore Button, right? And if its there, then I just set savedData.premium = true?

refreshPurchasedItemsAndroid() I don't really understand what refreshing does in this case. Does it tell Google Play that all of the previously consumed purchases are still purchased, but not consumed anymore? Or does it refresh the app's list of purchased items from Google Play's servers in which case would mean that the user's device is saving some sort of data on its own when a purchase is made?

Finally, it seems like on iOS, you are required to have a Restore Button for non-consumables. But for Google Play, you CAN have a Restore button for non-consumables, but it would be best practice to just check using getPurchasedItemsAndroid every time the app is launched (if the user's local data is saying that they haven't purchased the premium version yet).

Sorry for the long essay. Just having trouble making sense of the IAP process on Android.

from react-native-iap.

hyochan avatar hyochan commented on June 26, 2024

@KjellConnelly

Sorry that I've missed this. I've not implemented Sku.Type option to get consumable products in android since this was our above our topic as explained. Before you could only getPurchasedItems lists for non-consumable products only. I just fixed this to support for querying both consumable and non-consumable products.
--------------------------- screenshots below -----------------------------------

  1. In index.js
    screen1
  2. in RNIapModule.java
    screen2

--------------------------- screenshots done -----------------------------------

Also for refreshPurchasedItemsAndroid method, I've updated support for conusmable products. Screenshots are below

--------------------------- screenshots below -----------------------------------

  1. In index.js
    screen1
  2. in RNIapModule.java
    screen2

--------------------------- screenshots done -----------------------------------

I've just commited this update. Hope this helps your question.

Now you can call getPurchasedItemsAndroid(type: string) function to get non-consumable items or consumable items. If you want non-consumable items just put null or any string. If you want consumable items put 'SUBS' in it.

You can use refreshPurchasedItemsAndroid(type: string) function same as described above.

from react-native-iap.

KjellConnelly avatar KjellConnelly commented on June 26, 2024

@dooboolab

Iā€™m a bit confused now - I thought .SUBS was for subscriptions (which is different than consumables and non-consumables)

from react-native-iap.

hyochan avatar hyochan commented on June 26, 2024

@KjellConnelly

Yes! It was about items for subscriptions. OMG... I was confused too. Thanks again to point that out. Sorry that I was confused by busy work ..

It seems we've been missing some support for this senario. We didn't actually distinguish between consumable and non-consumable product in our library. Since you need this part, we will support for this near future. Thanks for sharing.

from react-native-iap.

KjellConnelly avatar KjellConnelly commented on June 26, 2024

@dooboolab If you have time, could you add Restore Purchase support for iOS? Will be needing it soon and was hoping this feature to be implemented by 2018. Thanks!

from react-native-iap.

JJMoon avatar JJMoon commented on June 26, 2024

Restore function Implemented. NPM module will be updated soon. If you need it right now, just use it from GitHub. Version is 0.1.16. It was merged to master, so you can use it right away.
Closing this issue. Thank you for waiting..

from react-native-iap.

KjellConnelly avatar KjellConnelly commented on June 26, 2024

Thank you!! I really appreciate it :)

from react-native-iap.

hyochan avatar hyochan commented on June 26, 2024

@KjellConnelly
Checkout later version of @0.2.2 for update.
Thank you!

from react-native-iap.

ivan133 avatar ivan133 commented on June 26, 2024

But how to use it?

from react-native-iap.

ivan133 avatar ivan133 commented on June 26, 2024

I wanted to create a new issue, but since the SUBJ I'll just post it here (Restore Purchase on iOS)
I'm not sure how to restore the subscription on ios?
As far I need to press a button (like restore subscription) but do I need to call any RNIap functions?
Or should I just save the purchase to local storage and restore it?

from react-native-iap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.