-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
After the user logs in, you need to provide the user's uid to the sdk, so that the sdk can use it when sending records.
[OmniSegment loginWithUid:@"Your UID"];
OmniSegment.login(uid: "uid")
When the user logs out:
[OmniSegment logout];
OmniSegment.logout()
If the user has logged-in and you need to set the uid without login event
[OmniSegment setUidWithUid:@"Your UID"];
OmniSegment.setUid(uid: "uid")
If you want to reset uid without logout event
[OmniSegment clearUid];
OmniSegment.clearUid()
To customize the document location reported in WebView events, use the setWebViewLocation method provided by OmniSegment SDK. This allows for overriding the default document location with a specified string.
[OmniSegment setWebViewLocation:@"location"];
OmniSegment.setWebViewLocation("location")
After setting a custom document location, you may wish to revert to using the default document location in WebView events. Achieve this by invoking the resetWebViewLocation method.
[OmniSegment resetWebViewLocation];
OmniSegment.resetWebViewLocation()
To use your own callback function to handle the redirect url behavior on popup button
[OmniSegment setPopupRedirectCallback:^(NSString *url) {
// Handle redirect URL
NSLog(@"Redirect to: %@", url);
}];
OmniSegment.setPopupRedirectCallback(_ callback: @escaping (String) -> Void)
To ensure the OmniSegment SDK properly manages pop-up displays, it's essential to update the current page context. Each time a user navigates to a new page within your app, invoke the following method with a predefined page_key:
[OmniSegment setCurrentPage:@"Your Page Key"];
OmniSegment.setCurrentPage("page_key")
This page_key serves as an identifier for the SDK to make decisions about displaying pop-ups. It should be defined in advance and triggered upon each page entry. The page_key is flexible and can be in either English or Chinese.
Important
The implementation of this function is crucial for the app's pop-up triggering mechanism. Ensure that setCurrentPage is called every time a user enters a new page to maintain accurate and effective pop-up management.
Note: Before using this feature, you need to integrate Firebase SDK into your project and enable Google Firebase services for your app.
You need to provide the user's Firebase Cloud Messaging Token to the sdk, so that the sdk can use it when sending records and push notifications.
[OmniSegment setFCMToken:@"fake-fcm-token-for-testing"];
import Firebase
let fcmToken = Messaging.messaging().fcmToken
OmniSegment.setFCMToken(fcmToken)
After setting the FCM Token with setFCMToken, it's important to trigger an appOpen() event to send this information to the OmniSegment system. This ensures the SDK is fully configured to utilize the FCM Token for push notifications and data recording.
Important
The appOpen() event is essential for completing the setup. Make sure to call it following the FCM Token configuration to ensure the OmniSegment system receives the necessary information.
To enable debug logs, add the following code to your application delegate (or scene delegate):
[OmniSegment enableDebugLogs:YES];
[OmniSegment enableDebugLogs:NO];
// 預設 true
OmniSegment.enableDebugLogs()
OmniSegment.enableDebugLogs(true)
OmniSegment.enableDebugLogs(false)
Note
Ensure “Run” Uses Debug Configuration Make sure the Run configuration is set to Debug in Xcode:
- Open Xcode.
- Go to Product → Scheme → Edit Scheme.
- In the Run section, ensure that Build Configuration is set to Debug.
- Check that the Debug executable option is enabled.
- Confirm that your Build Settings include a DEBUG preprocessor macro.

To ensure that events within webview pages are tracked by the SDK, you need to add the OmniSegment content controller to your WKWebViewConfiguration.
[OSGWebViewConfigurationExtension addOmniSegmentContentController:configuration];
func makeUIView(context: Context) -> WKWebView {
let webViewConfiguration = WKWebViewConfiguration()
webViewConfiguration.addOmniSegmentContentController()
let webView = WKWebView(frame: .zero, configuration: webViewConfiguration)
return webView
}
This integration ensures proper event tracking within webview pages through the SDK.