Handle bitchat://verify deep links

This commit is contained in:
yet300
2025-12-31 18:49:04 +04:00
parent 0c99012208
commit 0e75e3856f
2 changed files with 20 additions and 0 deletions
+6
View File
@@ -86,6 +86,12 @@
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="bitchat" android:host="verify" />
</intent-filter>
</activity> </activity>
<!-- Persistent foreground service to run the mesh in background --> <!-- Persistent foreground service to run the mesh in background -->
@@ -40,6 +40,7 @@ import com.bitchat.android.ui.ChatViewModel
import com.bitchat.android.ui.OrientationAwareActivity import com.bitchat.android.ui.OrientationAwareActivity
import com.bitchat.android.ui.theme.BitchatTheme import com.bitchat.android.ui.theme.BitchatTheme
import com.bitchat.android.nostr.PoWPreferenceManager import com.bitchat.android.nostr.PoWPreferenceManager
import com.bitchat.android.services.VerificationService
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@@ -624,6 +625,7 @@ class MainActivity : OrientationAwareActivity() {
// Handle any notification intent // Handle any notification intent
handleNotificationIntent(intent) handleNotificationIntent(intent)
handleVerificationIntent(intent)
// Small delay to ensure mesh service is fully initialized // Small delay to ensure mesh service is fully initialized
delay(500) delay(500)
@@ -650,6 +652,7 @@ class MainActivity : OrientationAwareActivity() {
// Handle notification intents when app is already running // Handle notification intents when app is already running
if (mainViewModel.onboardingState.value == OnboardingState.COMPLETE) { if (mainViewModel.onboardingState.value == OnboardingState.COMPLETE) {
handleNotificationIntent(intent) handleNotificationIntent(intent)
handleVerificationIntent(intent)
} }
} }
@@ -755,6 +758,17 @@ class MainActivity : OrientationAwareActivity() {
} }
} }
private fun handleVerificationIntent(intent: Intent) {
val uri = intent.data ?: return
if (uri.scheme != "bitchat" || uri.host != "verify") return
chatViewModel.showVerificationSheet()
val qr = VerificationService.verifyScannedQR(uri.toString())
if (qr != null) {
chatViewModel.beginQRVerification(qr)
}
}
override fun onDestroy() { override fun onDestroy() {
super.onDestroy() super.onDestroy()