java - 即使我的用户已经订阅(沙盒),iap.subscribe(Skus[]) 机制也会返回 false
问题描述
我使用自动续订订阅的演示应用程序在我的应用程序上实现自动续订订阅。我可以登录并订阅,这将打开标准的 ios 订阅对话框。但是,下次我登录时,我从 Codenameone 调用 iap.isSubscribed() 机制,结果总是错误的(这是因为我在 testflight 环境中吗?)。当 isSubscribed 方法返回错误时,我将用户发送到具有订阅按钮的订阅页面,当按下此按钮时,我会收到一个对话框,通知我我已经订阅了。
我尝试使用模拟器以及实际的苹果 iphone6+,两者都没有为用户取回成功订阅的收据
@Override
public void initForm() {
theme = UIManager.initFirstTheme("/theme");
//create a new content container
Container content = new Container();
iap = Purchase.getInAppPurchase();
// Pro only feature, uncomment if you have a pro subscription
// Log.bindCrashProtection(true);
// Define a receipt loader
iap.setReceiptStore(createReceiptStore());
/*
The form needs to be split up into 3 parts 1 part for Successful subscriptions
1 part for paymens that have not been sucecssful yet
and 1 part for people who have not subscribed yet
*/
if (!iap.isSubscribed(Skus)) {
EMCDialogFactory.showMessageDialog("Subscription Failed", "Is Subscribed upon login: " + iap.isSubscribed(SKU_1_MONTH));
content = createNonSubscribedHomeScreen();
} else {
EMCDialogFactory.showMessageDialog("Subscription Failed", "Is Subscribed upon login: " + iap.isSubscribed(SKU_1_MONTH));
content = createSuccessfulHomeScreen();
}
setLayout(new BorderLayout());
add(BorderLayout.CENTER, content);
}
/**
* Creates a receipt loader to load receipts from our web service
*
* @return
*/
private ReceiptStore createReceiptStore() {
//fetch all your receipts from the server to be used by the receipt store
listOfReceipts = fetchReceipts();
return new ReceiptStore() {
@Override
public void fetchReceipts(SuccessCallback<Receipt[]> callback) {
List<Receipt> out = new ArrayList<>();
//loop through the receipts
for (Receipt res : listOfReceipts) {
//create a new receipt
Receipt r = new Receipt();
r.setTransactionId(res.getTransactionId());
r.setPurchaseDate(res.getPurchaseDate());
r.setQuantity(1);
r.setSku(res.getSku());
//check cancellation and expiry
if (res.getCancellationDate() != null) {
r.setCancellationDate(res.getCancellationDate());
}
if (res.getExpiryDate() != null) {
r.setExpiryDate(res.getExpiryDate());
}
out.add(r);
}
callback.onSucess(out.toArray(new Receipt[out.size()]));
}
@Override
public void submitReceipt(Receipt r, SuccessCallback<Boolean> callback) {
submitTheReceipt(r, callback);
}
};
}
没有显示错误消息,它只是返回我未订阅的 false 并返回到我的订阅页面。但是,如果我再次按下我的订阅按钮,它会说我已经订阅了。
解决方案
推荐阅读
- dom - 加载网站时如何使用 DOM 操作抓取网站
- angularjs - Angular Js、Angular 1、2、3 和 4 之间有什么区别?
- android - 替换webview中的阿拉伯字符
- json - 尝试在 python 中加载和使用 json 时出现许多错误
- c# - 使用反射从静态类中获取特定事件的事件处理程序列表
- crystal-reports - 带有黄色图标的水晶报表参数
- python - 无法在 Ubuntu 18 上将 ordereddict 安装到特定的 Python 版本
- html - 从 facebook 重定向时没有响应页面
- java - Android / Java:如何并行和重复执行多个http请求?
- javascript - 当用户尝试减去时提醒用户,而没有其他要减去的内容