diff --git a/README.md b/README.md index ac3c40750..9f22dbe78 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,15 @@ If you get stuck while setting up your own environment, you can ask questions in ### Push Notifications -If you want to work on push notifications or use a development build with push notifications please go the server side code [HERE](https://github.com/home-assistant/mobile-apps-fcm-push) and deploy it to your firebase project. Once you have your androidV1 URL to the deployed service, exchange that for your local builds [PUSH_URL](https://github.com/home-assistant/android/blob/master/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt#L43). +If you want to work on push notifications or use a development build with push notifications, please go the server side code [HERE](https://github.com/home-assistant/mobile-apps-fcm-push) and deploy it to your firebase project. Once you have your androidV1 URL to the deployed service, set it in to your `${GRADLE_USER_HOME}/gradle.properties` file, e.g.: +```properties +homeAssistantAndroidPushUrl=https://mydomain.cloudfunctions.net/androidV1 +``` + +You can also define the rate limit function URL, e.g.: +```properties +homeAssistantAndroidRateLimitUrl=https://mydomain.cloudfunctions.net/checkRateLimits +``` ## App Flavors diff --git a/common/build.gradle.kts b/common/build.gradle.kts index f90a914c5..fcf71abe6 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -4,11 +4,16 @@ plugins { id("kotlin-kapt") } +val homeAssistantAndroidPushUrl: String by project +val homeAssistantAndroidRateLimitUrl: String by project + android { compileSdkVersion(Config.Android.compileSdk) defaultConfig { minSdkVersion(Config.Android.minSdk) + buildConfigField("String", "PUSH_URL", "\"$homeAssistantAndroidPushUrl\"") + buildConfigField("String", "RATE_LIMIT_URL", "\"$homeAssistantAndroidRateLimitUrl\"") } } diff --git a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt index 2bb091eb0..dd21d22a1 100644 --- a/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt +++ b/common/src/main/java/io/homeassistant/companion/android/common/data/integration/impl/IntegrationRepositoryImpl.kt @@ -1,6 +1,7 @@ package io.homeassistant.companion.android.common.data.integration.impl import android.util.Log +import io.homeassistant.companion.android.common.BuildConfig import io.homeassistant.companion.android.common.data.LocalStorage import io.homeassistant.companion.android.common.data.authentication.AuthenticationRepository import io.homeassistant.companion.android.common.data.integration.DeviceRegistration @@ -44,7 +45,7 @@ class IntegrationRepositoryImpl @Inject constructor( private const val APP_ID = "io.homeassistant.companion.android" private const val APP_NAME = "Home Assistant" private const val OS_NAME = "Android" - private const val PUSH_URL = "https://mobile-apps.home-assistant.io/api/sendPush/android/v1" + private const val PUSH_URL = BuildConfig.PUSH_URL private const val PREF_APP_VERSION = "app_version" private const val PREF_DEVICE_NAME = "device_name" @@ -57,7 +58,7 @@ class IntegrationRepositoryImpl @Inject constructor( private const val PREF_SESSION_EXPIRE = "session_expire" private const val PREF_SENSORS_REGISTERED = "sensors_registered" private const val TAG = "IntegrationRepository" - private const val RATE_LIMIT_URL = "https://mobile-apps.home-assistant.io/api/checkRateLimits" + private const val RATE_LIMIT_URL = BuildConfig.RATE_LIMIT_URL } override suspend fun registerDevice(deviceRegistration: DeviceRegistration) { diff --git a/gradle.properties b/gradle.properties index d45519ed4..aa2cd6ae8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,3 +15,8 @@ org.gradle.jvmargs=-Xmx1536m kotlin.code.style=official android.useAndroidX = true + +# The default API URL used by the Home Assistant Android application. +# Override these in your ${GRADLE_USER_HOME}/gradle.properties file if needed. +homeAssistantAndroidPushUrl=https://mobile-apps.home-assistant.io/api/sendPush/android/v1 +homeAssistantAndroidRateLimitUrl=https://mobile-apps.home-assistant.io/api/checkRateLimits