-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type(fix): fixes in-app-purchases-2 store.ready not getting fired #2043
Conversation
why nobody looks at this PR? |
Has this issue been addressed? |
nope, as you can see the PR is still open and no one bothers merging it! |
A promise should work fine. The Can you confirm that this works: import { InAppPurchase2 } from '@ionic-native/in-app-purchase2';
InAppPurchase2.getPlugin().ready(() => console.log('Callback called')); and this doesn't: import { InAppPurchase2 } from '@ionic-native/in-app-purchase2';
...
constructor(private iap: InAppPurchase2) {}
...
this.iap.ready()
.then(() => console.log('Ready resolved')); |
@ihadeed Nope, it doesn't work. I did try your sample and it doesn't work. That's why I opened this PR. Also unlike other ionic-native wrappers this one misses a check like |
@bshafiee If both of the code samples I provided don't work, then the issue is not from the wrapper. |
Make sure you're waiting for Example: import { InAppPurchase2 } from '@ionic-native/in-app-purchase2';
import { Platform } from 'ionic-framework';
class MyComponentOrService {
constructor(private iap: InAppPurchase2, private platform: Platform) {}
async someMethod() {
await this.platform.ready();
await this.iap.ready();
console.log('Ready resolved')
}
} |
|
|
|
`[Error] ERROR – Error: Uncaught (in promise): function (cb, altCb) {
return ret; |
Nice, didn't know there was an PR already. Just to link to the ionic forum discussion. If |
Looking at the code I guess I found out why Usually you add the So promisifying the function doesn't work in this way. Any idea how to encapsulate it correctly? |
@tobika passing extra parameters to a function doesn't hurt. If the original |
@ihadeed thanks for this clarification. When I try it with a promise I have the same error as @blueromans It's a pitty that people who try to use this plugin but don't know that they can change the typing of the lib won't be able to use it. Unfortunately I don't know how to fix the promis problem so maybe for the time being it would be better to accept this PR and change the documentation? |
Has anyone managed to get this working? I'm experiencing exactly the same issue as @blueromans . I'm unsure how to implement the code fix. |
@NodeKing as a workaround open the file Then you can use the Update: |
Thanks @tobika . I implemented the changes, but am still experiencing the same issue. I ended bypassing ionic native and just using cordova. It seems to be working but one thing I noticed is that the store.ready() method isn't fired until store.refresh() is called, so this could be my underlying issue. |
@ihadeed this is causing everyone trouble and I really don't understand why the PR is not getting merged. Sure, not the most elegant solution but it sure does work. Please either provide a proper fix or merge the PR. |
@tobika When I call this.iap.refresh(), either before or after this.iap.ready(), I get an error with code 6777001 and message "Init failed - String resource ID #0x0" |
@diegodem I think you should check in the repo of the plugin and create an issue there https://github.com/j3k0/cordova-plugin-purchase @ihadeed any news on if this PR will get merged or not? If you don't have the time maybe ask someone else or give merge permissions to someone else? or if there is a problem with the PR itself I'm sure we can think of another solution but we need some feedback to do this. |
@tobika I did create an issue already, but nobody answered |
@diegodem see the diff for the solution but this needs to be merged
otherwise it’ll be local mod. each time you install or update the npm.
On Tue, Feb 20, 2018 at 9:07 AM diegodem ***@***.***> wrote:
@bshafiee <https://github.com/bshafiee> What changes should I make to my
project in order for this to work? @tobika <https://github.com/tobika> 's
solution did not work for me, still the event ready is never getting fired.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2043 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEmYpVfYTJi9Kt3KygDb29sFCCytFZPVks5tWtGvgaJpZM4P50Z1>
.
--
Behrooz
|
@bshafiee I don't find the file src/@ionic-native/plugins/in-app-purchase-2/index.ts in my ionic project. Where should it be? |
it's in your installed modules (node_modules)
…On Tue, Feb 20, 2018 at 9:42 AM, diegodem ***@***.***> wrote:
@bshafiee <https://github.com/bshafiee> I don't find the file src/
/in-app-purchase-2/index.ts in my ionic project. Where should it be?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2043 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEmYpcifitzSoEtnGn10i79A8RKX1EPiks5tWtncgaJpZM4P50Z1>
.
--
Behrooz
|
From Tobika's comment above Then you can use the this.iap.ready(() => {}) function with a callback This just caused an error which building the app as I mentioned in the post just above. |
So you tried the callback method, that replaces the promise and no dice? I will try it too and let you know if I get the error. Did you try using the .getPlugin()? |
So I didn't get an error. It just doesn't work still. Same behavior as before. Update: So I wait until the platform is ready, call the configuration to set the handlers and the store ready is still never called with the changes @tobika suggested. Is there something else I am missing? |
This is using the .getPlugin() method? Does anyone know of any IAP modules for Angular 4 that do work? I really like Angular but frustrations like this make me consider switching. |
Oh to me it seemed like you did this.iap.ready after the index.d.ts change or InAppPurchase2.getPlugin().ready. |
Well for some reason nothing in here has worked for me. My store.ready never gets called and my handlers for the store just loop forever. I tired using the .getPlugin() and also modified the index.d.ts with the suggestions making it a callback instead of promise. @steve-allan If you switch to something that works or find a solution to this, please let me know if you remember :) |
For those of you still having issues, just install the ionic plugin package and don't make the ionic-native package changes as making them is only a temporary fix and will be overwritten every time you rebuild your node_modules. Better off waiting for the fix to be implemented. While your waiting, use the following work around. Only ran basic testing on ios that worked fine. Works perfectly on Android (using in production). Code below Install the plugin as normal via the ionic docs, then use the following code. ` export class IapService { // Type definition for anyone interested productArr: Array = []; constructor(public platform: Platform) { } initProducts() {
products['productId'] = {
} initStore() { updateProducts() { Note you will need a 'Restore Purchases' button feature on ios. Just call a store.refresh method followed by an updateProducts(). Android should restore purchases itself with the above code. |
Thank you NodeKing, |
@NodeKing Thanks for swinging by and providing help! What exactly is it you are doing? You are not using the InAppPurchase2 module? You are using your own store? Sorry for the noobish question. |
@aabdolla Still using the InAppPurchase2 module, just bypassing the problem ionic native code. You can use any cordova plugin directly, even if ionic doesn't provide it. You just need to implement it differently. I provided a full working example. You can use the whole lot, or just take what you need. |
@NodeKing Ah okay I see. Can my purchase code can still be the same using the store directly?
With how it is currently I am getting this error: Error Ordering {"line":441,"column":28,"sourceURL":"http://localhost:8080/var/containers/Bundle/Application/A66850AB-2460-4B28-BB0A-D46E6752D5A7/MyApp.app/www/plugins/cc.fovea.cordova.purchase/www/store-ios.js"} |
@NodeKing You are amazing! I am on to my next round of issues with purchasing in app purchases but this is no longer a hang up. Thank you so much! That bug above was an easy fix. You had "products.productId" and I just had to change it to "products[productId". What is the benefit of updateProducts()? Like keeping our own version of the products array? |
@aabdolla You're welcome. Apologies for the typo, I had to strip out most of my code to simplify for the example. RE: Products array: Yes, I just like storing the data in my own object to be accessed the same as the rest of my data. |
@NodeKing Oh okay cool. Yeah, it is working great for me. I just need to put the correct logic now in them. It's all new to me but at least I know the base of the purchasing is going to work. So is there a point to ever switching back to the plugin now that you enabled us to do it ourselves? |
My last hiccup now is my restore button. Using this code it looks like it never completes as the console log and alert at the end is never fired and I get this error: Error Ordering {"line":699,"column":96,"sourceURL":"http://localhost:8080/var/containers/Bundle/Application/49B5DA21-D504-46C3-90D4-DD550A1ACBFF/MyApp.app/www/build/main.js"}
Any thoughts @NodeKing? Sorry to ping you but you have been the man with the answers. |
@aabdolla I don't have any IOS apps, so I haven't got any working code I can share. I was playing around with IOS and had it working tho. I believe I just had a button click() event linked to a refresh() method. The button would only be show on IOS (not required on android). All the refresh method contained was store.refresh() from memory. You won't need to do anything anything with store.get() etc, as this should occur at startup/initialization in the above code. Maybe double check you have done everything correctly via the cordova documentation |
@NodeKing Oh okay, not necessary for Android, good to know. Thanks for checking it. I will double check the cordova documentation again. Thanks! |
On iOS for some reason during the purchase and refresh I get prompted multiple times to authenticate. During purchase, I have to put in my details three times. Same for restore. I am using the handlers above that @NodeKing provided. My purchase function looks like this:
@steve-allan Did you get around to implementing the recommendation? |
@danielsogl could you please merge this pull request? It's not nice to make this change every time because the current implementation is not working |
I'm receiving Update callback after product is registered saying Product is registered. But I'm not getting any response after store.order(productId). Just nothing happens. No error, nothing. Do you have any idea what could be the issue here? I tried the same async code block you have provided here. I would be very much grateful. I'm stuck at this since a week. Thanks in advance. |
Hi @NodeKing Thank you! |
@himalay-chauhan - did you get to the bottom of your problem? |
@CraigRBI yes, it's working fine for me now. Thank you for the response, little late though :D |
In my app it was working earlier but not working now. Has anybody found the solution for it? |
My all methods of store were not working. Uninstalling and re-installing app worked for me. |
1 similar comment
My all methods of store were not working. Uninstalling and re-installing app worked for me. |
Fixed the interface which should have been a callback not a promise (resulting in promise never gets resolved).