2

私は Ray Wenderlich のチュートリアルに従っていますが、彼のコードを使用しても同じことが起こります。

私は自分のサーバーですべてのファイルをホストしており、接続、ダウンロード、および領収書の検証を完全に行っています。私の問題は、plist で消費可能な変数を false に設定すると、それが true として機能し、その逆も成り立つことです。

なぜそれが本来あるべきこととは逆のことをしているのか、私はとても混乱しています。

したがって、このコードでは、消耗品であると考えられます。

<dict>
    <key>productIdentifier</key>
    <string>com.test.hello</string>
    <key>icon</key>
    <string>icon_hardwords.png</string>
    <key>consumable</key>
    <false/>
    <key>bundleDir</key>
    <string>HardWords</string>
</dict>

これは、トランザクションのダウンロードを提供するためのコードです。

- (void)provideContentForTransaction:
(SKPaymentTransaction *)transaction
               productIdentifier:(NSString *)productIdentifier {

IAPProduct * product = _products[productIdentifier];

if (transaction.downloads) {

    product.skDownload = transaction.downloads[0];
    if (transaction.downloads.count > 1) {
        NSLog(@"Unexpected number of downloads!");
    }
    [[SKPaymentQueue defaultQueue]
     startDownloads:transaction.downloads];

} else {

    // Put the code from before here
    IAPProduct * product = _products[productIdentifier];

    if (product.info.consumable) {
        [self
         purchaseConsumable:product.info.consumableIdentifier
         forProductIdentifier:productIdentifier
         amount:product.info.consumableAmount];
    } else {
        NSURL * bundleURL = [[NSBundle mainBundle].resourceURL
                             URLByAppendingPathComponent:product.info.bundleDir];
        [self purchaseNonconsumableAtURL:bundleURL
                    forProductIdentifier:productIdentifier];
    }

    [self notifyStatusForProductIdentifier:productIdentifier
                                    string:@"Purchase complete!"];

    product.purchaseInProgress = NO;
    [[SKPaymentQueue defaultQueue] finishTransaction:
     transaction];

}

}

これは、コード内で停止する NSAssert です。

- (void)buyProduct:(IAPProduct *)product
{
NSAssert(product.allowedToPurchase, @"This product isn't allowed to be purchased");

NSLog(@"Buying %@...", product.productIdentifier);
product.purchaseInProgress = YES;
SKPayment *paypment = [SKPayment paymentWithProduct:product.skProduct];
[[SKPaymentQueue defaultQueue] addPayment:paypment];

}
4

0 に答える 0