SDK Configuration

Initialize the Glassfy SDK once in the early stage of an application lifecycle.

You can find your API key in the app Setting page of the Glassfy Dashboard, you can copy it by clicking on the button to the right of the form.

13451345

Step 1

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

  Glassfy.initialize(apiKey: "YOUR_API_KEY", watcherMode: false)

  [...]

  // optionally login your user
  Glassfy.login(user: "youruser")

}
[...]
ContentView()
    .onAppear() {
        Glassfy.initialize(apiKey: "YOUR_API_KEY", watcherMode: false)
  }
[...]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

  [Glassfy initializeWithAPIKey:@"YOU_API_KEY" watcherMode:NO];

  [...]

  // optionally login your user
  [Glassfy loginUser:@"youruser" withCompletion:nil];
}
class App : Application() {
  override fun onCreate() {
    super.onCreate()

    Glassfy.initialize(this, "YOUR_API_KEY", false, null)
  }
}
public class App extends Application {
  @Override
  public void onCreate() {
    super.onCreate();
    Glassfy.initialize(this, "YOUR_API_KEY", false, null);
  }
}
try {

  await Glassfy.initialize('YOU_API_KEY',watcherMode: false);

} catch (e) {
  // error
  [...]
}
try {

  await Glassfy.initialize('YOU_API_KEY', false);

} catch (e) {
  // initialization error
  [...]
}
try {

  await Glassfy.initialize({ apiKey: 'YOU_API_KEY', watcherMode: false });

} catch (e) {
  // initialization error
  [...]
}

Did this page help you?