SKProductsRequest - 现在没有响应(正在工作 - 相同的代码)

发布于 2025-01-02 07:14:31 字数 2205 浏览 0 评论 0原文

代码如下 - 昨天工作的代码提供了无效的 ID,现在工作时间更长了,我已经浏览了大约 10 次代码

。m

 #import <UIKit/UIKit.h>
 #import <StoreKit/StoreKit.h>

@interface InAppViewController : UIViewController  <SKProductsRequestDelegate, SKPaymentTransactionObserver> {

    SKProduct *proUpgradeProduct;
    SKProductsRequest *productsRequest;
}

.h

#import "InAppViewController.h"


@implementation InAppViewController

- (void)viewDidLoad{
    [self requestProUpgradeProductData];
}

- (void)dealloc {
    [super dealloc];
}

- (void)requestProUpgradeProductData
{
    NSLog(@"called  productsRequest");

    NSSet *productIdentifiers = [NSSet setWithObject:@"com.okz8.investor.gem15" ];
    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    [productsRequest start];

    // we will release the request object in the delegate callback
}

#pragma mark -
#pragma mark SKProductsRequestDelegate methods

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *products = response.products;
    proUpgradeProduct = [products count] == 1 ? [[products firstObject] retain] : nil;
    if (proUpgradeProduct)
    {
        NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
        NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
        NSLog(@"Product price: %@" , proUpgradeProduct.price);
        NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }

    // finally release the reqest we alloc/init’ed in requestProUpgradeProductData
    [productsRequest release];

    //[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}

这只是不返回响应,我已经在这里完成了所有操作 http://troybrant.net/blog/2010/01/invalid-product-ids/

之前收到的 ID 无效,现在我什么也没收到

Code as following - this code worked yesterday are providing invalid ID's now longer works, i've been though code about 10 times

.m

 #import <UIKit/UIKit.h>
 #import <StoreKit/StoreKit.h>

@interface InAppViewController : UIViewController  <SKProductsRequestDelegate, SKPaymentTransactionObserver> {

    SKProduct *proUpgradeProduct;
    SKProductsRequest *productsRequest;
}

.h

#import "InAppViewController.h"


@implementation InAppViewController

- (void)viewDidLoad{
    [self requestProUpgradeProductData];
}

- (void)dealloc {
    [super dealloc];
}

- (void)requestProUpgradeProductData
{
    NSLog(@"called  productsRequest");

    NSSet *productIdentifiers = [NSSet setWithObject:@"com.okz8.investor.gem15" ];
    productsRequest = [[SKProductsRequest alloc] initWithProductIdentifiers:productIdentifiers];
    productsRequest.delegate = self;
    [productsRequest start];

    // we will release the request object in the delegate callback
}

#pragma mark -
#pragma mark SKProductsRequestDelegate methods

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response
{
    NSArray *products = response.products;
    proUpgradeProduct = [products count] == 1 ? [[products firstObject] retain] : nil;
    if (proUpgradeProduct)
    {
        NSLog(@"Product title: %@" , proUpgradeProduct.localizedTitle);
        NSLog(@"Product description: %@" , proUpgradeProduct.localizedDescription);
        NSLog(@"Product price: %@" , proUpgradeProduct.price);
        NSLog(@"Product id: %@" , proUpgradeProduct.productIdentifier);
    }

    for (NSString *invalidProductId in response.invalidProductIdentifiers)
    {
        NSLog(@"Invalid product id: %@" , invalidProductId);
    }

    // finally release the reqest we alloc/init’ed in requestProUpgradeProductData
    [productsRequest release];

    //[[NSNotificationCenter defaultCenter] postNotificationName:kInAppPurchaseManagerProductsFetchedNotification object:self userInfo:nil];
}

This just does not return response i've done all here http://troybrant.net/blog/2010/01/invalid-product-ids/

Was getting invalid ID's now i dont get anything

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

拥有 2025-01-09 07:14:31

遇到了同样的问题,并在这里找到了解决方案:
productsRequest 响应方法未调用

由于自动引用计数,我的请求被立即删除再次...

Had the same problem and found the solution here:
productsRequest response method is not calling

Due to automatic reference counting my request was immediately deleted again...

浮光之海 2025-01-09 07:14:31

根据 user178379 的响应,尝试实现此方法:

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
    NSLog(@"request - didFailWithError: %@", [[error userInfo] objectForKey:@"NSLocalizedDescription"]);
}

我的问题是:无法连接到 iTunes Store,其用途是:

StoreKit (In-App purchases) will not work in the Simulator. 13962338

Based on user178379 response, Try to implement this method:

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error {
    NSLog(@"request - didFailWithError: %@", [[error userInfo] objectForKey:@"NSLocalizedDescription"]);
}

My problem was: Cannot connect to iTunes Store, which was for:

StoreKit (In-App purchases) will not work in the Simulator. 13962338
染墨丶若流云 2025-01-09 07:14:31

我刚刚在 iOS 15 设备上遇到了这个问题。

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error

也已实现,但也未调用。

重新启动设备,一切又恢复正常了!

当发生这种情况时,我会在日志中得到以下内容或类似内容:

[BackgroundTask] Background Task 6 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

I just had this problem in an iOS 15 device.

- (void)request:(SKRequest *)request didFailWithError:(NSError *)error

is also implemented, and also not called.

Reboot of device and it all worked again!

When this happens I get this, or similar, in the log:

[BackgroundTask] Background Task 6 ("SKProductsRequest"), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.
梦里的微风 2025-01-09 07:14:31

顺便说一句,在这种情况下,当构建 SKProductsRequest 期间传递的产品标识符集为空时,SKProductsRequestDelegate 委托函数都不是叫。

By the way, it seems, that in the case, when the set of product identifiers being passed during the construction of a SKProductsRequest is empty, neither of the SKProductsRequestDelegate delegate functions are called.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文