initialize method
Initialize the In-App Messages SDK
Must be called before using any other methods.
Parameters:
apiKey: Your PushPushGo API keyprojectId: Your PushPushGo project IDisProduction: Use production environment (default: true)isDebug: Enable debug logging (default: false)
Implementation
Future<void> initialize({
required String apiKey,
required String projectId,
bool isProduction = true,
bool isDebug = false,
}) async {
if (_isInitialized) {
log('PPGInAppMessages: Already initialized');
return;
}
try {
await InAppMessagesChannel.invokeMethod(
method: InAppMethod.initialize,
arguments: {
'apiKey': apiKey,
'projectId': projectId,
'isProduction': isProduction,
'isDebug': isDebug,
},
);
_isInitialized = true;
log('PPGInAppMessages: Initialized successfully');
// Process any buffered route from NavigatorObserver
if (_pendingRoute != null) {
await onRouteChanged(_pendingRoute!);
_pendingRoute = null;
}
} catch (e) {
log('PPGInAppMessages: Initialization failed - $e');
rethrow;
}
}