Skip to content

Commit

Permalink
DMAPP-135: Push Chat Notification (#150)
Browse files Browse the repository at this point in the history
* DMAPP-135: Handle Notification Module

- Integrated chat notifications for both iOS and Android.
- Converted the notification helper to use Context API for better state management.
- Performed code refactoring to improve maintainability and readability.

* DMAPP-135: Code cleaning

- Removed unnecessary functions

* DMAPP-135: Integrate push chat notification

- Updated Notifee notification configuration for group chat notifications to enhance appearance.
- Refactored logic to remove chat notifications upon navigation to the chat history screen. This logic is now handled within the Single Chat component.

* DMAPP-135: Integrate chat notification

- Upgraded Firebase App, Messaging, and Notifee versions to fix the iOS native notification issue.
- [System level]: Updated Android configuration to require JVM 17 for compatibility.
- [Fix]: Resolved issue where the unlock profile modal was appearing after notification press even when the profile was already unlocked.
- Made minor adjustments to Notifee display notification configuration.

* DMAPP-135: Integrate chat notification

- Handled rare case for missing notification data: navigates to the chat list instead of a specific chat.
- Minor changes and fixes for improved reliability.

* DMAPP-135: Integrate chat notification

- Fixed navigation issue triggered on notification press.

* DMAPP-135: Fixes in chat & notification module

- User can copy group Chat ID
- Remove notification WIP

* DMAPP-135: Chat Notification

- Keep notification background handler in NotificationContext
- [fix]: Resolve warning for Spam feed item key

* DMAPP-135: Chat notification

- Requested code level changes done
- Remove channel notifications from notification centre after read
  • Loading branch information
meKushdeepSingh authored Jan 10, 2025
1 parent 3d6d3d9 commit 7ebf830
Show file tree
Hide file tree
Showing 24 changed files with 1,689 additions and 634 deletions.
76 changes: 30 additions & 46 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,33 @@ import RNCallKeep from 'react-native-callkeep';
import 'react-native-crypto';
import 'react-native-get-random-values';
import CallKeepHelper from 'src/helpers/CallkeepHelper';
import {NotificationHelper} from 'src/helpers/NotificationHelper';
import {NotifeClearBadge} from 'src/notifee';
import {getUUID} from 'src/push_video/payloads/helpers';
import MetaStorage from 'src/singletons/MetaStorage';
import 'text-encoding';
import {stringify} from 'uuid';

import App from './App';
import {name as appName} from './app.json';
import './shim';

/***************************************************/
/** Uncomment below commented code if video call **/
/** feature is enabled in the app **/
/***************************************************/
let isCallAccepted = false;

// this is supposed to be called wiz
if (AppState.currentState !== 'active' && Platform.OS === 'android') {
RNCallKeep.addEventListener('answerCall', async ({callUUID}) => {
CallKeepHelper.backToForeground();
CallKeepHelper.endAllCall();
isCallAccepted = true;
MetaStorage.instance.setBackgroundCallAccepted(false);
});
RNCallKeep.addEventListener('endCall', async ({callUUID}) => {
CallKeepHelper.endAllCall();
});
}
// if (AppState.currentState !== 'active' && Platform.OS === 'android') {
// RNCallKeep.addEventListener('answerCall', async ({callUUID}) => {
// CallKeepHelper.backToForeground();
// CallKeepHelper.endAllCall();
// isCallAccepted = true;
// MetaStorage.instance.setBackgroundCallAccepted(false);
// });
// RNCallKeep.addEventListener('endCall', async ({callUUID}) => {
// CallKeepHelper.endAllCall();
// });
// }

function HeadlessCheck({isHeadless}) {
useEffect(() => {
Expand All @@ -44,44 +46,26 @@ function HeadlessCheck({isHeadless}) {
return <App isCallAccepted={isCallAccepted} />;
}

// --------------------------------------
// Uncomment the code below if the video call feature is enabled.
// --------------------------------------
// if (Platform.OS === 'android') {
// CallKeepHelper.setupCallKeep();
// RNCallKeep.setAvailable(true);
// }

/************************************************/
/** Listeners used to display notifee **/
/** and native notification **/
/************************************************/
messaging().setBackgroundMessageHandler(async remoteMessage => {
// console.log('Message handled in the background!', remoteMessage);
/***************************************************/
/** Uncomment below commented code if video call **/
/** feature is enabled in the app **/
/***************************************************/
// if (Platform.OS === 'android' && CallKeepHelper.isVideoCall(remoteMessage)) {
// const caller = CallKeepHelper.getCaller(remoteMessage);
// const addressTrimmed = CallKeepHelper.formatEthAddress(caller);
// const uuid = getUUID();
// RNCallKeep.displayIncomingCall(
// uuid,
// addressTrimmed,
// addressTrimmed,
// 'generic',
// true,
// );
// }
});

messaging().onMessage(async remoteMessage => {
// console.log('Message handled in the foreground!', remoteMessage);
if (remoteMessage.notification) {
await NotificationHelper.resolveNotification(remoteMessage);
}
});
// messaging().setBackgroundMessageHandler(async remoteMessage => {
// console.log('Message handled in the background!', remoteMessage);
// if (Platform.OS === 'android' && CallKeepHelper.isVideoCall(remoteMessage)) {
// const caller = CallKeepHelper.getCaller(remoteMessage);
// const addressTrimmed = CallKeepHelper.formatEthAddress(caller);
// const uuid = getUUID();
// RNCallKeep.displayIncomingCall(
// uuid,
// addressTrimmed,
// addressTrimmed,
// 'generic',
// true,
// );
// }
// });

if (isCallAccepted) {
AppRegistry.registerComponent(appName, () => HeadlessCheck);
Expand Down
174 changes: 90 additions & 84 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -53,33 +53,33 @@ PODS:
- React-Core (= 0.71.14)
- React-jsi (= 0.71.14)
- ReactCommon/turbomodule/core (= 0.71.14)
- Firebase/CoreOnly (10.15.0):
- FirebaseCore (= 10.15.0)
- Firebase/Messaging (10.15.0):
- Firebase/CoreOnly (11.5.0):
- FirebaseCore (= 11.5.0)
- Firebase/Messaging (11.5.0):
- Firebase/CoreOnly
- FirebaseMessaging (~> 10.15.0)
- FirebaseCore (10.15.0):
- FirebaseCoreInternal (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Logger (~> 7.8)
- FirebaseCoreExtension (10.15.0):
- FirebaseCore (~> 10.0)
- FirebaseCoreInternal (10.16.0):
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- FirebaseInstallations (10.16.0):
- FirebaseCore (~> 10.0)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- FirebaseMessaging (10.15.0):
- FirebaseCore (~> 10.0)
- FirebaseInstallations (~> 10.0)
- GoogleDataTransport (~> 9.2)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/Reachability (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- nanopb (< 2.30910.0, >= 2.30908.0)
- FirebaseMessaging (~> 11.5.0)
- FirebaseCore (11.5.0):
- FirebaseCoreInternal (= 11.5)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/Logger (~> 8.0)
- FirebaseCoreExtension (11.5.0):
- FirebaseCore (= 11.5)
- FirebaseCoreInternal (11.5.0):
- "GoogleUtilities/NSData+zlib (~> 8.0)"
- FirebaseInstallations (11.5.0):
- FirebaseCore (= 11.5)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/UserDefaults (~> 8.0)
- PromisesObjC (~> 2.4)
- FirebaseMessaging (11.5.0):
- FirebaseCore (= 11.5)
- FirebaseInstallations (~> 11.0)
- GoogleDataTransport (~> 10.0)
- GoogleUtilities/AppDelegateSwizzler (~> 8.0)
- GoogleUtilities/Environment (~> 8.0)
- GoogleUtilities/Reachability (~> 8.0)
- GoogleUtilities/UserDefaults (~> 8.0)
- nanopb (~> 3.30910.0)
- fmt (6.2.1)
- Giphy (2.2.7):
- libwebp
Expand All @@ -88,43 +88,49 @@ PODS:
- RCT-Folly (= 2021.07.22.00)
- React-Core
- glog (0.3.5)
- GoogleDataTransport (9.2.5):
- GoogleUtilities/Environment (~> 7.7)
- nanopb (< 2.30910.0, >= 2.30908.0)
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities (7.11.5):
- GoogleUtilities/AppDelegateSwizzler (= 7.11.5)
- GoogleUtilities/Environment (= 7.11.5)
- GoogleUtilities/ISASwizzler (= 7.11.5)
- GoogleUtilities/Logger (= 7.11.5)
- GoogleUtilities/MethodSwizzler (= 7.11.5)
- GoogleUtilities/Network (= 7.11.5)
- "GoogleUtilities/NSData+zlib (= 7.11.5)"
- GoogleUtilities/Reachability (= 7.11.5)
- GoogleUtilities/SwizzlerTestHelpers (= 7.11.5)
- GoogleUtilities/UserDefaults (= 7.11.5)
- GoogleUtilities/AppDelegateSwizzler (7.11.5):
- GoogleDataTransport (10.1.0):
- nanopb (~> 3.30910.0)
- PromisesObjC (~> 2.4)
- GoogleUtilities (8.0.2):
- GoogleUtilities/AppDelegateSwizzler (= 8.0.2)
- GoogleUtilities/Environment (= 8.0.2)
- GoogleUtilities/Logger (= 8.0.2)
- GoogleUtilities/MethodSwizzler (= 8.0.2)
- GoogleUtilities/Network (= 8.0.2)
- "GoogleUtilities/NSData+zlib (= 8.0.2)"
- GoogleUtilities/Privacy (= 8.0.2)
- GoogleUtilities/Reachability (= 8.0.2)
- GoogleUtilities/SwizzlerTestHelpers (= 8.0.2)
- GoogleUtilities/UserDefaults (= 8.0.2)
- GoogleUtilities/AppDelegateSwizzler (8.0.2):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.5):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/ISASwizzler (7.11.5)
- GoogleUtilities/Logger (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/Environment (8.0.2):
- GoogleUtilities/Privacy
- GoogleUtilities/Logger (8.0.2):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/MethodSwizzler (8.0.2):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/Network (8.0.2):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Privacy
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.5)"
- GoogleUtilities/Reachability (7.11.5):
- "GoogleUtilities/NSData+zlib (8.0.2)":
- GoogleUtilities/Privacy
- GoogleUtilities/Privacy (8.0.2)
- GoogleUtilities/Reachability (8.0.2):
- GoogleUtilities/Logger
- GoogleUtilities/SwizzlerTestHelpers (7.11.5):
- GoogleUtilities/Privacy
- GoogleUtilities/SwizzlerTestHelpers (8.0.2):
- GoogleUtilities/MethodSwizzler
- GoogleUtilities/UserDefaults (7.11.5):
- GoogleUtilities/UserDefaults (8.0.2):
- GoogleUtilities/Logger
- GoogleUtilities/Privacy
- hermes-engine (0.71.14):
- hermes-engine/Pre-built (= 0.71.14)
- hermes-engine/Pre-built (0.71.14)
Expand All @@ -146,14 +152,14 @@ PODS:
- lottie-react-native (6.7.2):
- lottie-ios (= 4.4.1)
- React-Core
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- PromisesObjC (2.3.1)
- PromisesSwift (2.3.1):
- PromisesObjC (= 2.3.1)
- nanopb (3.30910.0):
- nanopb/decode (= 3.30910.0)
- nanopb/encode (= 3.30910.0)
- nanopb/decode (3.30910.0)
- nanopb/encode (3.30910.0)
- PromisesObjC (2.4.0)
- PromisesSwift (2.4.0):
- PromisesObjC (= 2.4.0)
- RCT-Folly (2021.07.22.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -554,12 +560,12 @@ PODS:
- React-Core
- RNCMaskedView (0.1.11):
- React
- RNFBApp (18.6.0):
- Firebase/CoreOnly (= 10.15.0)
- RNFBApp (21.6.1):
- Firebase/CoreOnly (= 11.5.0)
- React-Core
- RNFBMessaging (18.6.0):
- Firebase/Messaging (= 10.15.0)
- FirebaseCoreExtension (= 10.15.0)
- RNFBMessaging (21.6.1):
- Firebase/Messaging (= 11.5.0)
- FirebaseCoreExtension
- React-Core
- RNFBApp
- RNFlashList (1.6.3):
Expand All @@ -570,10 +576,10 @@ PODS:
- React-Core
- RNLocalize (3.0.2):
- React-Core
- RNNotifee (7.8.2):
- RNNotifee (9.1.8):
- React-Core
- RNNotifee/NotifeeCore (= 7.8.2)
- RNNotifee/NotifeeCore (7.8.2):
- RNNotifee/NotifeeCore (= 9.1.8)
- RNNotifee/NotifeeCore (9.1.8):
- React-Core
- RNOS (1.2.6):
- React
Expand All @@ -593,7 +599,7 @@ PODS:
- React
- Toast (4.0.0)
- Yoga (1.14.0)
- YoutubePlayer-in-WKWebView (0.3.8)
- YoutubePlayer-in-WKWebView (0.3.11)
- ZXingObjC/Core (3.6.9)
- ZXingObjC/OneD (3.6.9):
- ZXingObjC/Core
Expand Down Expand Up @@ -928,27 +934,27 @@ SPEC CHECKSUMS:
EXSharing: 09839ace249f61bfa13c50c6a28256c31d260355
FBLazyVector: 12ea01e587c9594e7b144e1bfc86ac4d9ac28fde
FBReactNativeSpec: b6ae48e67aaba46442f84d6f9ba598ccfbe2ee66
Firebase: 66043bd4579e5b73811f96829c694c7af8d67435
FirebaseCore: 2cec518b43635f96afe7ac3a9c513e47558abd2e
FirebaseCoreExtension: d3f1ea3725fb41f56e8fbfb29eeaff54e7ffb8f6
FirebaseCoreInternal: 26233f705cc4531236818a07ac84d20c333e505a
FirebaseInstallations: b822f91a61f7d1ba763e5ccc9d4f2e6f2ed3b3ee
FirebaseMessaging: 0c0ae1eb722ef0c07f7801e5ded8dccd1357d6d4
Firebase: 7a56fe4f56b5ab81b86a6822f5b8f909ae6fc7e2
FirebaseCore: 93abc05437f8064cd2bc0a53b768fb0bc5a1d006
FirebaseCoreExtension: ddb2eb987f736b714d30f6386795b52c4670439e
FirebaseCoreInternal: f47dd28ae7782e6a4738aad3106071a8fe0af604
FirebaseInstallations: d8063d302a426d114ac531cd82b1e335a0565745
FirebaseMessaging: 9f4e42053241bd45ce8565c881bfdd9c1df2f7da
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
Giphy: dad025aa0c82e4c057e1989cde959034829dfca7
giphy-react-native-sdk: f4fbdae92e3e8f8ef26b1af694141cb29d0e033a
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
GoogleDataTransport: 54dee9d48d14580407f8f5fbf2f496e92437a2f2
GoogleUtilities: 13e2c67ede716b8741c7989e26893d151b2b2084
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 26a3abef001b6533cf678d3eb38fd3f614b7872d
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
JitsiWebRTC: 80f62908fcf2a1160e0d14b584323fb6e6be630b
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
lottie-ios: e047b1d2e6239b787cc5e9755b988869cf190494
lottie-react-native: 17547b2f3c7034e2ae8672833fdb63262164d18a
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
PromisesSwift: 28dca69a9c40779916ac2d6985a0192a5cb4a265
nanopb: fad817b59e0457d11a5dfbde799381cd727c1275
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: e9df143e880d0e879e7a498dc06923d728809c79
RCTTypeSafety: c2d89c8308829c12c038ec1f431191eaa0d8c15c
Expand Down Expand Up @@ -1000,13 +1006,13 @@ SPEC CHECKSUMS:
RNCAsyncStorage: 8616bd5a58af409453ea4e1b246521bb76578d60
RNCClipboard: 2834e1c4af68697089cdd455ee4a4cdd198fa7dd
RNCMaskedView: 0e1bc4bfa8365eba5fbbb71e07fbdc0555249489
RNFBApp: 29a81c55c97887851fe2d8180293e0c618523d02
RNFBMessaging: 534bab7d0527d560cd1a35e74223735b4ed1eeee
RNFBApp: a3c9c3b23aa2d77001ce62b5a997325927593c12
RNFBMessaging: dd213f66f36b249f9ab035efe24dc2a3ede8f8c5
RNFlashList: 4b4b6b093afc0df60ae08f9cbf6ccd4c836c667a
RNGestureHandler: 071d7a9ad81e8b83fe7663b303d132406a7d8f39
RNKeychain: ff836453cba46938e0e9e4c22e43d43fa2c90333
RNLocalize: dbea38dcb344bf80ff18a1757b1becf11f70cae4
RNNotifee: 8e2d3df3f0e9ce8f5d1fe4c967431138190b6175
RNNotifee: 4a6ee5c7deaf00e005050052d73ee6315dff7ec9
RNOS: 6f2f9a70895bbbfbdad7196abd952e7b01d45027
RNReanimated: 2dc3707222fa153658386f4c0d357e0853327c3d
RNScreens: 80369e822c4f123c3f076c9ea4141991c17770f9
Expand All @@ -1015,7 +1021,7 @@ SPEC CHECKSUMS:
TcpSockets: 14306fb79f9750ea7d2ddd02d8bed182abb01797
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Yoga: e71803b4c1fff832ccf9b92541e00f9b873119b9
YoutubePlayer-in-WKWebView: 4fca3b4f6f09940077bfbae7bddb771f2b43aacd
YoutubePlayer-in-WKWebView: 2c3aa1d5ad8dded9f95ef12033af5dd8e55864b7
ZXingObjC: 8898711ab495761b2dbbdec76d90164a6d7e14c5

PODFILE CHECKSUM: 513a83d172d501d70c66336e88f9d25b0365cf4f
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@
"@giphy/react-native-sdk": "^3.2.0",
"@gorhom/bottom-sheet": "^4",
"@metamask/eth-sig-util": "^5.0.0",
"@notifee/react-native": "^7.8.2",
"@notifee/react-native": "^9.1.8",
"@pushprotocol/restapi": "^1.7.28",
"@pushprotocol/socket": "latest",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-clipboard/clipboard": "^1.11.1",
"@react-native-community/masked-view": "^0.1.11",
"@react-native-community/netinfo": "^11.3.1",
"@react-native-firebase/app": "^18.6.0",
"@react-native-firebase/messaging": "^18.6.0",
"@react-native-firebase/app": "^21.6.1",
"@react-native-firebase/messaging": "^21.6.1",
"@react-navigation/bottom-tabs": "^6.5.19",
"@react-navigation/native": "^6.0.12",
"@react-navigation/stack": "^6.2.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default {

IS_BACKGROUND_CALL_ACCEPTED: 'IsBackgroundCallAccepted',

NOTIFICATION_MESSAGES: 'NotificationMessages',
RECENT_NOTIFICATIONS: 'RecentNotification',
},

CONSTANTS: {
Expand Down
Loading

0 comments on commit 7ebf830

Please sign in to comment.