Skip to content

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

SalesforceMobileInterfaces

A collection of Android interface libraries designed for mobile plugins that integrate with Salesforce mobile applications. This library provides standardized interfaces for common mobile operations like networking, logging, navigation, user management, and caching.

Overview

SalesforceMobileInterfaces serves as a bridge between Salesforce mobile applications and their plugins, providing a unified set of interfaces that enable plugins to access host application capabilities while maintaining clean separation of concerns.

Features

  • 🌐 Network Interface: Standardized networking with authentication and context awareness
  • 📝 Logging Interface: Structured logging with configurable severity levels
  • 👤 User Management: User, organization, and community data models
  • 🧭 Navigation Interface: Navigate to Salesforce records, objects, and URLs
  • 💾 Cache Interface: Async data caching with user-scoped operations

Requirements

  • Android API level 24+
  • Kotlin 1.8+
  • Android Studio Arctic Fox (2020.3.1) or newer

Installation

Gradle

Add the following to your project's settings.gradle.kts file:

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
    }
}

Modules

SalesforceNetwork

Provides networking capabilities with built-in authentication and context management.

import com.salesforce.android.mobile.interfaces.network.Network
import com.salesforce.android.mobile.interfaces.network.NetworkRequest
import com.salesforce.android.mobile.interfaces.network.NetworkResponse

// Implement the Network interface in your host application
class MyNetworkService : Network {
    override suspend fun perform(request: NetworkRequest): NetworkResponse {
        // Implementation with authentication, retries, etc.
        return NetworkResponse(
            request = request,
            statusCode = 200,
            headers = mapOf("Content-Type" to listOf("application/json")),
            body = "response data".toByteArray()
        )
    }
}

SalesforceLogging

Structured logging interface with error, warning, and info levels.

import com.salesforce.android.mobile.interfaces.logging.Logger

// Implement logging in your host application
class MyLogger : Logger {
    override fun e(message: String) {
        // Log error message
    }

    override fun e(message: String, exception: Throwable) {
        // Log error message with exception
    }

    override fun w(message: String) {
        // Log warning message
    }

    override fun w(message: String, exception: Throwable) {
        // Log warning message with exception
    }

    override fun i(message: String) {
        // Log info message
    }

    override fun i(message: String, exception: Throwable) {
        // Log info message with exception
    }
}

SalesforceUser

Data models for Salesforce users, organizations, and communities.

import com.salesforce.android.mobile.interfaces.user.User

val user = User(
    userId = "005XXXXXXXXXXXXXXXXX",
    org = myOrg,
    username = "user@example.com",
    displayName = "John Doe",
    firstName = "John",
    avatarUrl = "https://example.com/avatar.jpg"
)

SalesforceNavigation

Navigation interface for moving between Salesforce destinations.

import com.salesforce.android.mobile.interfaces.navigation.Navigation

// Implement navigation in your host application
class MyNavigationService : Navigation {
    override fun navigateTo(destination: Destination) {
        // Navigate to records, object homes, URLs, etc.
    }
    
    override fun navigateTo(destination: Destination, replace: Boolean) {
        // Navigate with replacement control
    }
}

SalesforceCache

Async caching interface for user-scoped data storage.

import com.salesforce.android.mobile.interfaces.cache.Cache

// Implement caching in your host application
class MyCacheService : Cache {
    override suspend fun save(data: ByteArray, key: String) {
        // Save data to cache
    }
    
    override suspend fun load(key: String): ByteArray? {
        // Load data from cache
        return null
    }
    
    override suspend fun remove(key: String) {
        // Remove specific cache entry
    }
    
    override suspend fun removeAll() {
        // Clear all cache data
    }
}

Usage

These interfaces are designed to be implemented by host applications and passed to plugins. Here's a typical integration pattern:

// In your host application
val networkService = MyNetworkService()
val logger = MyLogger()
val navigation = MyNavigationService()
val cache = MyCacheService()

// Pass to your plugin
val plugin = SomePlugin(
    network = networkService,
    logger = logger,
    navigation = navigation,
    cache = cache
)

Development

Building the Project

  1. Clone the repository
  2. Open the project in Android Studio
  3. Sync the project with Gradle files
  4. Build the project using Gradle
./gradlew build

Running Tests

./gradlew test

Contributing

Please read our contribution guidelines and ensure all tests pass before submitting pull requests.

License

Copyright (c) 2011-present, salesforce.com, inc. All rights reserved.

See LICENSE.txt for full license terms.

About

No description, website, or topics provided.

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages