Meta
public class Meta
Class for creating and presenting Metaverse experiences.
Follow the following steps to present a Metaverse experience using this framework.
- Retrieve your API key from https://studio.gometa.io/sdk/keys
- Use your API key to initialize Meta in your ApplicationDelegate by calling:
Meta.configure(withKey: "API_KEY")
inapplication(didFinishLaunchingWithOptions:)
- Create a
MetaExperience
object with the ID of the experience you want to load:var experience = MetaExperience(id: "EXPERIENCE_ID")
- (optional) Set the delegate of the experience if you want to be notified
when the experience is closed:
experience.delegate = self
- Present the experience:
Meta.shared.present(experience: experience)
Please report any errors, issues, or suggestions via Github issues.
-
Reference to the shared instance of the framework
Declaration
Swift
public static var shared: Meta
-
Set the log level of the framework
Declaration
Swift
public static var logLevel: MetaLogLevel = .error
-
Return whether or not ARKit is supported on the current device
Declaration
Swift
public static var arKitIsSupported: Bool
-
Start off with an empty configuration object that we’ll mutate later
Declaration
Swift
public var configuration = MetaConfigurationObject()
-
Initializes the framework with your API key. Ideally, this should be done in your application delegate.
You can find your API key by logging into Metaverse Studio and navigating to https://studio.gometa.io/sdk/keys
When you are ready to launch your app, you will need to request a production API key by emailing support@gometa.io
Attempting to load an experience without first initializing this configuration object will crash the framework.
Declaration
Swift
public static func configure(withKey key: String)
Parameters
withKey
Your API key
-
Identify a user using some unique piece of information known by your application. For instance, if your app requires accounts, you can invoke this method at the time of sign in and provide your user ID as the argument (or, if you require unique usernames, the username; or another piece of information like phone number or email address) to create a persistent Metaverse account linked to their user profile within your app.
Identifying users allows you to do things like save and track user properties across experiences, and to give and request items from users’ inventories.
This method only needs to be invoked once. It writes the user’s identification key to your app’s UserDefaults, and references it when loading subsequent experiences.
Note that, at this time, if you are unable to identify a user, or choose not to, all Metaverse
activity
within your app will appear to be coming from the account associated with your API key. This is fine for testing, but might lead to collisions and weird things when dealing with items and user properties in production. We recommend at least identifying a user with a randomly generated UUID.Declaration
Swift
public func identify(user id: String)
Parameters
user
The piece of unique data to use to identify this user. This can be any unique string, like a UUID, username, or phone number.
-
Present a Metaverse experience. Metaverse experiences are presented on the application’s current UIWindow, and removed from that window when they are completed or closed. You should not draw, or attempt to draw, content above the experience view.
Declaration
Swift
public func present(experience: MetaExperience)
Parameters
experience
The Metaverse experience object