Implementing in-app purchase in an Electron app for the Mac App Store

前端 未结 2 813
无人共我
无人共我 2021-02-14 09:15

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

Adding Apple in-app purchase to Electron HTML/JS app

相关标签:
2条回答
  • 2021-02-14 09:44

    Update

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

    See https://electronjs.org/docs/tutorial/in-app-purchases


    First solution

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

    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...

    Second solution

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

    Third solution

    Adding in-app purchase directly to 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.

    0 讨论(0)
  • 2021-02-14 09:45

    In addition to user108828 i can suggest a couple more ideas to solve your problem:

    1. You can implement MAS receipt validation as a dynamic library in obj-C/C++/C using Xcode and then include it in your project via ToTallNate's node-ffi. For implementation you can use any of a large number of solutions that you can easely find on web.

    2. Another way to perform receipt verification is to create a self made node addon that includes openssl and objective-c runtime libraries. For this solution you may also need to include CoreFoundation and/or some other apple frameworks. As a result you will be able to implement your validation in pure C/C++ and incapsulate it in your node module.

    The API design of your dylib/node addon is strictly up to you and should be kept in secret.

    Good luck!

    0 讨论(0)
提交回复
热议问题