Optimizely

Configuration

Update the following parameters on the Push Notifications tab under Optimizely:

{
  "active": true | false,
}

Deep Linking

Set up Deep Linking within your app and notification links will automatically open directly into your app.

JavaScript Bridge Functions

Initialize

Initialize Optimizely with your API Key if your app is not configured within the App Studio for automatic initialization.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.initialize({
  'apiKey': STRING,
  'callback': function // optional otherwise returns promise
});
// Return value:
{
  "success": true | false
}

Check if Initialized

Check if the Optimizely SDK is initialized to avoid duplicate initialization.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.isInitialized({'callback': function});
// Return value:
{
  'initialized': true | false,
  'apiKey': STRING, // available only if initialized is true
}

Set Email or Set User Id

Identify the user with Optimizely. After the user has been identified run registerForPush() to generate a new token.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.setEmail({
  'email': STRING,
  'callback': function // optional otherwise returns promise
});
// Return value:
{
  "success": true | false
}

median.optimizely.setUserId({
  'userId': STRING,
  'callback': function
});
// Return value:
{
  "success": true | false
}

Register for Push Notifications

Register the current user for push notifications and generate a new token.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.registerPush({'callback': function});
// Return value:
{
  "success": true | false
}

Prompt for Push Notification Permission

Request Push Notification permission, which will show a dialog for users to confirm permission. For Android, the dialog is only shown on Android 13 and above. On Android 12 and below, permission will always be granted without user intervention.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.requestPermission({'callback': function});
// Return value:
{
  "granted": true | false
}

Check Push Notification Permission Status

Obtain Push Notification permission status.

Provide a callback function or otherwise a promise is returned.

↔️Median JavaScript Bridge

median.optimizely.permissionStatus({'callback': function});
// Return value:
{
  "granted": true | false
}