### Verify Cordova Plugin Installation Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Command to list installed Cordova plugins and verify that the Condo plugin has been successfully added to the project. It shows the plugin name and version. ```bash cordova plugin list # Expected output: # cordova-plugin-condo 0.0.2 "Condo" ``` -------------------------------- ### Get Installation ID - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves a unique identifier for the application installation. This ID can be used for analytics, tracking, or device-specific operations. ```javascript var installationId = cordova.plugins.condo.hostApplication.installationID(); console.log('Installation ID:', installationId); // Returns: "b8f73d1c-158a-4507-8b9d-379220c49e3b" // Use for analytics or device tracking analytics.setInstallationId(installationId); ``` -------------------------------- ### Install Cordova Plugin Condo Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Command to add the Condo plugin to a Cordova project using its GitHub repository URL. This sets up the necessary native bridges for the plugin's functionality. ```bash cordova plugin add https://github.com/open-condo-software/mobile_cordova_plugin_condo ``` -------------------------------- ### Access Condo Plugin in JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Example of how to access the Condo plugin's methods in JavaScript after the 'deviceready' event has fired. It logs the plugin object to the console, confirming its availability. ```javascript // Plugin is available at cordova.plugins.condo after deviceready event document.addEventListener('deviceready', function() { console.log('Condo plugin available:', cordova.plugins.condo); }, false); ``` -------------------------------- ### Get Launch Context Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves the launch context of the application, which may include deep link data or other launch parameters. The context is returned as a JSON string that needs to be parsed. ```javascript cordova.plugins.condo.getLaunchContext( function(context) { var launchData = JSON.parse(context); console.log('Launch context:', launchData); // Returns: { test: 1 } in stub mode // Real implementation provides deep link data and launch parameters if (launchData.deepLink) { // Handle deep link navigation navigateToScreen(launchData.deepLink); } }, function(error) { console.error('Failed to get launch context:', error); } ); ``` -------------------------------- ### Get Base URL - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves the base URL for API requests from the host application. This is essential for making network calls to the correct backend services. ```javascript var baseURL = cordova.plugins.condo.hostApplication.baseURL(); console.log('API base URL:', baseURL); // Returns: "https://condo.d.doma.ai" // Use for API requests fetch(baseURL + '/api/v1/residents/current') .then(response => response.json()) .then(data => console.log('API response:', data)); ``` -------------------------------- ### Get Device Locale - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves the locale setting of the device. This information is crucial for internationalization and localization of the application's content. ```javascript var locale = cordova.plugins.condo.hostApplication.locale(); console.log('Device locale:', locale); // Returns: "ru-RU" // Use for localization i18n.setLocale(locale); moment.locale(locale.split('-')[0]); // "ru" ``` -------------------------------- ### Get Device ID - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves a unique identifier for the device. This can be used for device-specific configurations, caching, or operations that require hardware identification. ```javascript var deviceId = cordova.plugins.condo.hostApplication.deviceID(); console.log('Device ID:', deviceId); // Returns: "ff3654eb-033b-45a0-b7db-c519d70159ba" // Use for device-specific operations cache.setKey('device_' + deviceId, userData); ``` -------------------------------- ### Get Current Resident Information Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Retrieves the currently logged-in resident's information. The callback provides a comprehensive resident object including ID, unit details, property information, and organization data. ```javascript cordova.plugins.condo.getCurrentResident( function(resident) { console.log('Resident data:', resident); // Returns complete resident object: // { // id: "b7d77f24-9ae6-4f78-9915-6645175e50d1", // unitName: "1", // unitType: "flat", // property: { // id: "94e2f48c-24b3-4f0d-bc9d-74ab863805a1", // name: "Лермонтова, д 7" // }, // organization: { // id: "9c2f63c8-9288-4942-b24f-e11da26f6bec", // name: "Тестирую API", // tin: "6671095805" // }, // organizationFeatures: { // hasBillingData: false, // hasMeters: true // }, // paymentCategories: [ // { id: "1", categoryName: "Квартплата" }, // { id: "9", categoryName: "Капремонт" } // ], // address: "г Новосибирск, ул Лермонтова, д 7" // } // Access specific fields console.log('Unit:', resident.unitName); console.log('Property:', resident.property.name); console.log('Organization:', resident.organization.name); }, function(error) { console.error('Failed to get resident:', error); } ); ``` -------------------------------- ### Initialize Condo App with Authentication and Data Flow (JavaScript) Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt This JavaScript code snippet demonstrates the full authentication and data flow for a Cordova application using the Condo plugin. It configures the app, handles deep links, authenticates with OAuth, exchanges the authorization code for an access token, loads resident data, and initializes the application UI. It also sets up navigation history management and handles back button events. ```javascript document.addEventListener('deviceready', onDeviceReady, false); function onDeviceReady() { var condo = cordova.plugins.condo; // Configure app based on host environment var config = { baseURL: condo.hostApplication.baseURL(), locale: condo.hostApplication.locale(), deviceId: condo.hostApplication.deviceID(), installationId: condo.hostApplication.installationID(), isDemoMode: condo.hostApplication.isDemoEnvironment() }; console.log('App config:', config); // Get launch context for deep linking condo.getLaunchContext( function(context) { var launchData = JSON.parse(context); handleDeepLink(launchData); }, function(error) { console.error('Launch context error:', error); } ); // Authenticate with OAuth condo.requestAuthorization( 'mini-app-client-id', 'mini-app-secret', function(authCode) { console.log('Auth code received:', authCode); // Exchange code for access token exchangeCodeForToken(authCode, config.baseURL) .then(function(accessToken) { // Fetch current resident data return loadResidentData(condo, accessToken); }) .then(function(resident) { // Initialize app with resident data initializeApp(resident, config); }) .catch(function(error) { console.error('Initialization failed:', error); }); }, function(error) { console.error('Authorization failed:', error); showAuthError(); } ); // Setup navigation history setupHistoryManagement(condo); } function exchangeCodeForToken(code, baseURL) { return fetch(baseURL + '/oauth/token', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ code: code }) }).then(response => response.json()) .then(data => data.accessToken); } function loadResidentData(condo, accessToken) { return new Promise(function(resolve, reject) { condo.getCurrentResident( function(resident) { resident.accessToken = accessToken; resolve(resident); }, reject ); }); } function initializeApp(resident, config) { console.log('Initializing app for resident:', resident.id); console.log('Property:', resident.property.name); console.log('Organization:', resident.organization.name); // Setup UI based on organization features if (resident.organizationFeatures.hasMeters) { enableMetersSection(); } if (resident.organizationFeatures.hasBillingData) { enablePaymentsSection(resident.paymentCategories); } // Localize UI setAppLocale(config.locale); // Track analytics analytics.identify(resident.id, { organizationId: resident.organization.id, propertyId: resident.property.id, deviceId: config.deviceId }); } function setupHistoryManagement(condo) { // Handle back button document.addEventListener('backbutton', function(e) { e.preventDefault(); condo.history.back( function() { console.log('Back navigation succeeded'); }, function(error) { // No history - close app condo.closeApplication( function() { console.log('App closed'); }, function(err) { console.error('Close failed:', err); } ); } ); }, false); // Track page navigation window.addEventListener('hashchange', function() { var currentPage = location.hash.substring(1); var state = { page: currentPage, timestamp: Date.now() }; condo.history.pushState( state, currentPage, function() { console.log('State pushed:', currentPage); }, function(err) { console.error('Push state error:', err); } ); }); } function handleDeepLink(launchData) { if (launchData.action === 'open_payment') { navigateToPayment(launchData.paymentId); } else if (launchData.action === 'open_meter') { navigateToMeter(launchData.meterId); } } ``` -------------------------------- ### Open URL with Fallback - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Attempts to open a given URL, falling back to a secondary URL if the primary one fails or is not handled. This is useful for deep linking and providing alternative access methods. ```javascript cordova.plugins.condo.openURLWithFallback( 'myapp://custom-scheme/action', 'https://example.com/fallback', function() { console.log('URL opened successfully'); // iOS: Opens URL with UIApplication openURL // Falls back to second URL if first fails }, function(error) { console.error('Failed to open URL:', error); } ); // Example: Open WhatsApp or web fallback cordova.plugins.condo.openURLWithFallback( 'whatsapp://send?phone=+79001234567&text=Hello', 'https://wa.me/79001234567?text=Hello', function() { console.log('WhatsApp or web opened'); }, function(error) { console.error('URL opening failed:', error); } ); ``` -------------------------------- ### Navigate History Steps - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Navigates forward or backward in the browser history by a specified number of steps. Accepts positive integers for forward navigation and negative for backward. ```javascript // Go back 2 steps cordova.plugins.condo.history.go( -2, function() { console.log('Navigated 2 steps back'); }, function(error) { console.error('Navigation failed:', error); } ); // Go forward 1 step cordova.plugins.condo.history.go( 1, function() { console.log('Navigated 1 step forward'); }, function(error) { console.error('Navigation failed:', error); } ); ``` -------------------------------- ### Request Server Authorization by URL Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Requests authorization directly from a server URL, handling the OAuth flow via a web view. It accepts a URL and optional parameters, returning authorization data like access and refresh tokens. ```javascript cordova.plugins.condo.requestServerAuthorizationByUrl( 'https://api.example.com/oauth/authorize?client_id=xyz', null, // Reserved for custom parameters function(result) { console.log('Authorization result:', result); // Returns dictionary with authorization data: // {accessToken: "...", refreshToken: "...", expiresIn: 3600 } }, function(error) { console.error('Authorization by URL failed:', error); } ); ``` -------------------------------- ### Request OAuth Authorization Code Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Initiates an OAuth authorization flow by requesting an authorization code. This function requires client ID and secret and returns the code upon success or an error. ```javascript cordova.plugins.condo.requestAuthorization( 'your-client-id', 'your-client-secret', function(authorizationCode) { console.log('Authorization successful:', authorizationCode); // Returns: "test_code_for_auth" in stub mode // Use this code to obtain access tokens from your server }, function(error) { console.error('Authorization failed:', error); } ); ``` -------------------------------- ### Check Demo Environment - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Checks if the application is running in a demo environment. This property is typically hardcoded in stub plugins and can be used to enable specific features for testing. ```javascript var isDemoEnv = cordova.plugins.condo.hostApplication.isDemoEnvironment(); console.log('Is demo environment:', isDemoEnv); // Returns: true (hardcoded in stub plugin) if (isDemoEnv) { console.log('Running in demo mode'); // Enable debug features or test data } ``` -------------------------------- ### Navigate Back in History Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Performs a back navigation action within the application's history. This function is useful for navigating through views or screens managed by the Cordova application. ```javascript cordova.plugins.condo.history.back( function() { console.log('Navigated back successfully'); }, function(error) { console.error('Navigation back failed:', error); // Error may indicate no previous history entry } ); ``` -------------------------------- ### Close Application Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Command to close the entire mobile application. This function triggers the native closeApp method on iOS and performs a standard app closure on Android. ```javascript cordova.plugins.condo.closeApplication( function() { console.log('Application closed successfully'); // iOS: Calls native host closeApp method // Android: Standard app closure }, function(error) { console.error('Failed to close application:', error); } ); ``` -------------------------------- ### Push New State to History - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Pushes a new state object to the browser history. This function allows for adding new entries to the navigation history, which can be later retrieved. ```javascript var state = { page: 'profile', userId: '12345' }; cordova.plugins.condo.history.pushState( state, 'User Profile', function() { console.log('History state pushed'); // State can be retrieved when navigating back }, function(error) { console.error('Push state failed:', error); } ); ``` -------------------------------- ### Replace Current History State - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Replaces the current history state with a new one. This is useful for updating the current view's state without adding a new entry to the history stack. ```javascript var state = { page: 'dashboard', tab: 'payments' }; cordova.plugins.condo.history.replaceState( state, 'Dashboard', function() { console.log('History state replaced'); // Current state replaced without adding new entry }, function(error) { console.error('Replace state failed:', error); } ); ``` -------------------------------- ### Enable/Disable Text Inputs - JavaScript Source: https://context7.com/open-condo-software/mobile_cordova_plugin_condo/llms.txt Controls the enabled state of text inputs within the application. This can be used to create read-only modes or disable input during processing, with support for iOS 14.5+. ```javascript // Disable text interaction (iOS 14.5+) cordova.plugins.condo.setInputsEnabled( false, function() { console.log('Text inputs disabled'); // Useful for read-only mode or during processing }, function(error) { console.error('Failed to disable inputs:', error); } ); // Re-enable text interaction cordova.plugins.condo.setInputsEnabled( true, function() { console.log('Text inputs enabled'); }, function(error) { console.error('Failed to enable inputs:', error); } ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.