SKProductsRequest - 现在没有响应(正在工作 - 相同的代码)
代码如下 - 昨天工作的代码提供了无效的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
遇到了同样的问题,并在这里找到了解决方案:
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...
根据 user178379 的响应,尝试实现此方法:
我的问题是:
无法连接到 iTunes Store
,其用途是:Based on user178379 response, Try to implement this method:
My problem was:
Cannot connect to iTunes Store
, which was for:我刚刚在 iOS 15 设备上遇到了这个问题。
也已实现,但也未调用。
重新启动设备,一切又恢复正常了!
当发生这种情况时,我会在日志中得到以下内容或类似内容:
I just had this problem in an iOS 15 device.
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:
顺便说一句,在这种情况下,当构建
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 theSKProductsRequestDelegate
delegate functions are called.