美文网首页
IG使用本地服务器进行测试

IG使用本地服务器进行测试

作者: iOS苦逼开发 | 来源:发表于2024-07-18 15:27 被阅读0次
    1. 打开终端,安装http-server
    MBP ~ % npm install -g http-server
    
    1. cd到游戏目录下,如cocos creator项目是在构建出来的游戏包根目录(build/fb-instant-game),然后生成私钥,接着生成证书,生成证书时需要填资料,可以随便填
    MBP ~ % cd /Users/***/***/***/build/fb-instant-games
    MBP ~ % openssl genrsa 2048 > key.pem
    MBP ~ % openssl req -x509 -days 1000 -new -key key.pem -out cert.pem
    // Fill out information
    ....
    
    1. 开始启用本地server服务,Ctrl + C可以停止,每次使用本地服务器测试前需要输入此指令。
    http-server --ssl -c-1 -p 8080 -a 127.0.0.1 
    
    1. 打开以下网址开始运行游戏进行测试,<YOUR_GAME_ID>替换成自己的游戏ID
    https://www.facebook.com/embed/instantgames/<YOUR_GAME_ID>/player?game_url=https://localhost:8080
    

    第一次打开的时候可能会遇到游戏加载不进去,打开控制台可以看到以下问题:

    image.png
    这是因为使用的是本地自定义的证书,浏览器不信任导致的,这时候需要输入并打开网址:https://localhost:8080,然后在控制台界面输入:
    sendCommand(SecurityInterstitialCommandId.CMD_PROCEED)
    image.png
    然后再重新打开测试链接,就可以了

    相关文章

      网友评论

          本文标题:IG使用本地服务器进行测试

          本文链接:https://www.haomeiwen.com/subject/bairhjtx.html