- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我正在尝试使 In-App Purchase
订阅优惠起作用。所以我从我们的服务器获得了编码的签名、随机数、时间戳和 key 标识符。我创建了一个 SKPaymentDiscount
对象并将其设置为 SKMutablePayment
对象的 paymentDiscount
。
在第一次弹出时,它按预期显示修改后的价格 -> 输入密码并继续 -> 第二次弹出:确认订阅:好的 -> 第三次弹出:显示以下错误 无法购买 联系开发者获取更多信息。
我尝试为产品传递不适用的报价标识符。然后它抛出正确的错误说:这不能应用于这个。
PromoOfferAPI.prepareOffer(usernameHash: "name", productIdentifier: "bundleid.product", offerIdentifier: "TEST10") { (result) in
switch result {
case let .success(discount):
// The original product being purchased.
let payment = SKMutablePayment(product: option.product)
// You must set applicationUsername to be the same as the one used to generate the signature.
payment.applicationUsername = "name"
// Add the offer to the payment.
payment.paymentDiscount = discount
// Add the payment to the queue for purchase.
SKPaymentQueue.default().add(payment)
break
case let .customFail(message):
print(message)
break
case let .failure(error):
print(error.localizedDescription)
break
}
}
无论我尝试多少次,它总是给我同样的错误。 无法购买 联系开发者获取更多信息。可以采取什么措施来解决这个问题。任何帮助深表感谢。
提前致谢!
编辑 1:它永远不会进入 updatedTransactions
函数。它只记录 Finishing transaction for payment "bundleid.product"状态:失败。
编辑 2:得到错误: code - 12 (invalidSignature)。无法连接到 iTunes Store
生成编码签名的 Node.JS 代码。
const UUID = require("uuid-v4");
const microtime = require('microtime');
const express = require('express');
const router = express.Router();
const EC = require("elliptic").ec;
const ec = new EC("secp256k1");
const crypto = require('crypto');
const privateKey = `-----BEGIN PRIVATE KEY-----
key goes here
-----END PRIVATE KEY-----`;
//const key = ec.keyFromPrivate(privateKey,'hex');
router.post('/',(req, res)=>{
const bundle_id = "bundle.id";
const key_id = "keyed";
const nonce = String(UUID()).toLowerCase();// Should be lower case
const timestamp = microtime.now();
const product = req.body.product;
const offer = req.body.offer;
const application_username = req.body.application_username;
const payload = bundle_id + '\u2063' + key_id + '\u2063' + product + '\u2063' + offer + '\u2063' + application_username + '\u2063' + String(nonce) + '\u2063' + String(timestamp)
let shaMsg = crypto.createHash("sha256").update(payload).digest();
let signature = ec.sign(shaMsg, privateKey, {canonical: true});
let derSign = signature.toDER();
let buff = new Buffer(derSign);
let base64EncodedSignature = buff.toString('base64');
let response = {
"signeture": base64EncodedSignature,
"nonce": nonce,
"timestamp": timestamp,
"keyIdentifier": key_id
}
res.type('json').send(response);
});
module.exports = router;
最佳答案
我在测试他们提供的新 WWDC2019 示例 Node.js 服务器文件时遇到了同样的问题。按照自述文件后,我能够成功生成签名。
然而,令我惊讶的是,一个无效的签名看起来就像一个有效的,我花了一段时间才意识到我的签名是无效的。
我的错误如下:我使用 Alamofire 向我的服务器发出 GET 请求,如下所示:
AF.request("myserver:3000/offer", parameters: parameters).responseJSON { response in
var signature: String?
var keyID: String?
var timestamp: NSNumber?
var nonce: UUID?
switch response.result {
case let .success(value):
let json = JSON(value)
// Get required parameters for creating offer
signature = json["signature"].stringValue
keyID = json["keyID"].stringValue
timestamp = json["timestamp"].numberValue
nonce = UUID(uuidString: json["nonce"].stringValue)
case let .failure(error):
print(error)
return
}
// Create offer
let discountOffer = SKPaymentDiscount(identifier: offerIdentifier, keyIdentifier: keyID!, nonce: nonce!, signature: signature!, timestamp: timestamp!)
// Pass offer in completion block
completion(discountOffer) // this completion is a part of the method where this snippet is running
}
}
关于 WWDC2019 Video on Subscription Offers 中提供的文件,在 index.js 文件中,他们正在加载我在请求中传递的参数,如下所示:
const appBundleID = req.body.appBundleID;
const productIdentifier = req.body.productIdentifier;
const subscriptionOfferID = req.body.offerID;
const applicationUsername = req.body.applicationUsername;
但是,我的 alamofire 请求并没有传递正文中的参数,而是作为查询参数传递。因此,服务器正在生成一个带有 null appBundleID 以及其他 null 字段的签名!所以我把上面提到的 index.js 部分改成如下:
const appBundleID = req.query.appBundleID;
const productIdentifier = req.query.productIdentifier;
const subscriptionOfferID = req.query.offerID;
const applicationUsername = req.query.applicationUsername;
我希望这对忽略这一点的人有所帮助。请原谅我不安全的 swift,但我希望你明白这一点!
关于ios - 无法使用订阅优惠购买,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56148983/
IO 设备如何知道属于它的内存中的值在memory mapped IO 中发生了变化? ? 例如,假设内存地址 0 专用于保存 VGA 设备的背景颜色。当我们更改 memory[0] 中的值时,VGA
我目前正在开发一个使用Facebook sdk登录(通过FBLoginView)的iOS应用。 一切正常,除了那些拥有较旧版本的facebook的人。 当他们按下“使用Facebook登录”按钮时,他
假设我有: this - is an - example - with some - dashesNSRange将使用`rangeOfString:@“-”拾取“-”的第一个实例,但是如果我只想要最后
Card.io SDK提供以下详细信息: 卡号,有效期,月份,年份,CVV和邮政编码。 如何从此SDK获取国家名称。 - (void)userDidProvideCreditCardInfo:(Car
iOS 应用程序如何从网络服务下载图片并在安装过程中将它们安装到用户的 iOS 设备上?可能吗? 最佳答案 您无法控制应用在用户设备上的安装,因此无法在安装过程中下载其他数据。 只需在安装后首次启动应
我曾经开发过一款企业版 iOS 产品,我们公司曾将其出售给大型企业,供他们的员工使用。 该应用程序通过 AppStore 提供,企业用户获得了公司特定的配置文件(包含应用程序配置文件)以启用他们有权使
我正在尝试将 Card.io SDK 集成到我的 iOS 应用程序中。我想为 CardIO ui 做一个简单的本地化,如更改取消按钮标题或“在此保留信用卡”提示文本。 我在 github 上找到了这个
我正在使用 CardIOView 和 CardIOViewDelegate 类,没有可以设置为 YES 的 BOOL 来扫描 collectCardholderName。我可以看到它在 CardIOP
我有一个集成了通话工具包的 voip 应用程序。每次我从我的 voip 应用程序调用时,都会在 native 电话应用程序中创建一个新的最近通话记录。我在 voip 应用程序中也有自定义联系人(电话应
iOS 应用程序如何知道应用程序打开时屏幕上是否已经有键盘?应用程序运行后,它可以接收键盘显示/隐藏通知。但是,如果应用程序在分屏模式下作为辅助应用程序打开,而主应用程序已经显示键盘,则辅助应用程序不
我在模拟器中收到以下错误: ImageIO: CGImageReadSessionGetCachedImageBlockData *** CGImageReadSessionGetCachedIm
如 Apple 文档所示,可以通过 EAAccessory Framework 与经过认证的配件(由 Apple 认证)进行通信。但是我有点困惑,因为一些帖子告诉我它也可以通过 CoreBluetoo
尽管现在的调试器已经很不错了,但有时找出应用程序中正在发生的事情的最好方法仍然是古老的 NSLog。当您连接到计算机时,这样做很容易; Xcode 会帮助弹出日志查看器面板,然后就可以了。当您不在办公
在我的 iOS 应用程序中,我定义了一些兴趣点。其中一些有一个 Kontakt.io 信标的名称,它绑定(bind)到一个特定的 PoI(我的意思是通常贴在信标标签上的名称)。现在我想在附近发现信标,
我正在为警报提示创建一个 trigger.io 插件。尝试从警报提示返回数据。这是我的代码: // Prompt + (void)show_prompt:(ForgeTask*)task{
您好,我是 Apple iOS 的新手。我阅读并搜索了很多关于推送通知的文章,但我没有发现任何关于 APNS 从 io4 到 ios 6 的新更新的信息。任何人都可以向我提供 APNS 如何在 ios
UITabBar 的高度似乎在 iOS 7 和 8/9/10/11 之间发生了变化。我发布这个问题是为了让其他人轻松找到答案。 那么:在 iPhone 和 iPad 上的 iOS 8/9/10/11
我想我可以针对不同的 iOS 版本使用不同的 Storyboard。 由于 UI 的差异,我将创建下一个 Storyboard: Main_iPhone.storyboard Main_iPad.st
我正在写一些东西,我将使用设备的 iTunes 库中的一部分音轨来覆盖 2 个视频的组合,例如: AVMutableComposition* mixComposition = [[AVMutableC
我创建了一个简单的 iOS 程序,可以顺利编译并在 iPad 模拟器上运行良好。当我告诉 XCode 4 使用我连接的 iPad 设备时,无法编译相同的程序。问题似乎是当我尝试使用附加的 iPad 时
我是一名优秀的程序员,十分优秀!