【发布时间】:2012-04-11 21:05:37
【问题描述】:
我正在测试 Mac OS Lion 上可用的应用内购买新功能,我卡在收据验证部分,我的代码在这部分总是失败,就好像我没有连接到沙盒或应用程序收据一样永远不要把收据发给我,因为 "exit(173);" 应该可以工作。
这些是我的步骤:
1-为应用程序注册一个显式的 App ID。 ([会员中心][1])。
2-在 iTunes 上添加应用程序 ID,状态为:“准备上传”。
3-添加应用内购买产品产品。
5-创建测试用户 6-创建、下载和安装 Mac 签名证书,该证书使用为应用内购买启用的应用 ID 7-开发配置文件和此证书。 ([会员中心][1])。
7-将 Provisioning 配置文件添加到 Xcode Observer。
8-在 Xcode 中 My Target 的 Info 窗格的 Bundle Identifier 字段中输入 App ID 的 Bundle Identifier 部分。
9-用我的证书签署代码。
注意:我在 finder 上测试应用程序,而不是 Xcode 调试器。
这里是应用代码:
标题:
#import <Cocoa/Cocoa.h>
#import <StoreKit/StoreKit.h>
@interface AppDelegate : NSObject <NSApplicationDelegate,SKProductsRequestDelegate,SKPaymentTransactionObserver>
{
NSWindow *window;
IBOutlet NSTextField *label;
IBOutlet NSButton *checkox;
}
@property (assign) IBOutlet NSWindow *window;
-(void)request:(SKRequest *)request didFailWithError:(NSError *)error;
- (void)applicationDidFinishLaunching:(NSNotification *)notification;
-(void)requestUpgradeProductsData;
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response;
-(IBAction)checkBoxState:(id)sender;
@end
代码:
#import "AppDelegate.h"
@implementation AppDelegate
@synthesize window = _window;
-(void)applicationWillFinishLaunching:(NSNotification *)notification
{
NSLog(@"applicationDidFinishLaunching");
NSURL *receiptUrl = [[NSBundle mainBundle] appStoreReceiptURL];
if (![[NSFileManager defaultManager] fileExistsAtPath:[receiptURL path]])
{
NSLog(@"no receipt - exit the app with code 173");
exit(173);
}
}
-(void)requestUpgradeProductsData
{
if([SKPaymentQueue canMakePayments])
{
SKProductsRequest *request =[[SKProductsRequest alloc]initWithProductIdentifiers:[NSSet setWithObjects:@"com.comany.MyApp.DLC1",@"com.comany.MyApp.DLC2",nil]];
request.delegate = self;
[request start];
}
}
-(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
int count = response.products.count;
if(count!=0)
{
NSLog(@"COUNT IS NOT ZERO");
}
else
{
[label setStringValue:@"NO PRODUCT"];
}
}
-(IBAction)checkBoxState:(id)sender
{
[self requestUpgradeProductsData];
}
-(void) request:(SKRequest *)request didFailWithError:(NSError *)error
{
NSLog(error);
}
@end
-我的代码总是在 "exit(173);" 退出,如果我删除此检查,我会将我的所有产品作为无效标识符。 -当我用 3d 方证书应用商店签署我的代码时,要求提供登录信息,但是当我用开发证书应用商店签署我的代码时,什么都不做。
谢谢。
【问题讨论】:
标签: xcode in-app-purchase osx-lion storekit