0

我们正在使用 InApp 购买教程“ http://xcodenoobies.blogspot.in/2012/04/implementing-inapp-purchase-in-xcode.html ”。我们不知道如何创建 kStoredData @"com.emirbytes.IAPNoobService "

告诉我如何创建:-- kStoredData @"com.emirbytes.IAPNoobService"

有人解决这个问题吗?

先感谢您。

我们正在使用以下代码:-

@implementation 视图控制器

@synthesize feature2Btn, featureLabel, statusLabel;

定义 kStoredData @"com.emirbytes.IAPNoobService"

-(BOOL)IAPItemPurchased {

// check userdefaults key

NSError *error = nil;
NSString *password = [SFHFKeychainUtils getPasswordForUsername:@"IAPNoob01" andServiceName:kStoredData error:&error];


if ([password isEqualToString:@"whatever"]) return YES; else return NO;

}

-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{

// remove wait view here
statusLabel.text = @"";

SKProduct *validProduct = nil;
int count = [response.products count];

if (count>0) {
    validProduct = [response.products objectAtIndex:0];

    SKPayment *payment = [SKPayment paymentWithProductIdentifier:@"com.emirbytes.IAPNoob.01"];
    [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
    [[SKPaymentQueue defaultQueue] addPayment:payment];


} else {
    UIAlertView *tmp = [[UIAlertView alloc] 
                        initWithTitle:@"Not Available" 
                        message:@"No products to purchase"
                        delegate:self 
                        cancelButtonTitle:nil 
                        otherButtonTitles:@"Ok", nil]; 
    [tmp show];
    [tmp release];
}

}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

if (alertView==askToPurchase) {
    if (buttonIndex==0) {
        // user tapped YES, but we need to check if IAP is enabled or not.
        if ([SKPaymentQueue canMakePayments]) { 

            SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:
            [NSSet setWithObject:@"com.emirbytes.IAPNoob.01"]];

            request.delegate = self;  
            [request start];  


        } else {
            UIAlertView *tmp = [[UIAlertView alloc] 
                                initWithTitle:@"Prohibited" 
                                message:@"Parental Control is enabled, cannot make a purchase!"
                                delegate:self 
                                cancelButtonTitle:nil 
                                otherButtonTitles:@"Ok", nil]; 
            [tmp show];
            [tmp release];
        }
    }
}

}

4

1 回答 1

0

要创建 kStoreDate 数据,您需要 iTunes 连接登录,然后您必须从应用程序的应用内购买选项卡添加它!

这是展示如何创建 kStoreDate 的最佳教程,在这里检查与应用内购买的完全集成

于 2013-04-09T10:14:23.513 回答