接收数据的base64EncodedStringWithOptions返回nil [英] base64EncodedStringWithOptions for receipt data returns nil

查看:2049
本文介绍了接收数据的base64EncodedStringWithOptions返回nil的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用服务器端验证我的应用内购买。
所以我使用以下代码:

I want to validate my in app purchases using server side. So I use the following code:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction * transaction in transactions) {

        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
            {
                NSData *reciptData = [NSData dataWithContentsOfURL:[[NSBundle mainBundle] appStoreReceiptURL]];
                if(reciptData) {
                    NSDictionary *parameters = @{@"receipt_data" : [reciptData base64EncodedStringWithOptions:0]};//App crashes here -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
                }
            }
                break;

            default:
                break;
        }
    };
}

最奇怪的是应用程序在一台iPad上崩溃,iOS 8.0.2和不会在同一个iOS版本的其他版本上崩溃。

The weirdest thing is that application crashes on one iPad with iOS 8.0.2 and does not crash on other with the same iOS version.

最糟糕的是我无法访问应用程序崩溃的设备。

The worst thing is that I do not have access to device on which application crashes.

据我所知 - base64EncodedStringWithOptions:返回 nil 但我不知道为什么。

As far as I understand - base64EncodedStringWithOptions: returns nil but I don't know why.

任何人都可以帮助我吗?

Can anyone help me?

推荐答案

我见过在设备运行某种形式的应用程序内购买破解程序之前的空收据问题,例如IAP Free或IAP Cracker,这意味着该设备已被越狱并且已安装了应用程序内购买破解工具。我会确保应用程序崩溃的设备没有运行某种形式的应用内购买破解工具。您可以做的另一件事是忽略空的收据 - 但不要退货以避免崩溃或返回仅在本地可用的商品。这取决于你如何对破解应用程序内购买的人做出反应 - 有时假装它在本地工作但限制服务器的功能是好的。

I have seen this empty receipt issue before where devices are running some form of in-app purchase cracking program such as "IAP Free" or "IAP Cracker" which implies the device has been jailbroken and an in-app purchase cracking tool has been installed. I would make sure the device where the application crashes is not running some form of in-app purchase cracking tool. The other thing you can do is ignore an empty receipt - but don't return any goods to avoid the crash or return a good that is only available locally. This depends on how you want to react to someone cracking in-app purchases - sometimes it's good to pretend it all works locally but limit features from your server.

这篇关于接收数据的base64EncodedStringWithOptions返回nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆