@@ -6,10 +6,7 @@ import android.os.Bundle
6
6
import android.webkit.WebView
7
7
import com.facebook.react.ReactActivity
8
8
import com.facebook.react.ReactActivityDelegate
9
- import com.zulipmobile.notifications.EXTRA_NOTIFICATION_DATA
10
- import com.zulipmobile.notifications.NOTIFICATION_URL_AUTHORITY
11
- import com.zulipmobile.notifications.logNotificationData
12
- import com.zulipmobile.notifications.notifyReact
9
+ import com.zulipmobile.notifications.maybeHandleViewNotif
13
10
import com.zulipmobile.sharing.handleSend
14
11
import expo.modules.ReactActivityDelegateWrapper
15
12
@@ -32,26 +29,22 @@ open class MainActivity : ReactActivity() {
32
29
/* Returns true just if we did handle the intent. */
33
30
private fun maybeHandleIntent (intent : Intent ? ): Boolean {
34
31
intent ? : return false
35
- val url = intent.data
36
32
when (intent.action) {
37
33
// Share-to-Zulip
38
34
Intent .ACTION_SEND , Intent .ACTION_SEND_MULTIPLE -> {
39
35
handleSend(intent, reactApplication.tryGetReactContext(), contentResolver)
40
36
return true
41
37
}
42
38
43
- Intent .ACTION_VIEW -> when {
44
- // Launch MainActivity on tapping a notification
45
- url?.scheme == " zulip" && url.authority == NOTIFICATION_URL_AUTHORITY -> {
46
- val data = intent.getBundleExtra(EXTRA_NOTIFICATION_DATA ) ? : return false
47
- logNotificationData(" notif opened" , data)
48
- notifyReact(reactApplication.tryGetReactContext(), data)
39
+ Intent .ACTION_VIEW -> {
40
+ if (maybeHandleViewNotif(intent, reactApplication.tryGetReactContext())) {
41
+ // Notification tapped
49
42
return true
50
43
}
51
44
52
45
// Let RN handle other intents. In particular web-auth intents (parsed in
53
46
// src/start/webAuth.js) have ACTION_VIEW, scheme "zulip", and authority "login".
54
- else -> return false
47
+ return false
55
48
}
56
49
57
50
// For other intents, let RN handle it.
0 commit comments