Skip to content

Commit de3e696

Browse files
authored
chore: Migrate to expo-notifications (#6846)
1 parent 59e873a commit de3e696

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1840
-1046
lines changed

android/app/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ android {
9393
versionName "4.68.0"
9494
vectorDrawables.useSupportLibrary = true
9595
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
96-
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below!
9796
resValue "string", "rn_config_reader_custom_package", "chat.rocket.reactnative"
9897
}
9998

@@ -144,7 +143,6 @@ dependencies {
144143
implementation jscFlavor
145144
}
146145

147-
implementation project(':react-native-notifications')
148146
implementation "com.google.firebase:firebase-messaging:23.3.1"
149147
implementation project(':watermelondb-jsi')
150148

android/app/src/main/AndroidManifest.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@
7575
<data android:mimeType="*/*" />
7676
</intent-filter>
7777
</activity>
78+
<!-- Custom Firebase Messaging Service for Rocket.Chat notifications -->
79+
<service
80+
android:name="chat.rocket.reactnative.notification.RCFirebaseMessagingService"
81+
android:exported="false">
82+
<intent-filter android:priority="100">
83+
<action android:name="com.google.firebase.MESSAGING_EVENT" />
84+
</intent-filter>
85+
</service>
7886
<receiver
7987
android:name="chat.rocket.reactnative.notification.ReplyBroadcast"
8088
android:enabled="true"
@@ -84,6 +92,15 @@
8492
android:enabled="true"
8593
android:exported="true" >
8694
</receiver>
95+
<receiver
96+
android:name="chat.rocket.reactnative.notification.VideoConfBroadcast"
97+
android:enabled="true"
98+
android:exported="false" >
99+
<intent-filter>
100+
<action android:name="chat.rocket.reactnative.ACTION_VIDEO_CONF_ACCEPT" />
101+
<action android:name="chat.rocket.reactnative.ACTION_VIDEO_CONF_DECLINE" />
102+
</intent-filter>
103+
</receiver>
87104
<meta-data
88105
android:name="com.bugsnag.android.API_KEY"
89106
android:value="${BugsnagAPIKey}" />

android/app/src/main/java/chat/rocket/reactnative/MainActivity.kt

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import com.facebook.react.defaults.DefaultReactActivityDelegate
77

88
import android.os.Bundle
99
import com.zoontek.rnbootsplash.RNBootSplash
10-
import android.content.Intent;
11-
import android.content.res.Configuration;
10+
import android.content.Intent
11+
import android.content.res.Configuration
12+
import chat.rocket.reactnative.notification.VideoConfModule
13+
import chat.rocket.reactnative.notification.VideoConfNotification
14+
import com.google.gson.GsonBuilder
1215

1316
class MainActivity : ReactActivity() {
1417

@@ -25,9 +28,60 @@ class MainActivity : ReactActivity() {
2528
override fun createReactActivityDelegate(): ReactActivityDelegate =
2629
DefaultReactActivityDelegate(this, mainComponentName, fabricEnabled)
2730

28-
override fun onCreate(savedInstanceState: Bundle?) {
31+
override fun onCreate(savedInstanceState: Bundle?) {
2932
RNBootSplash.init(this, R.style.BootTheme)
3033
super.onCreate(null)
34+
35+
// Handle video conf action from notification
36+
intent?.let { handleVideoConfIntent(it) }
37+
}
38+
39+
public override fun onNewIntent(intent: Intent) {
40+
super.onNewIntent(intent)
41+
// Handle video conf action when activity is already running
42+
handleVideoConfIntent(intent)
43+
}
44+
45+
private fun handleVideoConfIntent(intent: Intent) {
46+
if (intent.getBooleanExtra("videoConfAction", false)) {
47+
val notificationId = intent.getIntExtra("notificationId", 0)
48+
val event = intent.getStringExtra("event") ?: return
49+
val rid = intent.getStringExtra("rid") ?: ""
50+
val callerId = intent.getStringExtra("callerId") ?: ""
51+
val callerName = intent.getStringExtra("callerName") ?: ""
52+
val host = intent.getStringExtra("host") ?: ""
53+
val callId = intent.getStringExtra("callId") ?: ""
54+
55+
android.util.Log.d("RocketChat.MainActivity", "Handling video conf intent - event: $event, rid: $rid, host: $host, callId: $callId")
56+
57+
// Cancel the notification
58+
if (notificationId != 0) {
59+
VideoConfNotification.cancelById(this, notificationId)
60+
}
61+
62+
// Store action for JS to pick up - include all required fields
63+
val data = mapOf(
64+
"notificationType" to "videoconf",
65+
"rid" to rid,
66+
"event" to event,
67+
"host" to host,
68+
"callId" to callId,
69+
"caller" to mapOf(
70+
"_id" to callerId,
71+
"name" to callerName
72+
)
73+
)
74+
75+
val gson = GsonBuilder().create()
76+
val jsonData = gson.toJson(data)
77+
78+
android.util.Log.d("RocketChat.MainActivity", "Storing video conf action: $jsonData")
79+
80+
VideoConfModule.storePendingAction(this, jsonData)
81+
82+
// Clear the video conf flag to prevent re-processing
83+
intent.removeExtra("videoConfAction")
84+
}
3185
}
3286

3387
override fun invokeDefaultOnBackPressed() {

android/app/src/main/java/chat/rocket/reactnative/MainApplication.kt

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package chat.rocket.reactnative
22

33
import android.app.Application
4-
import android.content.Context
54
import android.content.res.Configuration
6-
import android.os.Bundle
75
import com.facebook.react.PackageList
86
import com.facebook.react.ReactApplication
97
import com.facebook.react.ReactHost
@@ -18,26 +16,35 @@ import com.facebook.react.defaults.DefaultReactNativeHost
1816
import com.facebook.react.soloader.OpenSourceMergedSoMapping
1917
import com.facebook.soloader.SoLoader
2018
import com.nozbe.watermelondb.jsi.WatermelonDBJSIPackage;
21-
import com.wix.reactnativenotifications.core.AppLaunchHelper
22-
import com.wix.reactnativenotifications.core.AppLifecycleFacade
23-
import com.wix.reactnativenotifications.core.JsIOHelper
24-
import com.wix.reactnativenotifications.core.notification.INotificationsApplication
25-
import com.wix.reactnativenotifications.core.notification.IPushNotification
2619
import com.bugsnag.android.Bugsnag
2720
import expo.modules.ApplicationLifecycleDispatcher
2821
import chat.rocket.reactnative.networking.SSLPinningTurboPackage;
2922
import chat.rocket.reactnative.storage.MMKVKeyManager;
3023
import chat.rocket.reactnative.storage.SecureStoragePackage;
3124
import chat.rocket.reactnative.notification.CustomPushNotification;
25+
import chat.rocket.reactnative.notification.VideoConfTurboPackage
3226

33-
open class MainApplication : Application(), ReactApplication, INotificationsApplication {
27+
/**
28+
* Main Application class.
29+
*
30+
* NOTIFICATION ARCHITECTURE:
31+
* - JS layer uses expo-notifications for token registration and event handling
32+
* - Native layer uses RCFirebaseMessagingService + CustomPushNotification for:
33+
* - FCM message handling
34+
* - Notification display with MessagingStyle
35+
* - E2E encrypted message decryption
36+
* - Direct reply functionality
37+
* - Message-id-only notification loading
38+
*/
39+
open class MainApplication : Application(), ReactApplication {
3440

3541
override val reactNativeHost: ReactNativeHost =
3642
object : DefaultReactNativeHost(this) {
3743
override fun getPackages(): List<ReactPackage> =
3844
PackageList(this).packages.apply {
3945
add(SSLPinningTurboPackage())
4046
add(WatermelonDBJSIPackage())
47+
add(VideoConfTurboPackage())
4148
add(SecureStoragePackage())
4249
}
4350

@@ -78,19 +85,4 @@ open class MainApplication : Application(), ReactApplication, INotificationsAppl
7885
super.onConfigurationChanged(newConfig)
7986
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig)
8087
}
81-
82-
override fun getPushNotification(
83-
context: Context,
84-
bundle: Bundle,
85-
defaultFacade: AppLifecycleFacade,
86-
defaultAppLaunchHelper: AppLaunchHelper
87-
): IPushNotification {
88-
return CustomPushNotification(
89-
context,
90-
bundle,
91-
defaultFacade,
92-
defaultAppLaunchHelper,
93-
JsIOHelper()
94-
)
95-
}
9688
}

0 commit comments

Comments
 (0)