Introduction
In the rapidly evolving landscape of mobile app development, maximizing ad revenue while maintaining efficiency is paramount. Bidapp's innovative SDK, featuring advanced waterfall technology, empowers developers to sell their ad inventory to multiple networks at the best rates. To further enhance this capability, we have introduced a new plugin specifically designed for Kotlin Multiplatform, enabling seamless ad mediation across different platforms.
Understanding Kotlin Multiplatform
What is Kotlin Multiplatform?
Kotlin Multiplatform (KMP) is a feature of the Kotlin programming language developed by JetBrains. It allows developers to write shared code that can run on various platforms, including Android, iOS, Web, and Desktop. KMP aims to reduce the duplication of effort by enabling a single codebase for multiple targets, thereby streamlining the development process and enhancing productivity.
Key Features of Kotlin Multiplatform
- Code Reuse: Write common code once and share it across different platforms.
- Interoperability: Seamlessly integrate with existing codebases and libraries for each target platform.
- Modular Architecture: Separate platform-specific code from shared code, ensuring clean and maintainable project structures.
Google's Support for Kotlin Multiplatform
Google has recognized the potential of Kotlin Multiplatform, emphasizing its importance for the future of mobile development. According to a recent statement, Google is committed to supporting KMP due to its ability to streamline the development process and reduce time-to-market. The integration of KMP in major projects has shown significant improvements in code maintainability and developer productivity.
Benefits of Kotlin Multiplatform
1. Enhanced Development Speed
By leveraging a single codebase for multiple platforms, developers can significantly reduce the time required to build and maintain applications. This streamlined approach minimizes redundancy and allows for faster iterations and updates.
2. Consistent User Experience
KMP ensures a uniform user experience across different devices and operating systems. Developers can implement common business logic while customizing the UI and platform-specific features as needed, maintaining consistency in functionality and performance.
3. Cost Efficiency
Reducing the need for separate codebases for each platform translates to lower development and maintenance costs. Teams can allocate resources more effectively, focusing on innovation and feature enhancements rather than redundant coding tasks.
4. Robust Ecosystem
Kotlin Multiplatform is backed by a robust ecosystem of libraries and tools. JetBrains actively supports the platform, providing continuous updates and improvements, as well as extensive documentation and community resources.
Challenges of Kotlin Multiplatform
1. Learning Curve
Adopting Kotlin Multiplatform requires developers to familiarize themselves with its architecture and best practices. This initial learning phase might slow down development initially but pays off in the long run.
2. Platform-Specific Code
While KMP promotes code sharing, certain platform-specific features and UI elements still require separate implementations. Balancing shared and platform-specific code can be challenging and requires careful planning.
3. Library Compatibility
Not all libraries are fully compatible with KMP yet. Developers might need to find alternative libraries or implement custom solutions to bridge gaps, which can be time-consuming.
Integrating Bidapp Plugin with Kotlin Multiplatform
To leverage the full potential of Kotlin Multiplatform, we have developed the Bidapp plugin to streamline ad mediation. Here’s how you can integrate it into your KMP projects:
1. Adding the Plugin
Start by adding the Bidapp plugin to your project dependencies. This can be done in your shared module's build.gradle.kts
file:
kotlinCopy code
implementation("com.bidapp:bidapp-kotlin-multiplatform-plugin:1.0.0")
2. Configuring Mediation
Configure your mediation settings directly through the Bidapp platform:
- Register on the Bidapp platform and create a new account.
- Add Ad Networks to your project and configure their priorities and settings.
- Set Mediation Parameters to optimize ad delivery and maximize revenue.
3. Integrating in Shared Code
In your shared Kotlin code, initialize and configure the Bidapp plugin:
kotlinCopy code
import com.bidapp.Bidapp
import com.bidapp.BidappConfig
fun initBidapp() {
val config = BidappConfig.Builder()
.setAppId("YOUR_APP_ID")
.setAdUnitId("YOUR_AD_UNIT_ID")
.build()
Bidapp.initialize(config)
}
4. Platform-Specific Implementations
For platform-specific integrations, ensure that you implement any required setup in the respective targets (Android, iOS):
- Android: Add necessary permissions and services in the
AndroidManifest.xml
. - iOS: Configure the app delegate to initialize the Bidapp SDK.
5. Setting up Advertising Display
- Go to the Bidapp dashboard, add a new application, and connect advertising networks.
- In the build.gradle.kts file of the shared module, configure the adapters according to the settings of the advertising networks on the Bidapp dashboard.
Example for Android:
kotlinCopy code
plugins {
android {
//...
}
dependencies {
implementation ("io.bidapp.networks:unity:latest")
implementation ("io.bidapp.networks:liftoff:latest")
implementation ("io.bidapp.networks:admob:latest")
}
}
Example for iOS:
kotlinCopy code
plugins {
cocoapods {
//...
pod("bidapp/AdMob")
pod("bidapp/Unity")
pod("bidapp/Liftoff")
//...
}
}
Set in the Settings file located in the shared module the pubId for Android and iOS. Additionally, you can enable or disable:
kotlinCopy code
const val pubId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
const val isEnableTestMode = true
const val isEnableLogging = true
Conclusion
Kotlin Multiplatform represents a significant step forward in mobile app development, offering code reuse, consistency, and cost efficiency. The Bidapp plugin seamlessly integrates with KMP, enabling developers to efficiently manage ad mediation across multiple platforms. By leveraging KMP and the Bidapp plugin, developers can maximize their ad revenue while maintaining a streamlined and efficient development process.
For more detailed integration instructions, visit our GitHub page.