Why use Optimizely
- Bridge-first control: Request permissions, read permission state, and sync user identity from JavaScript without writing native code.
- Push workflow coverage: Request notification permission, check permission status, and register for push from a single API.
- User identity support: Set user email or user ID for audience targeting before registering push tokens.
Prerequisites
- A Median app with JavaScript Bridge enabled
- Optimizely API key
- Deep linking setup if you want notification links to open directly in-app
What you’ll do
Use this section as a fast navigation map into the full setup and implementation details:- Enable the plugin config: Go to Plugin setup and complete Enable the plugin.
- Confirm runtime behavior: Review Configuration options for the
activetoggle behavior. - Implement bridge calls: Add core methods from JavaScript Bridge functions.
- Validate integration flow: Run the scenarios in Code examples.
- Verify edge cases: Complete Testing checklist and use Troubleshooting.
Plugin setup
Enable the plugin
To enable this plugin, book a call with the Median team to discuss your requirements and get started.Configuration options
Note: Notification links can open directly in the app when Deep Linking is configured.
JavaScript Bridge functions
Initialize
Initialize Optimizely with an API key when not auto-configured in App Studio. For this function, provide a callback function or otherwise a promise is returned.
Return value:
Check if initialized
Check whether the Optimizely SDK is already initialized. For this function, provide a callback function, or a promise is returned.
Return value:
Set email
Identify the user by email address in Optimizely. CallregisterPush after this to generate a new push token associated with the identified user. For this function, provide a callback function or otherwise a promise is returned.
Return value:
Set user ID
Identify the user by a custom ID in Optimizely. CallregisterPush after this to generate a new push token associated with the identified user. For this function, provide a callback function or a promise is returned.
Return value:
Register for push notifications
Register the current user for push and generate a new push token. Call this after setting the user identity to ensure the token is associated with the identified user. For this function, provide a callback function, or a promise is returned.
Return value:
Prompt for push notification permission
Prompt the user to grant notification permission. For this function, provide a callback function, or otherwise a promise is returned.
Return value:
Check push notification permission status
Check the current notification permission state without prompting the user. For this function, provide a callback function, or a promise is returned.
Return value:
Testing checklist
Use this checklist to ensure Optimizely is working correctly in your app: Basic functionality-
initializereturns{ success: true }. -
isInitializedreflects the expected state after initialization. -
setEmailandsetUserIdeach return{ success: true }. -
registerPushsucceeds after user identity is set. - Plugin loads without JavaScript errors.
- Permission request flow works on iOS.
- Android 13+ shows the system permission dialog.
- Android 12 and below grants permission without a dialog prompt.
- Plugin gracefully handles platform differences.
- Invalid or missing API key is handled in the UI flow.
- An initialization guard prevents duplicate
initializecalls. - Permission-denied path is handled gracefully.
- Network errors during push registration are caught and logged.
- Push registration is re-run after identity updates.
- Deep link notification opens the correct route in-app when configured.
- Both promise and callback invocation styles work in your integration.
- Users receive a clear prompt when notification permission is requested.
- App provides a fallback experience when push permission is denied.
- No duplicate permission prompts appear after the user has already responded.
- Plugin does not interfere with app navigation or page transitions.
Troubleshooting
Optimizely functions are undefined or not working
Confirm the JavaScript Bridge is enabled in Median App Studio and that the plugin is active. Also verify you are calling bridge functions after the page and bridge have fully loaded.isInitialized remains false after calling initialize
Ensure you passed a valid apiKey to initialize and that the call returned { success: true }. If initialization failed silently, check for network issues or an incorrect API key, then retry.
Push notifications are not arriving after sign-in
After setting user identity withsetEmail or setUserId, you must call registerPush to generate a new token associated with that user. Skipping this step means the push token is not linked to the newly identified user.
Notification links do not open inside the app
Deep Linking must be configured in your app for notification links to open directly in-app. Without Deep Linking, tapping a notification will open the device’s default browser instead.Permission dialog does not appear on Android
On Android 12 and below, push permission is granted automatically without a dialog. On Android 13+, the system permission dialog is required. Verify you are callingrequestPermission and testing on a device or emulator running Android 13 or higher to see the dialog.
Still having trouble?For issues related to Optimizely’s own configuration, permissions, or platform-specific behavior outside Median, refer to Optimizely’s integration documentation.