diff --git a/presentation/build.gradle b/presentation/build.gradle index 4a1b4e52c..6b6834c42 100644 --- a/presentation/build.gradle +++ b/presentation/build.gradle @@ -32,8 +32,8 @@ android { applicationId "org.traccar.gateway" minSdkVersion 21 targetSdkVersion 29 - versionCode 6 - versionName "4.0" + versionCode 7 + versionName "4.1" setProperty("archivesBaseName", "traccar-v${versionName}") testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/gateway/GatewayMessagingService.kt b/presentation/src/main/java/com/moez/QKSMS/feature/gateway/GatewayMessagingService.kt index 3325ad989..cf47d8a70 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/gateway/GatewayMessagingService.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/gateway/GatewayMessagingService.kt @@ -1,6 +1,8 @@ package com.moez.QKSMS.feature.gateway import android.annotation.SuppressLint +import android.os.Handler +import android.os.Looper import android.telephony.SmsManager import android.widget.Toast import com.google.firebase.messaging.FirebaseMessagingService @@ -9,6 +11,8 @@ import com.google.firebase.messaging.RemoteMessage @SuppressLint("MissingFirebaseInstanceTokenRefresh") class GatewayMessagingService : FirebaseMessagingService() { + private val handler = Handler(Looper.getMainLooper()) + override fun onMessageReceived(remoteMessage: RemoteMessage) { val phone = remoteMessage.data["phone"] val message = remoteMessage.data["message"] @@ -16,7 +20,9 @@ class GatewayMessagingService : FirebaseMessagingService() { try { SmsManager.getDefault().sendTextMessage(phone, null, message, null, null) } catch (e: Exception) { - Toast.makeText(this, e.message, Toast.LENGTH_LONG).show() + handler.post { + Toast.makeText(this, e.message, Toast.LENGTH_LONG).show() + } } } }