FBInstant在TS下无法访问

FBInstant模块在JS下正常访问,没有报错,但是改为TS,显示报错信息:找不到名称“FBInstant”。
求教如何解决这个问题?

你是要做FB小游戏吗

是哪报错?编辑器还是浏览器

cc.sys.isObjectValid(window.FBInstant);
你需要判断 是否存在此对象.
引用的时候需要用window.FBInstant

去下载一个 d.ts 的文件
https://github.com/runinspring/FBInstantGameDTS

1赞

这个问题已经解决了,在头文件加个:
declare let FBInstant : any;

你这样跑起来会报错吧

大佬 有木有7.1版本的呀

@types/facebook-instant-games”: “^7.1.0”
Use npm to install the type d.ts
It’s easy to use with full funtion in FBInstant api.