在 Mac App Store 的 Electron 应用中实现应用内购买 [英] Implementing in-app purchase in an Electron app for the Mac App Store

查看:16
本文介绍了在 Mac App Store 的 Electron 应用中实现应用内购买的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我环顾四周,似乎有几个人遇到了这个问题,但似乎没有人解决它:

I've looked around and it seems like several people are having this issue but no-one seems to have solved it:

将 Apple 应用内购买添加到 Electron HTML/JS 应用程序

https://github.com/electron/electron/issues/3745

https://discuss.atom.io/t/osx-in-app-purchases-in-electron/22885

有人建议使用这个 Node 到 Objective-C 的桥来做:

Some people suggest using this Node to Objective-C bridge to do it:

https://github.com/TooTallNate/NodObjC

其他人建议使用这个应用内库,但据我所知,它只验证收据:

Other people suggest using this in-app library, but from what I can see, it only validates receipts:

https://github.com/voltrue2/in-app-purchase

有没有人真正设法在 Mac App Store 的 Electron 应用中实现应用内购买?

Has anyone actually managed to implement in-app purchases in an Electron app for the Mac App Store?

你是怎么做到的?

如果没有人做过,那是不可能的吗?

If no one has done it, is it simply impossible to do?

推荐答案

更新

最后,我将应用内购买直接添加到 Electron.

Update

Finally, I added in-app purchase directly to Electron.

参见 https://electronjs.org/docs/tutorial/in-app-购买

我已经实施了这个解决方案,它在开发中有效(尚未在生产中测试).

I have implemented this solution and it works in development (not yet tested in production).

  1. 使用 Xcode 创建一个 MacOS 应用程序 (InAppPurchase) 以执行应用内购买(请参阅 https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction.html)
  2. InAppPurchase.app 放在 Electron 应用文件夹中的某个位置
  3. 使用 require('electron').shell.openItemrequire('child_process').spawn('./InAppPurchase.app/Contents/MacOS/InAppPurchase'); 在您的 Electron 应用中开始应用内购买.
  1. Create a MacOS application (InAppPurchase) with Xcode that performs the in-app purchase (see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Introduction.html)
  2. Put the InAppPurchase.app somewhere in your Electron app folder
  3. Use require('electron').shell.openItem or require('child_process').spawn('./InAppPurchase.app/Contents/MacOS/InAppPurchase'); in your Electron app to start the in-app purchase.

这绝对不是一个干净的解决方案,但它似乎工作......

This is definitely not a clean solution but it seems to work...

我认为它也可以用 NodObjC 来完成.但是,与第一个解决方案相比,此库非常重.

I think that it can also be done with NodObjC. However, this lib is very heavy compared to the first solution.

将应用内购买直接添加到 Electron.

Adding in-app purchase directly to Electron.

如果我可以通过 IAP 在 Mac Apple Store 上发布我的 Electron 应用程序,或者我找到了其他解决方案,我会及时通知您.

I will keep you informed if I can release my Electron app on the Mac Apple Store with IAP or if I found another solution.

这篇关于在 Mac App Store 的 Electron 应用中实现应用内购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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