blux_flutter 0.0.2
blux_flutter: ^0.0.2 copied to clipboard
BlucClient Flutter SDK
Blux Flutter SDK Integration Guide #
Installation #
Using pub #
Add the Blux Flutter SDK to your project's pubspec.yaml file:
dependencies:
blux_flutter: ^0.0.2
CocoaPods (iOS-specific) #
After adding the SDK, navigate to the ios directory and run the following command to install iOS dependencies:
cd ios
pod install
iOS Project Setup #
(1) Enable Push Notifications #
Enable push notifications by navigating to your Target's Signing & Capabilities, clicking the "+" button in the top-left corner, and selecting Push Notifications.
[Document image](2) Create a Notification Service Extension #
- In Xcode, go to File > New > Target and select Notification Service Extension.
- Enter an appropriate Product Name and click Finish. We recommend using Swift as the language.
- When prompted with the scheme activation dialog, click Cancel to avoid enabling a separate scheme.
(3) Set Minimum Deployment Version #
Ensure the Minimum Deployment Version for the Notification Service Extension matches the deployment version of your main app's Target.
[Document image](4) Modify the Podfile #
Open the Podfile in the ios directory and add the following lines:
# Add the following at the bottom of the file.
# Use the Product Name you provided earlier for the Extension.
target 'BluxNotificationServiceExtension' do
pod 'BluxClient'
end
Then, run the following command to complete the SDK installation:
cd ios
pod install
Finally, open Xcode and modify the newly created Extension file. Replace the automatically generated code with the following:
import BluxClient
class NotificationService: BluxNotificationServiceExtension {
}
Initialize #
To initialize the SDK, provide your Client ID and API Key:
import 'package:blux_flutter/blux_flutter_api_stage.dart';
import 'package:blux_flutter/blux_flutter.dart';
// somewhere in class
final bluxClient = BluxClient();
// ...
bluxClient.initialize(
'{client_id}',
'{blux_api_key}',
true
);
// ...
setLogLevel #
Enable logging for debugging integration-related issues. This method can be called before initializing the SDK. Supported log levels include:
'debug''log''warning''error''fatal'
Example:
bluxClient.setLogLevel('debug');
User Management #
signIn #
Sign in a user by passing a unique user ID. Users with the same UserId are treated as the same user by the Blux service.
bluxClient.signIn('USER_ID');
signOut #
Call this method when a user logs out of your service. It helps improve user identification accuracy.
bluxClient.signOut();
Sending Events #
Product Detail View Event #
Track when a user views a product detail page or expresses interest in an item.
bluxClient.sendEvent(
[
AddProductDetailViewEvent(
itemId: 'ITEM_ID',
)
]
);
Like Event #
Track when a user likes or favorites a product or video.
bluxClient.sendEvent([
AddLikeEvent(
itemId: 'ITEM_ID',
)
]);
Add to Cart Event #
Track when a user adds a product to their shopping cart.
bluxClient.sendEvent([
AddCartaddEvent({
itemId: 'ITEM_ID',
})
]);
Purchase Event #
Track when a user purchases a product. Provide the price as the purchase price at the time of the transaction.
Single Product Purchase Example
If a user purchases multiple quantities of the same product, set the price to the total revenue (e.g., price × quantity).
BluxClient.sendEvent([
AddPurchaseEvent(
itemId: 'ITEM_ID',
price: 1000,
)
]);
Multiple Products Purchase Example
If multiple products are purchased, create an AddPurchaseEvent object for each product and send them as a list:
BluxClient.sendEvent([
AddPurchaseEvent(
itemId: 'ITEM_ID_1',
price: 1000,
),
AddPurchaseEvent(
itemId: 'ITEM_ID_2',
price: 2000,
),
]);