应用内购买在发布后差不多一周仍然无法使用

时间:2014-02-02 10:39:15

标签: ios objective-c cocoa-touch app-store in-app-purchase

在测试期间,应用内购买似乎运作良好,但在发布后它就停止了。我按“升级”按钮后,它会询问我的密码,然后什么也没有。甚至没有错误消息。

我已经浏览了StackOverflow一段时间并找到了这些问题:

In app purchase does not work when live

In App Purchase not working after it has been approved

我以为我只需要等待,但没有人等待超过48小时。对我而言,发布后120小时。所以我认为它可能与我的代码有关。

我的算法基于Ray Wenderlich的教程 http://www.raywenderlich.com/21081/introduction-to-in-app-purchases-in-ios-6-tutorial

首先,在我的app delegate中的`applicationDidFinishLaunchingWithOptions:

// In app
[myGuideIAP sharedInstance]; //initialize singleton
[[myGuideIAP sharedInstance] tryLoadingProduct]; //my method to load SKProduct
//SKProduct is stored as a @property in the singleton

稍后,在升级视图控制器中,我检查它是否未加载产品,再次执行tryloadingProduct

Singleton以经典方式初始化:

+ (myGuideIAP *)sharedInstance {
    static dispatch_once_t once;
    static myGuideIAP * sharedInstance;
    dispatch_once(&once, ^{
        NSSet * productIdentifiers = [NSSet setWithObjects:
                                      @"com.mkochukov.myguidemind.proupgrade",
                                      nil];
        sharedInstance = [[self alloc] initWithProductIdentifiers:productIdentifiers];
    });
    return sharedInstance;
}

这就是tryLoadingProduct方法中的内容:

- (void)tryLoadingProduct
{
    [[myGuideIAP sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products)
     {
        if (success) {
            if (products.count > 0)
                _mProduct = products[0];

        }
    }];
}

当用户尝试购买时,会出现警报视图,要求购买或恢复。这就是它的处理方式

-(void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == alertView.cancelButtonIndex)
        return;
    if (buttonIndex == 0) {
         [[myGuideIAP sharedInstance] buyProduct:[myGuideIAP sharedInstance].mProduct];
    }else if (buttonIndex == 1){
        [[myGuideIAP sharedInstance]restoreCompletedTransactions];
    }
}

之后,当用户点击“购买”按钮时,执行:

- (void)buyProduct:(SKProduct *)product {

    NSLog(@"Buying %@...", product.productIdentifier);

    SKPayment * payment = [SKPayment paymentWithProduct:product];
    [[SKPaymentQueue defaultQueue] addPayment:payment];

}

1 个答案:

答案 0 :(得分:1)

听起来像权利问题,请确保它们已设置。

enter image description here