Skip to content
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

Fix for prompt appearing on app start #338

Closed
wants to merge 1 commit into from

Conversation

d3orn
Copy link

@d3orn d3orn commented Nov 11, 2015

This fix solves the problem of the reappearing sign in prompt on app start which was cause by transactions being stuck in a unfinished state and therefore the observer always tried to finish does transactions.
This is probably not the nicest fix but it works and has been tested with 3 different apps.
If you have a better way of fixing this go ahead but at least with this pull request the plugin can be used without the annoying prompts

@j3k0
Copy link
Owner

j3k0 commented Nov 12, 2015

Hello,

This will break apps that provide downloadable content. For those apps, finish should only be called when the content has been provided (if download fails, app should retry at every restart).

Actually this is also true for any kind purchase, if the user closes the app (or get called) between the purchase and the moment your app is done unlocking the feature... He may have paid but didn't get what he paid for.

If you have unfinished transaction stuck in the queue, it's most probably because you didn't finish them properly (after the feature has been delivered): see https://github.com/j3k0/cordova-plugin-purchase/blob/master/doc/api.md#finish-a-purchase

@d3orn
Copy link
Author

d3orn commented Nov 12, 2015

Ok, I see but could you have a look at #334. The gist from him is what I am doing in my app currently (more or less) and we (3 people) all had the same problem. Maybe another example with the structure @anonrig is using would be nice because this is how a lot of people actually us your plugin!
Keep up your work, awesome plugin I hope I can us it soon

@anonrig
Copy link

anonrig commented Nov 13, 2015

@j3k0 you can see an example from my gist https://gist.github.com/anonrig/cfdf88ad3a1d2f7d3b46

in such case, even though the transaction is completed, it prompts for username&password

@LukePulverenti
Copy link

@j3k0 since you do not consider this best practice, is there an alternative that you can suggest to resolve this? My users are also reporting repeated password prompts on app starts, and I believe I've followed your samples almost exactly. Thanks.

@saniyusuf
Copy link

are you saying we stay away from this fix @anonrig @j3k0

@LukePulverenti
Copy link

Has anyone tested this with a subscription? Could this result in receipt validation being bypassed?

@bwalsh
Copy link

bwalsh commented Dec 4, 2015

Any progress on this? Does it only affect testflight users? Will it affect production users?

Cordova CLI: 5.4.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.1.1
Ionic CLI Version: 1.7.10
Ionic App Lib Version: 0.6.5

@anonrig
Copy link

anonrig commented Dec 10, 2015

I've tested it with subscription. And this solution works well. But don't quite tested the case that @j3k0 told. @LukePulverenti

@LukePulverenti
Copy link

Thanks for reporting your results. I too have implemented it in my app until the developer provides an alternative solution.

I do still see repeated password prompts, but only in the situation of attempting to restoring a purchase after disabling the app store on the device (e.g., parental controls). Aside from this scenario it seems to be working well.

See here about that:

#356

@NGumby
Copy link

NGumby commented Dec 14, 2015

@j3k0 I think I might have found the reason why the purchase is never finished. After my purchase, when I get to this code :

    if(downloads){
        [[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
    }
    else if (g_autoFinishEnabled && canFinish) {
        [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
        [self transactionFinished:transaction];
    }
    else {
        [unfinishedTransactions setObject:transaction forKey:transactionIdentifier];
    }

downloads is not nil, but it's an array of 0 objects. So unfinishedTransactions is never set. When you call product.finish(), you get this log :

InAppPurchase[objc]: Cannot finish transaction 

So the correct fix seems to be this :

    if(downloads && [downloads count] > 0){
        [[SKPaymentQueue defaultQueue] startDownloads:transaction.downloads];
    } else ...

Let me know if this works for anybody else!

@j3k0
Copy link
Owner

j3k0 commented Dec 15, 2015

@NGumby this fix was already in master. I published a new version of the plugin that includes it (4.1.0)

@LukePulverenti
Copy link

Fyi - I do have a report from a user who shows that their subscription completed in iTunes but that they did not actually get what they paid for. Since I am currently unsure of the issue I suspect that the guidance from @j3k0 came true in this case.

Still @j3k0, you've been very quiet on this issue and there are a number of us reporting it. It would be great if you could help us hunt down a solution. Thanks.

@j3k0
Copy link
Owner

j3k0 commented Dec 19, 2015

Hi, I haven't been working on a Cordova app with in-app purchase since iOS 9, so I didn't really have the opportunity to look deeper into that yet... and do not know much about why this happens.

The attempted fix in this PR seems to indicate that there are some unfinished purchase in the StoreKit queue that causes the prompt to appear. If someone can track down "why?" then we may have some cleaner solution to the issue.

Volunteers?

@j3k0 j3k0 added the invalid label Dec 19, 2015
@LukePulverenti
Copy link

Has anyone reproduced on iOS8? Are we sure it's iOS9-specific?

@j3k0
Copy link
Owner

j3k0 commented Dec 19, 2015

I didn't heard of anyone having this issue before iOS 9, so it most probably is specific.

@bwalsh
Copy link

bwalsh commented Dec 19, 2015

This started with os9, didn't happen before, does not happen on Android
On Dec 19, 2015 10:46 AM, "Jean-Christophe Hoelt" notifications@github.com
wrote:

I didn't heard of anyone having this issue before iOS 9, so it most
probably is specific.


Reply to this email directly or view it on GitHub
#338 (comment)
.

@mralj
Copy link

mralj commented Jun 9, 2016

Hey, are there any updates on this issue :) ?

@VanVan
Copy link

VanVan commented Jun 29, 2016

Same issue with finished subscription on iOS 9.
App prompt User for password at app startup

@j3k0 j3k0 closed this Dec 16, 2016
@saniyusuf
Copy link

Why was this issue closed? @j3k0 Has there been a definitive fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants