我不断收到21002显示java.lang.NullPointerException从苹果的错误,当我尝试测试我的应用程序内购买在沙箱中。这是我做了什么:
I keep getting 21002 'java.lang.NullPointerException' errors from Apple when I try to test my In-App Purchases in the sandbox. This is what I have done:
设置了应用程序内购买的产品在iTunes Connect。我可以通过StoreKit成功找回它们。 在iTunes Connect中设置的测试用户。 在应用程序启动时,会下载可用的应用程序内购买的产品,我触发应用程序内购买和苹果回应与transactionReceipt,这是我的base64恩code iPhone和发送到我的C#/ ASP。 NET服务器。 服务器会将接收到的字符串转换成JSON(我想它都与 NewtonSoft.Json
和手动),并发送JSON苹果:
Set up the In-App Purchase products in iTunes Connect. I can successfully retrieve them via StoreKit.
Set up test user in iTunes Connect.
Application starts up, downloads the available In-App Purchase products, I trigger the In-App Purchase and Apple responds with the transactionReceipt, which I base64-encode on the iPhone and send to my C#/ASP.NET server.
The server puts the received string into JSON (I tried it both with NewtonSoft.Json
and manually) and sends the JSON to Apple:
VAR JSON ={'接收数据:+收据+'};
或
VAR JSON =新JObject(新JProperty(接收数据,收据))的ToString();
然后:
var webRequest = System.Net.HttpWebRequest.Create("https://sandbox.itunes.apple.com/verifyReceipt");
webRequest.ContentType = "text/plain";
webRequest.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(receipt);
webRequest.ContentLength = byteArray.Length;
using (var stream = webRequest.GetRequestStream())
{
stream.Write(byteArray, 0, byteArray.Length);
stream.Flush();
}
var resp = webRequest.GetResponse();
if (resp != null)
{
using (var sr = new System.IO.StreamReader(resp.GetResponseStream()))
{
var result = sr.ReadToEnd().Trim();
var iapResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<AppleIapResponse>(result);
// always getting '21002' 'java.lang.NullPointerException'
}
}
我什么都试过:改变的ContentType的JSON格式,编码....
I tried everything: changing the ContentType, the JSON formatting, the encoding....
任何提示?
这是在code一个简单的错误,我写了收据进入后,不是JSON:
It's a simple bug in the code, I was writing the receipt into the POST, not the JSON:
byte[] byteArray = Encoding.UTF8.GetBytes(json);
^^^^
城墙,从撞我的头好痛..
The wall hurts from banging my head against it..
上一篇:Android 2.1的:如何放大/缩小和滚动一个GridViewAndroid、GridView
下一篇:在NDK / Java项目Eclipse CDT的C / C ++ code完成的问题项目、问题、Java、NDK