我們正在使用應用程式內購買教程「http://xcodenoobies.blogspot.in/2012/04/implementing-inapp-purchase-in-xcode.html」。我們不無如何創建kStoredData @「com.emirbytes.IAPNoobService」應用程式內購買(IOS 6)如何創建kStoredData @「com.emirbytes.IAPNoobService」
告訴我如何創建: - kStoredData @「com.emirbytes.IAPNoobService」
有人解決了這個問題嗎?
非常感謝您。
我們用下面的代碼: -
@implementation ViewController中
@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;
}
- (無效)productsRequest:(SKProductsRequest *)請求didReceiveResponse :(SKProductsResponse *)迴應
{
// 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];
}
}
- (空)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];
}
}
}
}
最好的教程定義kStoredData @「com.emirbytes.IAPNoobService」這是id.First您創建應用程序ID和束ID,然後用你的應用程序包需要在您的代碼或應用程序中。 – 2013-03-19 08:02:13