allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
implementation 'com.github.ahmadidrees347:Firebase-BOM-Lib:firebase-bom-version'
Do not forget to add internet permission in manifest if already not present
<uses-permission android:name="android.permission.INTERNET" />
Create Firebase project, add you application ID init, download your google-services.json file and place it in app folder.
val fcm = FirebaseFCM(this)
fcm.initializeFCM("/topics/$packageName")
val fbAnalytics = FirebaseAnalytics(this)
Send eventName & eventStatus init:
fbAnalytics.sendEventAnalytics(eventName, eventStatus)
private val remoteConfig = RemoteConfigData("topicName")
var remoteAdSettings = RemoteModel()
Make your Custom model the way you want to receive model, call getRemoteConfig() to get data:
remoteConfig.getRemoteConfig(context) {
it?.let {
val remoteJson = Gson().toJson(it)
if (!remoteJson.isNullOrEmpty())
remoteAdSettings = Gson().fromJson(remoteJson, RemoteModel::class.java)
Log.e("RemoteConfigNew*", "$remoteAdSettings")
if (remoteAdSettings.splashNative.value == "on") {
//Load Splash Native AD
}
}
}
Data Class to receive the response:
@Keep
data class RemoteModel(
@SerializedName("splashNative")
val splashNative: RemoteDetailModel = RemoteDetailModel()
) {
override fun toString(): String {
return "splashNative : $splashNative"
}
}
Copyright (C) 2022
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.