Code Monkey home page Code Monkey logo

swiftystorekit's Issues

How can i know if a user extends Auto Renewal subscription from Settings or PC

When a user subscribe I store the expiration date on Firebase but also on NSUserDefaults but How can i know if a user extends Auto Renewal subscription from Settings or PC.

Check here: https://support.apple.com/en-us/HT202039

P.S Should the Auto Renewal subscriptions autorenew itself? After a product expire i verify the receipt and the date does not change, it should be extended for example +1month.

.
.
I'm also having issue sometimes when i click the purchase button it takes too long or sometimes never to popup the dialog to buy. I should close the app and then the popup comes up. I call completeIAPTransactions on didFinishLaunchingWithOptions

Transaction Id of purchase?

I'm migrating my app to swift from obj-c and found this really nice library. We use google analytics to track purchases and currently pass in the transaction id. For the nice swift callbacks the only thing available is the product id and the transaction observer closure only seems to be called when there isn't an active purchase.

Would it make sense to just always call that closure? Or alternatively pass the transaction details back with the purchase success?

Rename targets and schemes

Following the addition of OSX (now macOS) and tvOS compatibility, it seems to appropriate to rename the targets and schemes as follows:

  • SwiftyStoreKit -> SwiftyStoreKitIOS
  • SwiftyStoreKitOSX -> SwiftyStoreKitMacOS
  • SwiftyStoreKitTV -> SwiftyStoreKitTvOS

This should not be a code breaking change for clients as the module would be imported as import SwiftyStoreKit as before.

The folder structure could also be updated:

  • Introduce SwiftyStoreKitIOS folder to include SwiftyStoreKitIOS.h and Info.plist files.
  • Rename SwiftyStoreKitOSX folder to SwiftyStoreKitMacOS
  • Rename SwiftyStoreKitTV folder to SwiftyStoreKitTvOS
  • Rename SwiftyStoreDemo folder to SwiftyStoreKitDemoIOS
  • Rename SwiftyStoreOSXDemo folder to SwiftyStoreKitDemoMacOS

The above should bring more consistency to the naming conventions in SwiftyStoreKit. Feedback is appreciated about this proposal.

No callback when the a subscription is already purchased

If user is already subscribed to a subscription and he tries to subscribe again to this subscription - the completion handler never gets executed:

        SwiftyStoreKit.purchaseProduct(subscriptionSKU) { result in
              // this never gets executed 
        }

In order to reproduce:

  1. subscribe to a renewable subscription
  2. after subscribing successfully - execute the purchaseProduct method again
    this window will eventually will show up:
    img_8116

and then nothing happens...

Bug after merging pull request #24?

Hi,

everytime after someone has purchased an item, the app asks for the App Store password when you send it to background and bring it back again.

Cheers, Jan

SKPaymentTransactionObserver updatedTransactions called multiple times

I briefly read some of the other threads and it seems like there might be an issue everyone is running into. The InAppProductPurchaseRequest class is being deinitialized after updatedTransactions is called for other transactions. This results in the completion block being called "early" for the purchase, and causes the completion to not be called when the user actually purchases something again.

Change Restore to return all products ids at once

Could it be possible to change the Restore method to return all productIds at once?

Sometimes one needs some heavy computation after the restores, but like it is right now, it is not possible to know which callback is the last.

How to getInfo in an orderly fashion?

So I have 1, 3, and 6 months subscription option. I am using the getInfo func in the demo with the products appended into an array. As of now the order in which the products appear are random, how do I control this so that it will load 1, 3, 6 months accordingly?

Synchronously load receipt without verification.

Right now the only way to read receipt data is by calling verifyReceipt, and getting access to the ReceiptInfo in the VerifyReceiptResult.

The issue is that this always make a network call out to Apple, just to read receipt data in a format that I can pass into verifyPurchase. This makes it impossible provide an offline-enabled app with this framework alone. I'm happy to verify the receipt with apple using this technique immediately after purchase, but there is no reason to do it every time the app is launched.

Is it possible to provide an accessor to the current ReceiptInfo data?

Purchase Failed: Failed "Cannot connect to iTunes Store" changed from .Test to .Production

I changed yesterday from .Test to .Production but today i changed back to .Test and In-App purchases does not work i get this:

Purchase Failed: Failed(Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store})

Can anyone help me what should i do?

Update:

I was able to test with my regular apple ID until 6 days ago.

After that i created a sandbox user and everything seems to work again.

Question: completeTransactions asks for login with fresh install

Hi, I'd like to know if I have to call in some special way to "completeTransactions" as it's asking the user to login when the app is freshly installed. It says something similar to what would be translted to English like:
"It is necessary to login. Tap on continue and login in order to look for downloads"

Is there any mechanism for this?
Can this be avoided in order not to ask the login?
Is this because of auto-renewal subscriptions (and same questions above apply).

Thank you, keep going for Swift 3 soon and let this framework grow :D

iOS Demo app

Why is it giving me the alert: return alertWithTitle("Purchase failed", message: "Please check your Internet connection or try again later")

When I hit cancel instead of buying?

auto renewable subscription status on app launch

Is there a way to request the status of subscription on app launch without asking for the user credentials?

If not, is there at least a way to get the notification, when the subscription is being renewed?

Thanks

Best practice to store the Shared Secret

I wondering where to store the Shared Secret as it is very sensitive data.
At the moment i have stored it as a string in the SwiftyStoreKit class but i know that this is not a good idea.
What if I regenerate the Shared Secret, i should update the whole app and would be a mess.

Missing backoffice validation support

Albeit a very appreciated attempt at porting storekit functionaliies to Swift, the solution misses the possibility of validating the purchase remotely in cases when a certain oepration on the backoffice is subjected to the correct processing of the purchase and to prevent fraud. This functionality is missing from all solutions I found using appStoreReceiptUrl while is present in the original MKStoreKit using the deprecated old construct. I know by myself the issue is a very tough one having attempt myself to implement it for a month three years ago, but I am baffled no one suceeded since then.

Downloadable content

Can I use this for IAPs that use downloadable content? (Apple hosted content) I know there isn't any particular functionality for handling downloading, but can I handle downloading myself and just use this library for the purchase part?

Xcode 8 & Swift 3.0 compatibility

hey guys,

I would like to know if theres a status or any workaround to use this pod with xcode 8.. I'm getting errors as soon it converts to swift 3.0..

refresh receipt and validate afterwards

So if I understand right, I can refresh the receipt if there is no receipt present, while verifying the receipt with: SwiftyStoreKit.refreshReceipt

But after doing this, would't it be right to verify the refreshed receipt again calling
SwiftyStoreKit.verifyReceipt ?

But in the completion handler I cannot access the product the receipts belongs to. I have nonconsumable products and autorenewing subscriptions, so I'm not able to choose the right verification method.

In your example you just refresh the receipt without doing anything with it, what's the purpose of this?

Thanks

Purchase Issue for v0.2.7

  • If first purchase net.toolinbox.ihosts.plus, then try to purchase net.toolinbox.ihosts.pro. The Mac App Store part is correct (show the password dialog, confirm dialog, "Thank You" for purchase succeed dialog), but in paymentQueue, beside 2 transaction of Purchasing state, only get a transaction with id of net.toolinbox.ihosts.plus which was continued. And then no more transaction is called, thus the complete handler of purchase is never called.
    purchase_0
    • I manually cancel the purchasing and purchase again, it will return .Purchased even I haven't input password.
      purchase_2
  • In your demo of 'alertForPurchaseResult', doesn't deal with the case user cancel purchasing.
  • In SwiftyStoreKit.purchaseProduct, if the product identifier is empty string, the complete handler will not be called.

Invalid state returned when restoring purchases

Sometimes (I dont know how the users do it - i was not able to simulate it) when user is trying to restore purchases, payment queue returns invalid state .Purchased and the app crashes in the following line:

screen shot 2016-01-11 at 21 33 27

any idea what is wrong?

Using SwiftyStoreKit to verify if user has purchased a previous version of app

Hi guys,

I've got a paid app that I want to make free with in-app purchases. I don't want my users that have already purchased my app to pay for the in app purchase. I had a quick look over your code and I feel I can use it to check the user's receipt to determine if they purchased the app before I changed it from paid to free. I just wondered what you guys thought about this implementation? I'm thinking retrieve the user's receipt then check their original purchase date and original purchased version then lock or unlock all features dependant on the result.

Unit tests

Need to devise a plan and add unit tests for this library as the feature set and the number of contributors has been increasing.

Ideally we could discuss proposed approach for test coverage here and then proceed to implementation.

Validate Receipt - Security issue

There are two ways to validate a receipt properly. Locally or via App Store from a server.

https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Introduction.html

"Use a trusted server to communicate with the App Store. Using your own server lets you design your app to recognize and trust only your server, and lets you ensure that your server connects with the App Store server. 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."

In the way you are doing, you may have security problems.

Product Price Example Should be Changed

In the example used to get product details the approach uses the following to get price:

let priceString = NSNumberFormatter.localizedStringFromNumber(product.price ?? 0, numberStyle: .CurrencyStyle)

The problem I see with this is that it's using the device's region setting to set currency. However, it is possible that the device's region settings are not aligned with the locale that Apple is sending with the product description. In that case the above approach will incorrectly present a currency symbol for the amount given. For example if region is set to France and Apple sends the amount in USD, the code above would put in a Euro symbol but with a USD amount.

Rather than the above I think we should look at the locale of the price Apple sends. This will ensure that the currency symbol always matches the amount. Something like this:

                let numberFormatter = NSNumberFormatter()
                numberFormatter.locale = product.priceLocale
                numberFormatter.numberStyle = .CurrencyStyle
                let priceString = numberFormatter.stringFromNumber(product.price ?? 0)!

Resumption of non-renewable subscription by changing date

After the expiry of the subscription user can change the system date to the date prior expiration. I suggest using request_date_ms from receipt response in InAppReceipt.verifySubscription

maybe this function helps:

private class func getRequestDate(inReceipt receipt: ReceiptInfo) -> NSDate {
        guard let receiptInfo = receipt["receipt"] as? ReceiptInfo else {
            return NSDate()
        }
        let requestDateValue = receiptInfo["request_date_ms"]
        guard let doubleValue = requestDateValue?.doubleValue else { return NSDate() }
        let requestDateDouble = (doubleValue / 1000)
        return NSDate(timeIntervalSince1970: requestDateDouble)
    }

Retrieve Issue for v0.2.7

If disconnect network connection and try to retrieve product list, will only get error of "No bag entry". It's better using better string if could figure it out.

BTW, did you consider to localise the error strings? There're some choices.

  • You can let volunteers help to translate.
  • Or let the developer to translate in their own projects.

Restore issue with v0.2.7

Just create a new test account and then try to restore, will get this issue. In this case should return that no purchase was found. But I'm not sure it's caused by Apple's cache or not.

JSONDecodeError(Optional(""))??

I keep getting this error when I try to verify the receipt. How can I fix this?
I'm running the iOS version on xcode 7.3.1

Debug Output:
CoreFoundation = 1145.150000
Purchase Success: com.testapp.inapp10
Verify receipt Failed: JSONDecodeError(Optional(""))

Auto-renewable verification ~ Subscription group

I have 3 products under auto-renewable verification. All of them unlock a feature, but they are of different durations. Would I have to verify all three with SwiftyStoreKit? If not, how would I verify a group of subscription or something like that?

App store constantly asking for password, even if I cancel the it.

I am implementing an in-app purchase with consumable products. The problem I am facing is dialogue box asking for password constantly start appearing, even if I cancel, it pop up again.

While debugging I found that finishTransaction is not called in InAppCompleteTransactionObserver.

Below method didn't call complete transaction on callbackCalled = true, which is causing dialogue box to appear again and again.

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {

        if callbackCalled {
            return
        }
        if SwiftyStoreKit.hasInFlightPayments {
            return
        }

        var completedTransactions: [SwiftyStoreKit.CompletedTransaction] = []

        for transaction in transactions {

            #if os(iOS) || os(tvOS)
                let transactionState = transaction.transactionState
            #elseif os(OSX)
                let transactionState = PaymentTransactionState(rawValue: transaction.transactionState)!
            #endif

            if transactionState != .Purchasing {

                let completedTransaction = SwiftyStoreKit.CompletedTransaction(productId: transaction.payment.productIdentifier, transactionState: transactionState)

                completedTransactions.append(completedTransaction)

                print("Finishing transaction for payment \"\(transaction.payment.productIdentifier)\" with state: \(transactionState.stringValue)")

                paymentQueue.finishTransaction(transaction)
            }
        }
        callbackCalled = true

        callback(completedTransactions: completedTransactions)
    }

Purchase and product delivery does not seem to be atomic

Hi, I'm planning to use SwiftyStoreKit in my app, but I have concerns about the following lines:

switch transactionState {
case .Purchased:
if isPurchaseRequest {
transactionResults.append(.Purchased(productId: transactionProductIdentifier))
paymentQueue.finishTransaction(transaction)
}

finishTransaction is called before any product is delivered.
I think there is a risk that the user will be charged without the product being delivered, especially if the product is a consumable type.
Is this risk handled somewhere else in the library?

The API docs also says that finishTransaction should be called after product delivery.

Your application should call finishTransaction: only after it has successfully processed the transaction and unlocked the functionality purchased by the user.

Get a list of all products available from products ids

In my current application, I have a list of IDs clear to sales from the API, to be sure which ones I can show to the user, I need to verify which products are available or not on Apple side.

I though about using retrieveProductInfo, but that will create one request per product. One easy solution would be to create retrieveProductsInfo which could take an array of product ids, and return the ids available in the completion block.

What do you think?

Question on purchase response

Hello,
I'm using 0.2.7 version
I'm experiencing the following problem: I got the Success response before I got the Store popups to do the purchase. Sometimes I got the Failed (Cannot connect to the App Store) and after that the Store popups to do the purchase appear.
Is there a way to control the flow of Store popups? or at least prevent them to appear in those situations?

Critical issue when app have multi products.

First, thanks for your framework.

But, after spend days to finish the IAP with your framework, I find a critical issue which prevent me to release this product. This really make me feel upset, change another framework (or implement using Apple's api), or provide help and wait you until this critical issue is fixed?

Steps to reproduce this issue:

  • The App has 2 products to purchase: Plus and Pro.
  • First purchase Plus and succeed.
  • Start to purchase Pro.
  • The problem is, in func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
    • sometimes it has 3 transactions: 1 for Pro with status of Purchasing. 2 for Plus with status of restored (Note: I didn't purchase Plus at this time, I purchase Pro.)
    • sometimes it has 1 transaction for Plus with status of restored (Note: I didn't purchase Plus at this time, I purchase Pro.) I attached the screen capture for this case.
      purchasefailed
    • sometimes it's correct, with normal status of Purchasing (as I even hasn't input password in App Store's pop up dialog.)
  • If has issue in pre-step, it returns, call the handler with SwiftyStoreKit.InternalErrorCode.RestoredPurchaseWhenPurchasing.
    purchasefailed2

This issue doesn't happen every time, but happen 4 times for the 5 test. I guess it's related with the multi-threads/queue. Similar with issue #3 . As AlexCatch said,

I get this error occasionally. It makes the library unusable in Production.

I would like to provide test account if you need. You can also directly contact me beside Github. Thanks.
Jason

Usage questions

  1. after SwiftyStoreKit.restorePurchases(), how to check if auto renewable subscription is active?
    Do I need to call verify subscription? SwiftyStoreKit.verifySubscription
  2. let subscriptionState = SwiftyStoreKit.verifySubscription(productId: "myprouctID", inReceipt: AppState.receipt, validUntil: NSDate(), validDuration: nil)
    where do I get receipt? Can I use
    receiptInfo = InAppReceipt.base64EncodedString as receipt to verify the active subscription?

receipt validation sandbox / production

Would it be possible to implement the verification according to apple?

How do I verify my receipt (iOS)?
Always verify your receipt first with the production URL; proceed to verify
with the sandbox URL if you receive a 21007 status code. Following this
approach ensures that you do not have to switch between URLs while your
application is being tested or reviewed in the sandbox or is live in the
App Store.

Note: The 21007 status code indicates that this receipt is a sandbox receipt,
but it was sent to the production service for verification.

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.