在IOS应用程序中动态应用程序购买

时间:2014-04-23 06:50:40

标签: ios iphone in-app-purchase ios7.1

我的商品价格是我要购买的,来自服务器。这意味着我将在运行时获得我的商品价格。如何在运行时实现。

2 个答案:

答案 0 :(得分:-1)

[[SubclassInAppHelper sharedInstance] requestProductsWithCompletionHandler:^(BOOL success, NSArray *products) {
    if (success)
    {
        NSMutableArray *arrTemp = [[NSMutableArray alloc]init];
        for (SKProduct *Sss in products)
        {
             NSString *string = Sss.productIdentifier;//@"hello bla bla";

             NSMutableDictionary *dictprod = [NSMutableDictionary dictionary];
             [dictprod setObject:Sss.productIdentifier forKey:@"ProductIdentifier"];
             [dictprod setObject:Sss.price forKey:@"ProductPrice"];
             [dictprod setObject:Sss.localizedTitle forKey:@"ProductTitle"];
             [arrTemp addObject:dictprod];
        }
    }
}

NSLog(@"%@", arrTemp);

请使用Valid Provisioning profile。这一系列产品将为您提供所有应用内购买,其中包含您在应用中添加的详细信息。 试试这段代码可能会对你有帮助。

答案 1 :(得分:-2)

一般来说,您不应该相信自己的服务器价格,而是信任Apple的IAP服务器。至少,向用户收费的是Apple,而不是您的服务器。

IAP(您的情况)的标准流程是:

  1. 从您的服务器获取商品ID列表(仅限)。您的服务器可以决定客户可以购买哪些商品,然后只返回可用商品。
  2. 当您的应用获得列表时,您应该与Apple的服务器联系,以获取这些ID的详细信息。使用SKProductsRequest执行此操作。
  3. Apple会向您的应用返回包含SKProduct个对象的数组。现在,您可以检索您在iTunes Connect中按属性pricepriceLocale设置的价格。
  4. 您可能需要参考Apple的IAP guide以获取更多详细信息