saturngod / iaphelper Goto Github PK
View Code? Open in Web Editor NEWNo more maintenance for this repo. Please use the https://github.com/bizz84/SwiftyStoreKit
License: MIT License
No more maintenance for this repo. Please use the https://github.com/bizz84/SwiftyStoreKit
License: MIT License
Edit: Nevermind, issue on my end
in IAPHelper.m
around line 237
`
-(void)restoreProductsWithCompletion:(resoreProductsCompleteResponseBlock)completion {
//clear it
self.buyProductCompleteBlock = nil;
self.restoreCompletedBlock = completion;
if ([SKPaymentQueue defaultQueue]) {
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
else {
NSLog(@"Cannot get the default Queue");
}
}
`
In the else clause should trigger callback
Your app crashed on iPad running iOS 10.3.1 connected to an IPv6 network when we:
This occurred when your app was used:
We have attached detailed crash logs to help troubleshoot this issue.
Next Steps
To resolve this issue, please revise your app and test it on a device while connected to an IPv6 network (all apps must support IPv6) to ensure that it runs as expected.
Resources
For information on how to symbolicate and read a crash log, please review Tech Note TN2151 Understanding and Analyzing Application Crash Reports.
For information about supporting IPv6 Networks, please review Supporting IPv6 DNS64/NAT64 Networks and About Networking.
Installing IAPHelper (1.0.8.1)
[!] Error installing IAPHelper
[!] /usr/bin/git clone https://github.com/saturngod/IAPHelper.git /var/folders/w5/9ps2h02j1pbcq0g9l9vdzw0w0000gn/T/d20151116-2925-ehl70h --single-branch --depth 1 --branch 1.0.8.1
Cloning into '/var/folders/w5/9ps2h02j1pbcq0g9l9vdzw0w0000gn/T/d20151116-2925-ehl70h'...
warning: Could not find remote branch 1.0.8.1 to clone.
fatal: Remote branch 1.0.8.1 not found in upstream origin
Hello,
I have used your code to make in-app and i am getting an error here, [[IAPShare sharedHelper].iap provideContent:productIdentifier]; . it is saying me that use of undeclared identifier productIdentifier . how to solve it??
Thanks.
Hi
can you modify the cocoa pods to integrate in tvOS?
Thank you.
Is it okay if I just set it up?
[IAPShare sharedHelper].iap.production = YES;
The block of this method is not called on request error.
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
// never called
}];
Looks like this happens in simulator only. May be we should add the SKRequest delegate method to print a log message that this won't work on simulator instead of going silent.
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
NSLog(@"Warning: the completion block of -requestProductsWithCompletion method won't be called in iOS simulator. Please test on device.");
}
When in development, we are making sure to test what happens when we purchase a product. But, since that is saved in the keychain as purchased, how can we clear that out, so we can test it again?
[IAPShare sharedHelper].iap.production 当上线的提交审核的时候,这个BOOL 的属性设置成YES 和No 有什么区别
Hi @saturngod
I have questions about your workflow to perform purchase and provide content of it.
Please find comments in code below.
if(![IAPShare sharedHelper].iap) {
NSSet* dataSet = [[NSSet alloc] initWithObjects:@"com.comquas.iap.test", nil];
[IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet];
}
[IAPShare sharedHelper].iap.production = NO;
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
if(response > 0 ) {
SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
[[IAPShare sharedHelper].iap buyProduct:product
onCompletion:^(SKPaymentTransaction* trans){
if(trans.error)
{
NSLog(@"Fail %@",[trans.error localizedDescription]);
}
else if(trans.transactionState == SKPaymentTransactionStatePurchased) {
// @moleksyuk: According to Apple API SKPaymentTransactionStatePurchased means that transaction is in queue, user has been charged. Client should complete the transaction.
// And this doc says: https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html#//apple_ref/doc/uid/TP40008267-CH5-SW3
// Transaction statuses and corresponding actions
// SKPaymentTransactionStatePurchased -> Provide the purchased functionality.
// BUT in this place isPurchased will be NO.
BOOL isPurchased = [[IAPShare sharedHelper].iap isPurchasedProductsIdentifier:kInAppPurchaseRemoveAdsProductId];
// @moleksyuk: And if in this place internet connection will fail before we check receipt user won't get purchased item but will be charged.
[[IAPShare sharedHelper].iap checkReceipt:trans.transactionReceipt AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {
//Convert JSON String to NSDictionary
NSDictionary* rec = [IAPShare toJSON:response];
if([rec[@"status"] integerValue]==0)
{
NSString *productIdentifier = trans.payment.productIdentifier;
[[IAPShare sharedHelper].iap provideContent:productIdentifier];
// @moleksyuk: Only here we will get isPurchased = YES. Right after provideContent is called.
BOOL isPurchased = [[IAPShare sharedHelper].iap isPurchasedProductsIdentifier:kInAppPurchaseRemoveAdsProductId];
NSLog(@"SUCCESS %@",response);
NSLog(@"Pruchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
}
else {
NSLog(@"Fail");
}
}];
}
else if(trans.transactionState == SKPaymentTransactionStateFailed) {
NSLog(@"Fail");
}
}];//end of buy product
}
}];
Question:
s.dependency 'SFHFKeychainUtils'
Hello,
I use your contribution and it works perfect, but in a new app i created only in iOS7, appears "transactionreceipt" deprecated.
How can correct it ? Only need to change with this ?
NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
Thanks
First of all, thanks for this little gem, its working great
One thing I found is that the delegate method is not called after asking requestProductsWithCompletion with the device flight mode on.
This causes the completion block not to be executed
Steps to regenerate :
[IAPHelper respondsToSelector:]: message sent to deallocated instance 0x15847e40
[[IAPShare sharedHelper].iap checkReceipt:trans.transactionReceipt AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error)
I was having a problem where I would occasionally get the following error while trying to restore products. (only if NSZombieEnabled)
[IAPHelper respondsToSelector:]: message sent to deallocated instance 0x17668730
I found that I had to add this somewhere in the IAPHelper.m code:
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
I chose to put it in a dealloc method, though there might be better places for this. It did fix my problem though.
When using this code:-
[[IAPShare sharedHelper].iap checkReceipt:trans.transactionReceipt AndSharedSecret:@"SECRET" onCompletion:^(NSString *response, NSError *error)
show as 'transactionReceipt' is deprecated: first deprecated in iOS 7.0
Please edit your .podspec file and add .m file into s.source_files!
You could change to "s.source_files = 'IAPHelper/*.{h,m}'"
typedef void (^IAPbuyProductCompleteResponseBlock)(SKPaymentTransaction* transcation);
to
typedef void (^IAPbuyProductCompleteResponseBlock)(SKPaymentTransaction* transaction);
Hi,
First of all, let me thank you for the great work. I'm a very happy adopter of your library since almost 2 years now ;)
I would like to implement a simple mechanism to properly handle cancelled subscriptions.
In other words, if a user disables the auto-renewal of the subscription, I would like to be aware of it and thus deactivate the corresponding in-app purchase(s) when the subscription expires.
What's the best way do it?
Will this be enough? Will this automatically clear subscriptions that are no longer active?
[[IAPShare sharedHelper].iap restoreProductsWithCompletion:^(SKPaymentQueue *payment, NSError *error) { if (error) { // error: do your stuff } else { // do your stuff } }];
Or should I clear in-app purchases before doing that?
[[IAPShare sharedHelper].iap clearSavedPurchasedProducts];
Thanks
Hey,
when take the example code, change the product ID and run the code, I get the error
"[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array" on the line of the declaration of product.
Why?
Many thanks in advance
Rename
resoreProductsCompleteResponseBlock
to
restoreProductsCompleteResponseBlock
iOS11 support?
If so, how can I handle subscriptions in my app?
Thanks
Hi,
I've recently tried to promote my in-app purchases by using the new features available on iOS 11.
However I haven't managed to do that because my app doesn't support the SKPaymentTransactionObserver method https://developer.apple.com/documentation/storekit/skpaymenttransactionobserver/2877502-paymentqueue
Here there are more information about promotions https://developer.apple.com/app-store/promoting-in-app-purchases/
Do you think you can add this feature?
Thanks
Can i force a non arc compiler flag on the helper class? Will it work with a non arc project then?
As it currently stands, if a dev forgets to set the production boolean to YES upon submitting for the AppStore issues can incur with receipt validation. (app will use Apple's sandbox verification server URL instead of their production verification server URL)
IAPHelper should utilize CLANG macros as a failsafe to automatically force that variable to YES if app is in release mode not debug mode.
#ifdef DEBUG
#define releaseBuild NO
#else
#define releaseBuild YES
#endif
Then in IAPHelper.m:
if (_production) {
Should now read:
if (_production || releaseBuild) {
Is this library compatible with iOS 10? Has it been tested with iOS 10? It looks like it has been updated within the past 6 months but there is no mention of recent iOS versions, unfortunately, so I can't tell. Thanks.
Hi,
I just noticed when -requestProductsWithCompletion:
doesn't report errors happening in the request. Adding a NSError *
parameter to the block type and the following method to IAPHelper.m
seems to fix the issue for me :
- (void)request:(SKRequest *)request didFailWithError:(NSError *)error
{
self.request = nil;
if(_requestProductsBlock) {
_requestProductsBlock (request,nil, error);
}
}
Do you confirm it is the right approach and if so would it be possible to add it to a future release ?
Thanks a lot for considering,
Stan
Hi,
a few iOS 9 users of my app are experiencing a crash when they try to purchase one or more items. Apple and I extensively tested IAPs and we never encountered such an issue.
From what I can see in the stacktrace, looks like the restoreTransaction function is internally trying to register a 'nil' product identifier. The stacktrace is attached below.
Did anyone encounter this problem before ?
Thanks
2014-06-11 14:29:11.897 app[14096:60b] Transaction error: Cannot connect to iTunes Store 0
2014-06-11 14:29:11.898 app[14096:60b] Fail Cannot connect to iTunes Store
In viewDidLoad:
if(![IAPShare sharedHelper].iap) {
NSSet* dataSet = [[NSSet alloc] initWithObjects:SUB_PRODUCT_REMOVEAD,SUB_PRODUCT_BUY200, nil];
[IAPShare sharedHelper].iap = [[IAPHelper alloc] initWithProductIdentifiers:dataSet];
}
[IAPShare sharedHelper].iap.production = NO;
Buy:
//IAP
- (IBAction)pressBuy:(id)sender{
[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
{
if(response > 0 ) {
SKProduct* product =[[IAPShare sharedHelper].iap.products objectAtIndex:0];
[[IAPShare sharedHelper].iap buyProduct:product
onCompletion:^(SKPaymentTransaction* trans){
if(trans.error)
{
NSLog(@"Fail %@",[trans.error localizedDescription]);
}
else if(trans.transactionState == SKPaymentTransactionStatePurchased) {
[[IAPShare sharedHelper].iap checkReceipt:trans.transactionReceipt AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {
//Convert JSON String to NSDictionary
NSDictionary* rec = [IAPShare toJSON:response];
if([rec[@"status"] integerValue]==0)
{
NSString *productIdentifier = trans.payment.productIdentifier;
[[IAPShare sharedHelper].iap provideContent:productIdentifier];
NSLog(@"SUCCESS %@",response);
NSLog(@"Pruchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
}
else {
NSLog(@"Fail");
}
}];
}
else if(trans.transactionState == SKPaymentTransactionStateFailed) {
NSLog(@"Fail");
}
}];//end of buy product
}
}];
}
Why can't buy when I press buy button? Is there any IAPHelp project example to download?
I've just been browsing this repo to see if it's usable, but I'm pretty sure I spotted a vulnerability:
The checkReceipt:
method is using the logic from this Apple guide which states that this logic is meant for communication between your app's server and Apple's servers. You should not use this logic for communication between a user's device and Apple's servers, because as the docs state:
It is not possible to build a trusted connection between a user’s device and the App Store directly because you don’t control either end of that connection.
This repo still maintaining updates?
getting shared instance from IAPShare
is not thread safe.
As we all know the version number must look like this 1.2.3
,
if the version number looks like 1.2.3.4
, when i archive my project.
the Xcode will report a problem.
so I suggest to change the version number.
When validating receipt, Apple's response
can be nil, which causes the app to crash when it tries to convert nil to JSON via NSDictionary* rec = [IAPShare toJSON:response];
I propose a modification simply in the read-me doc's example code, to now be as follows:
[[IAPShare sharedHelper].iap checkReceipt:[NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]] AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error) {
if (response)
{
//Convert JSON String to NSDictionary
NSDictionary* rec = [IAPShare toJSON:response];
if([rec[@"status"] integerValue]==0)
{
[[IAPShare sharedHelper].iap provideContentWithTransaction:trans];
NSLog(@"SUCCESS %@",response);
NSLog(@"Purchases %@",[IAPShare sharedHelper].iap.purchasedProducts);
}
else {
NSLog(@"Fail");
}
}
else {
NSLog(@"Fail (Apple server malfunction or connection interruption)");
}
}];
@saturngod
From the Apple's document In-App Purchase Best Practices
https://developer.apple.com/library/ios/technotes/tn2387/_index.html
Transaction observer SHOULD be added to SKPaymentQueue at application launch, the reason is that some transaction may be still in purchasing status when user closes the app.
But IAPHelper doesn't initialise it self at launch. Moreover buyProductCompleteBlock in IAPHelper isn't initialised until buyProduct:onCompletion: or restoreProductsWithCompletion: is invoked. So the updatedTransactions will be lost before any purchase or restore if user relaunches the app.
Am i correct?
Please fix this version to 1.0.9 or some thing, iTunes connect does not approve this type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.