Giter Club home page Giter Club logo

iaphelper's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iaphelper's Issues

When restoreProductsWithCompletion fail to retrieve defaultQueue, callback won't be triggered

in IAPHelper.maround 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

Not support IPv6 Networks

Your app crashed on iPad running iOS 10.3.1 connected to an IPv6 network when we:

  1. Launch the application 2. Navigate to Purchase/Recharge tab 3. Proceed to purchase one of the IAP products

This occurred when your app was used:

  • On Wi-Fi

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.

Latest updates breaks cocoapods

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

Use of undeclared identifier productIdentifier

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.

tvOS works?

Hi
can you modify the cocoa pods to integrate in tvOS?
Thank you.

-requestProductsWithCompletion: block not called when request error (simulator only)

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.");
}

How to clear a purchased product from keychain?

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?

Is workflow correct?

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:

  1. Is it important to checkReceipt and provide content only after validation?
  2. What is the best way to fix issue when user is charged successfully for item but checkReceipt is failed due to internet connection error? In this case we should provide content.

transactionReceipt in iOS7

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

Getting crashed if user has retried for password for Apple id

Steps to regenerate :

  1. Try to restore the product.
  2. An pop up opens for your id and password.
  3. enter wrong password.
  4. Pop up opens for invalid username and password.
  5. enter right password.
  6. Getting crash with message

[IAPHelper respondsToSelector:]: message sent to deallocated instance 0x15847e40

transactionReceipt is deprecated

[[IAPShare sharedHelper].iap checkReceipt:trans.transactionReceipt AndSharedSecret:@"your sharesecret" onCompletion:^(NSString *response, NSError *error)

Need to removeTransactionObserver

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.

See also: http://stackoverflow.com/questions/4150926/in-app-purchase-crashes-on-skpaymentqueue-defaultqueue-addpaymentpayment

transactionReceipt

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

transcation -> transaction

typedef void (^IAPbuyProductCompleteResponseBlock)(SKPaymentTransaction* transcation);

to
typedef void (^IAPbuyProductCompleteResponseBlock)(SKPaymentTransaction* transaction);

How to handle checks for cancelled subscriptions

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

SKProductsResponse* returns 0 products....

image

That's a screenshot of my iTunesConnect inAppPurchase page.

[[IAPShare sharedHelper].iap requestProductsWithCompletion:^(SKProductsRequest* request,SKProductsResponse* response)
 {
     if (response > 0)
     {
         
         NSLog(@"%i", response.products.count);
         
     }
 }];

This always returns 0. It should return 2. Any ideas?

empty array on line 12

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

Add support for SKPaymentTransactionObserver method and Promotions

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

Production variable should have failsafe when app is live

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) {

iOS 10 compatible?

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.

Not getting errors when requesting products

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

IAPHelper restoreTransaction -> provideContent -> crash [__NSSetM addObject:]: object cannot be nil

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

fabric

Can't buy: Fail Cannot connect to iTunes Store. Transaction error: Cannot connect to iTunes Store 0 ?

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?

checkReceipt is insecure and vulnerable to middleman hack

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.

The version number have a problem?

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.

App Crash if Apple's Receipt Servers return nil

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)");
    }

}];

IAPHelper Not handling transactions at application launch?

@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?

Fix ver 1.0.8.1

Please fix this version to 1.0.9 or some thing, iTunes connect does not approve this type.

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.