FBInstant games SDK gives the error
"Cannot find name 'FBInstant'.ts(2304)" in Cocos Creator 3.8.
I have been trying to follow the documentation guide to make the module be detected.
“Currently Cocos Creator does the work for users including:
Integration with Facebook Instant Games SDK and automatic
initialization, allowing users to call the relevant APIs directly
One-click packaging process in the Cocos Creator build panel to
package games directly to Facebook Instant Games specifications What
the user needs to do:
Call the Facebook Instant Games SDK to access platform-related
features Upload the packaged version of Cocos Creator to Facebook”
It also says:
“The Creator is integrated with the Instant Games SDK provided by
Facebook and is automatically initialized when the game is loaded
(initializeAsync and startGameAsync). Users can access it directly
through the FBInstant module, see Instant Games SDK for instructions.
access Facebook’s social features, which can be accessed through the
FB module. However, this SDK Creator is not integrated and needs to be
introduced manually by the user, see official documentation.”
However, if I try to use the FBInstant module in my script then I get the error:
"Cannot find name 'FBInstant'.ts(2304)",
Does anyone have any examples or tutorials of how to use the Facebook Instant Games SDK with Cocos Creator. Or does anyone know how to import the module in a way where I dont get this error? I dont want the error to just go away, I want the module to actually be loaded correctly.
I have searched through the Githubs of the tutorials on the Cocos page for tutorials and examples.
But I cant seem to find any Facebook Instant Games examples.
Can you help or give me an idea about how to proceed? Thank you. Examples would be great if you have any too!
You can access the FBInstant object directly in your project:
Check vsconsole on the build panel to enable the project to view logs.
@Doh09 means how to let VSCode recognize FBInstant APIs through typescript config, is there a .d.ts for FB ?
Install the .d.ts from this npm module could solve the issue
After you get index.d.ts, place the file in the root directory of your project.
npm install --save @types/facebook-instant-games