mobiqo_flutter 1.0.0
mobiqo_flutter: ^1.0.0 copied to clipboard
Mobiqo SDK for Flutter. Integrate with Mobiqo for user analytics, predictions, and insights.
Mobiqo Flutter SDK #
⚠️ THIS PLUGIN HAS TO BE USED ALONG WITH THE ANALYTICS SERVICE MOBIQO ⚠️
👉 CREATE AN ACCOUNT HERE: https://getmobiqo.com?utm_source=npm
The Mobiqo Flutter SDK allows you to integrate your Flutter application with the Mobiqo user intelligence platform. Track events, manage user data, and gain insights into user behavior.
Features #
- User identification and session tracking
- Custom event tracking
- Automatic heartbeat for session management
- Retrieval of user analytics and predictions
Getting Started #
Prerequisites #
- Flutter version
1.17.0or higher. - A Mobiqo account and API key.
Installation #
-
Add this to your package's
pubspec.yamlfile:dependencies: mobiqo_flutter: ^1.0.0 -
Install packages from the command line:
flutter pub get
Usage #
Import the package:
import 'package:mobiqo_flutter/mobiqo_flutter.dart';
Initialize the Mobiqo:
final mobiqo = Mobiqo();
void main() async {
// Important: Ensure Flutter bindings are initialized if you are calling init before runApp
WidgetsFlutterBinding.ensureInitialized();
await mobiqo.init(mobiqoKey: 'YOUR_MOBIqo_API_KEY');
runApp(MyApp());
}
Sync a user:
try {
SyncUserResponse? response = await mobiqo.syncUser(
revenueCatUserId: 'your_user_id_from_revenuecat_or_internal_id',
includeAdvancedAnalysis: false,
additionalData: AdditionalData(
userId: 'user-123',
userName: 'John Doe',
userEmail: 'user@example.com',
referrer: 'google',
),
);
if (response != null) {
print('User synced: ${response.appUser.mobiqoUsername}');
print('Purchase intent: ${response.statistics.purchaseIntent}');
}
} catch (e) {
print('Error syncing user: $e');
}
Track an event:
try {
await mobiqo.trackEvent(
'button_pressed',
MobiqoEvent.click,
additionalData: {'button_name': 'subscribe_now', 'page': 'homepage'},
);
print('Event tracked!');
} catch (e) {
print('Error tracking event: $e');
}
Update user data:
try {
await mobiqo.updateUser(
revenueCatUserId: 'your_user_id_from_revenuecat_or_internal_id',
additionalData: AdditionalData(
userId: 'user-123',
userName: 'John Doe Updated',
userEmail: 'newemail@example.com',
referrer: 'facebook',
),
);
print('User updated!');
} catch (e) {
print('Error updating user: $e');
}
Get user info:
try {
GetUserInfoResponse? userInfo = await mobiqo.getUserInfo(
revenueCatUserId: 'your_user_id_from_revenuecat_or_internal_id',
includeAdvancedAnalysis: true,
);
if (userInfo != null) {
print('User OS: ${userInfo.appUser.os}');
}
} catch (e) {
print('Error getting user info: $e');
}
Dispose the service when no longer needed (e.g., in your main app widget's dispose method):
@override
void dispose() {
mobiqo.dispose(); // Clean up heartbeat timer
super.dispose();
}
Contributing #
Contributions are welcome! Please feel free to submit a pull request.
License #
This SDK is released under the MIT License. See the LICENSE file for details.