【问题标题】:Mac OS LION 10.7 In-App PurchaseMac OS LION 10.7 应用内购买
【发布时间】: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 方证书应用商店签署我的代码时,要求提供登录信息,但是当我用开发证书应用商店签署我的代码时,什么都不做。

谢谢。

https://developer.apple.com/membercenter/index.action

【问题讨论】:

    标签: xcode in-app-purchase osx-lion storekit


    【解决方案1】:

    在 Finder 中启动应用程序,这并不意味着您出于某种原因在 xcode 之外启动。

    1. 选择产品 -> 从菜单存档
    2. 选择您的应用并选择分发
    3. 选择导出为应用程序
    4. 所以现在当您启动导出的应用程序时,该应用程序将强制退出并在您登录后询问您的测试用户帐户。该应用程序将自动为您重新启动。

    现在您有一个收据并且可以测试购买。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多