在 App Purchase 中恢复不工作 - iOS Swift StoreKit
In App Purchase restore Not Working - iOS Swift StoreKit
我正在使用 SwiftyStoreKit 来处理我的应用内购买。我有一项非消耗性应用内购买。我无法恢复购买。我正在我的应用程序的发布版本上对此进行测试,之前我已为此付费,但它不会恢复。我用来调用 SwiftyStoreKit 的代码如下:
SwiftyStoreKit.restorePurchases(atomically: true) { results in
if results.restoreFailedProducts.count > 0 {
print("Restore Failed: \(results.restoreFailedProducts)")
}
else if results.restoredProducts.count > 0 {
print("Restore Success: \(results.restoredProducts)")
self.defaults?.set(true, forKey: "UnlockApp")
NotificationCenter.default.post(name: Notification.Name(rawValue: "transition"), object: nil)
self.dismissView()
} else {
print("Nothing to Restore")
}
}
如您所见,我设置了用户默认值以解锁应用程序中的功能,但这永远不会触发它总是返回 "Nothing to Restore"
有没有人处理过这个问题,或者知道这种行为的可能原因?
编辑:这是在物理设备上的发布版本(非沙盒购买)
解决方案是当我在 phone 上有开发者版本时,我必须:
- 卸载开发者版本
- 重启iPhone
- 从应用商店下载正式版
然后恢复购买选项将起作用
我正在使用 SwiftyStoreKit 来处理我的应用内购买。我有一项非消耗性应用内购买。我无法恢复购买。我正在我的应用程序的发布版本上对此进行测试,之前我已为此付费,但它不会恢复。我用来调用 SwiftyStoreKit 的代码如下:
SwiftyStoreKit.restorePurchases(atomically: true) { results in
if results.restoreFailedProducts.count > 0 {
print("Restore Failed: \(results.restoreFailedProducts)")
}
else if results.restoredProducts.count > 0 {
print("Restore Success: \(results.restoredProducts)")
self.defaults?.set(true, forKey: "UnlockApp")
NotificationCenter.default.post(name: Notification.Name(rawValue: "transition"), object: nil)
self.dismissView()
} else {
print("Nothing to Restore")
}
}
如您所见,我设置了用户默认值以解锁应用程序中的功能,但这永远不会触发它总是返回 "Nothing to Restore"
有没有人处理过这个问题,或者知道这种行为的可能原因?
编辑:这是在物理设备上的发布版本(非沙盒购买)
解决方案是当我在 phone 上有开发者版本时,我必须:
- 卸载开发者版本
- 重启iPhone
- 从应用商店下载正式版
然后恢复购买选项将起作用