package com.suno.android.push import android.app.NotificationChannel import android.app.NotificationManager import android.content.Context import com.braze.Braze import com.braze.configuration.BrazeConfig import com.suno.android.R import com.suno.android.common_core_utils.environment.EnvironmentConstantsProvider import dagger.Binds import dagger.Module import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent import javax.inject.Singleton private const val CHANNEL_ID = "braze_push_notifications" private const val CHANNEL_NAME = "Push Notifications" private const val CHANNEL_DESCRIPTION = "App notifications" private const val CUSTOM_ENDPOINT = "sdk.iad-07.braze.com" private const val SESSION_TIMEOUT_SECONDS = 60 private const val GREAT_NETWORK_INTERVAL_SECONDS = 10 private const val FIREBASE_SENDER_ID = "985036759634" @Module @InstallIn(SingletonComponent::class) interface BrazeModule { @Binds @Singleton fun bindBrazeManager( impl: BrazeManagerImpl, ): BrazeManager companion object { @Provides @Singleton fun provideBraze( @ApplicationContext context: Context, ): Braze = Braze.getInstance(context) @Provides @Singleton fun provideBrazeConfig( @ApplicationContext context: Context, environmentConstantsProvider: EnvironmentConstantsProvider, ): BrazeConfig { val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val channel = NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH).apply { enableLights(true) enableVibration(true) setShowBadge(true) } notificationManager.createNotificationChannel(channel) return BrazeConfig.Builder() .setDefaultNotificationChannelName(CHANNEL_NAME) .setDefaultNotificationChannelDescription(CHANNEL_DESCRIPTION) .setApiKey(environmentConstantsProvider.environmentConstants.brazeApiKey) .setCustomEndpoint(CUSTOM_ENDPOINT) .setSessionTimeout(SESSION_TIMEOUT_SECONDS) .setHandlePushDeepLinksAutomatically(true) .setGreatNetworkDataFlushInterval(GREAT_NETWORK_INTERVAL_SECONDS) .setIsFirebaseCloudMessagingRegistrationEnabled(true) .setIsLocationCollectionEnabled(true) .setIsPushWakeScreenForNotificationEnabled(true) .setFirebaseCloudMessagingSenderIdKey(FIREBASE_SENDER_ID) .setDefaultNotificationAccentColor(0xFF0E0808.toInt()) .setSmallNotificationIcon(context.resources.getResourceEntryName(R.drawable.small_notification_icon)) .build() } } }