Skip to content

Commit 4de2067

Browse files
Merged in stage (pull request #258)
MRN-961 Approved-by: vanitha.g
2 parents ae37a75 + f54761e commit 4de2067

Some content is hidden

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

43 files changed

+502
-295
lines changed

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ android {
9898
minSdkVersion rootProject.ext.minSdkVersion
9999
targetSdkVersion rootProject.ext.targetSdkVersion
100100
versionCode 1
101-
versionName "3.3.3"
101+
versionName "3.3.7"
102102
/** Add this for react-native-camera */
103103
missingDimensionStrategy 'react-native-camera', 'general'
104104
multiDexEnabled true
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"project_info": {
3+
"project_number": "893798188095",
4+
"project_id": "findmena-c1e1a",
5+
"storage_bucket": "findmena-c1e1a.firebasestorage.app"
6+
},
7+
"client": [
8+
{
9+
"client_info": {
10+
"mobilesdk_app_id": "1:893798188095:android:cffd2a6d3c181b05aee48a",
11+
"android_client_info": {
12+
"package_name": "com.findmena"
13+
}
14+
},
15+
"oauth_client": [],
16+
"api_key": [
17+
{
18+
"current_key": "AIzaSyD_RCzIaomul4ZVoVERv6onVnIbyzv7NIY"
19+
}
20+
],
21+
"services": {
22+
"appinvite_service": {
23+
"other_platform_oauth_client": []
24+
}
25+
}
26+
}
27+
],
28+
"configuration_version": "1"
29+
}

android/fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ platform :android do
5454
firebase_app_distribution(
5555
app: "1:235373697524:android:8b3becf8d8ff9be3a0c1a1",
5656
groups: "reactnative",
57-
release_notes: "React-Native ios build for MRN-908, MRN-901",
57+
release_notes: "React-Native ios build for bug-fixes MRN-967",
5858
apk_path: "../android/app/build/outputs/apk/release/app-release.apk",
5959
firebase_cli_token: "1//0gfTJ_oWJ0mHNCgYIARAAGBASNwF-L9IrYZM4cUIV5EB8gVnSvtMC6Q7aAtgrgG8R1ybhSY1Np_5r5UuZu28N144_weOQDyONcW4",
6060
)

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { isPipModeEnabled } from './src/Helper/Calls/Utility';
99
import config from './src/config/config';
1010
import { MIRRORFLY_RN } from './src/helpers/constants';
1111
import { mirrorflyInitialize, mirrorflyNotificationHandler, setAppConfig, setupCallScreen } from './src/uikitMethods';
12+
import { sdkLog } from './src/SDK/utils';
1213

1314
setAppConfig({ appSchema: MIRRORFLY_RN });
1415

@@ -26,6 +27,7 @@ mirrorflyInitialize({
2627
});
2728

2829
messaging().setBackgroundMessageHandler(async remoteMessage => {
30+
sdkLog('Message handled in the background!', remoteMessage);
2931
if (Platform.OS === 'android') {
3032
mirrorflyNotificationHandler(remoteMessage);
3133
}

ios/NotificationExtension/MyClass.swift

Lines changed: 87 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -30,56 +30,95 @@ class MyClass: NSObject {
3030
}
3131

3232
@objc
33-
func getMessage(messageID: String, content: String, type:String, userjid:String, completion: @escaping([String: Any]?) -> Void) {
34-
var dict = [String: Any]()
35-
removeInvalidMessage(forIDs: [messageID], onCompletion: {
36-
notification in
37-
38-
switch (type) {
39-
case "text":
40-
let val = convertToDictionary(text: self.run(messageID: messageID, content: content))
41-
let nickName:String = val?["nickName"] as? String ?? ""
42-
if let number = userjid.components(separatedBy: "@").first, !number.isEmpty {
43-
dict["nickName"] = FlyEncryption.encryptDecryptData(key: number, data: nickName, encrypt: false, isForProfileName: true)
44-
} else {
45-
dict["nickName"] = nickName // Fallback in case `number` is nil or empty
46-
}
47-
dict["message"] = val?["message"]
48-
break;
49-
case "image":
50-
dict["message"] = "📷 Image"
51-
break;
52-
case "video":
53-
dict["message"] = "📽️ Video"
54-
break;
55-
case "audio":
56-
dict["message"] = "🎵 Audio"
57-
break;
58-
case "file":
59-
dict["message"] = "📄 File"
60-
break;
61-
case "location":
62-
dict["message"] = "📌 Location"
63-
break;
64-
case "contact":
65-
dict["message"] = "👤 Contact"
66-
break;
67-
case "recall":
68-
// Need to called for recall message
69-
// removeNotification(messageId: messageID, n: notification)
70-
dict["messageID"] = messageID
71-
dict["message"] = "This message was deleted"
72-
break;
73-
default:
74-
dict["message"] = "Unknown message format"
75-
break
76-
}
33+
func getMessage(userInfo: [String: Any], completion: @escaping ([String: Any]?) -> Void) {
34+
var dict = [String: Any]()
35+
36+
// Use empty strings if the keys are not present
37+
let messageID = userInfo["message_id"] as? String ?? userInfo["notify_id"] as? String ?? ""
38+
let content = userInfo["message_content"] as? String ?? ""
39+
let chat_type = userInfo["chat_type"] as? String ?? ""
40+
let group_name = userInfo["group_name"] as? String ?? ""
41+
let type = userInfo["type"] as? String ?? ""
42+
let userjid = userInfo["from_user"] as? String ?? ""
43+
7744

78-
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(1.0 * Double(NSEC_PER_SEC)) / Double(NSEC_PER_SEC), execute: { [self] in
79-
completion(dict)
45+
if ["added", "removed"].contains(where: { content.contains($0) }) {
46+
if let aps = userInfo["aps"] as? [String: Any],
47+
let alert = aps["alert"] as? [String: Any],
48+
let body = alert["body"] as? String,
49+
let title = alert["title"] as? String,
50+
let groupName = userInfo["group_name"] as? String {
51+
52+
let trimmedGroupName = groupName.trimmingCharacters(in: .whitespacesAndNewlines)
53+
var cleanBody = body.trimmingCharacters(in: .whitespacesAndNewlines)
54+
55+
// Build a regex to match any variation like "group_name:", "group_name :", "group_name : "
56+
let regexPattern = "^" + NSRegularExpression.escapedPattern(for: trimmedGroupName) + "\\s*:\\s*"
57+
58+
if let regex = try? NSRegularExpression(pattern: regexPattern, options: [.caseInsensitive]) {
59+
let range = NSRange(location: 0, length: cleanBody.utf16.count)
60+
cleanBody = regex.stringByReplacingMatches(in: cleanBody, options: [], range: range, withTemplate: "")
61+
.trimmingCharacters(in: .whitespacesAndNewlines)
62+
}
63+
64+
dict["nickName"] = title
65+
dict["message"] = cleanBody
66+
67+
DispatchQueue.main.async {
68+
completion(dict)
69+
}
70+
return
71+
}
72+
}
73+
74+
removeInvalidMessage(forIDs: [messageID], onCompletion: { notification in
75+
switch type {
76+
case "text":
77+
let val = convertToDictionary(text: self.run(messageID: messageID, content: content))
78+
let rawNickName = val?["nickName"] as? String ?? ""
79+
let number = userjid.components(separatedBy: "@").first ?? ""
80+
81+
var decryptedNickName = rawNickName
82+
if !number.isEmpty {
83+
decryptedNickName = FlyEncryption.encryptDecryptData(key: number, data: rawNickName, encrypt: false, isForProfileName: true)
84+
}
85+
86+
// Optionally prepend group name if it's a group chat
87+
if chat_type == "normal", let groupName = userInfo["group_name"] as? String {
88+
dict["nickName"] = "\(groupName)@ \(decryptedNickName)"
89+
} else {
90+
dict["nickName"] = decryptedNickName
91+
}
92+
93+
dict["message"] = val?["message"]
94+
case "image":
95+
dict["message"] = "📷 Image"
96+
case "video":
97+
dict["message"] = "📽️ Video"
98+
case "audio":
99+
dict["message"] = "🎵 Audio"
100+
case "file":
101+
dict["message"] = "📄 File"
102+
case "location":
103+
dict["message"] = "📌 Location"
104+
case "contact":
105+
dict["message"] = "👤 Contact"
106+
case "recall":
107+
dict["messageID"] = messageID
108+
dict["message"] = "This message was deleted"
109+
default:
110+
dict["message"] = "Unknown message format"
111+
}
112+
113+
if (dict["nickName"] == nil || (dict["nickName"] as? String)?.isEmpty == true),
114+
let groupName = userInfo["group_name"] as? String {
115+
dict["nickName"] = groupName
116+
}
117+
// Call completion with the final dict
118+
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(1.0 * Double(NSEC_PER_SEC)) / Double(NSEC_PER_SEC), execute: { [self] in
119+
completion(dict)
120+
})
80121
})
81-
// completion(dict)
82-
})
83122
}
84123
}
85124

ios/NotificationExtension/NotificationService.m

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,29 @@ @implementation NotificationService
2020
- (void)didReceiveNotificationRequest:(UNNotificationRequest *)request withContentHandler:(void (^)(UNNotificationContent * _Nonnull))contentHandler {
2121
self.contentHandler = contentHandler;
2222
self.bestAttemptContent = [request.content mutableCopy];
23-
NSString *messagecontent = [self.bestAttemptContent.userInfo objectForKey:@"message_content"];
24-
NSString *messagetype = [self.bestAttemptContent.userInfo objectForKey:@"type"];
25-
NSString *userjid = [self.bestAttemptContent.userInfo objectForKey:@"from_user"];
23+
NSDictionary *userInfo = [self.bestAttemptContent userInfo];
2624
NSString *message_id = [self.bestAttemptContent.userInfo objectForKey:@"message_id"];
27-
NSString *user_name = [self.bestAttemptContent.userInfo objectForKey:@"user_name"];
25+
NSString *user_name = [self.bestAttemptContent.userInfo objectForKey:@"user_name"];;
26+
2827
@autoreleasepool {
2928
MyClass * obj = [MyClass new];
30-
[obj getMessageWithMessageID:message_id content:messagecontent type:messagetype userjid:userjid completion:^(NSDictionary<NSString *,id> * dict) {
31-
self.bestAttemptContent.threadIdentifier = dict[@"messageID"] ? dict[@"messageID"]: message_id;
32-
NSString *nickName = dict[@"nickName"];
33-
if (nickName) {
34-
self.bestAttemptContent.title = dict[@"nickName"];
35-
} else {
36-
self.bestAttemptContent.title = user_name;
29+
[obj getMessageWithUserInfo:userInfo completion:^(NSDictionary<NSString *,id> *dict){
30+
if(dict){
31+
self.bestAttemptContent.threadIdentifier = dict[@"messageID"] ? dict[@"messageID"]: message_id;
32+
NSString *nickName = dict[@"nickName"];
33+
if (nickName) {
34+
self.bestAttemptContent.title = dict[@"nickName"];
35+
} else {
36+
self.bestAttemptContent.title = user_name;
3737
// Handle the case where both nickName and user_name are nil
38-
// Optional: set a default title
38+
// Optional: set a default title
39+
}
40+
self.bestAttemptContent.sound = [UNNotificationSound defaultSound];
41+
self.bestAttemptContent.body = dict[@"message"];
42+
self.contentHandler(self.bestAttemptContent);
43+
} else{
44+
self.contentHandler(self.bestAttemptContent);
3945
}
40-
self.bestAttemptContent.body = dict[@"message"];
41-
self.contentHandler(self.bestAttemptContent);
4246
}];
4347
}
4448
}

ios/fastlane/Fastfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ lane :qa_firebase do
2828
firebase_app_distribution(
2929
app: "1:235373697524:ios:0e9bd66b524978a0a0c1a1",
3030
groups: "reactnative",
31-
release_notes: "React-Native ios build for MRN-908, MRN-901",
31+
release_notes: "React-Native ios build for bug-fixes MRN-967",
3232
firebase_cli_path: "/usr/local/bin/firebase",
3333
firebase_cli_token: "1//0g53oUKW5j5bJCgYIARAAGBASNwF-L9Ir7Ei_6NzWEsyHOMMXytlesfgXShhLeJWRwbcf2MC3e7BaC5dwYlUZB-_osuQFsxy0Du0"
3434
)

ios/mirrorfly_rn.xcodeproj/project.pbxproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
89C6BE57DB24E9ADA2F236DE /* Pods-mirrorfly_rn-mirrorfly_rnTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-mirrorfly_rn-mirrorfly_rnTests.release.xcconfig"; path = "Target Support Files/Pods-mirrorfly_rn-mirrorfly_rnTests/Pods-mirrorfly_rn-mirrorfly_rnTests.release.xcconfig"; sourceTree = "<group>"; };
8484
A7B20BDA2CF5E2880075CC1B /* fly_reconnecting_tone.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = fly_reconnecting_tone.mp3; sourceTree = "<group>"; };
8585
A7B20BDB2CF5E2880075CC1B /* incallmanager_ringback.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = incallmanager_ringback.mp3; sourceTree = "<group>"; };
86-
A7B20BFB2CF5EB1B0075CC1B /* mirrorfly_rn.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = mirrorfly_rn.entitlements; path = mirrorfly_rn/mirrorfly_rn.entitlements; sourceTree = "<group>"; };
8786
A7B20C242CF5F71C0075CC1B /* RNCallKeep.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = RNCallKeep.h; path = mirrorfly_rn/RNCallKeep.h; sourceTree = "<group>"; };
8887
A7B20C252CF5F71C0075CC1B /* RNCallKeep.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = RNCallKeep.m; path = mirrorfly_rn/RNCallKeep.m; sourceTree = "<group>"; };
8988
A7B20C502CF60AC40075CC1B /* UserNotifications.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UserNotifications.framework; path = System/Library/Frameworks/UserNotifications.framework; sourceTree = SDKROOT; };
@@ -161,7 +160,6 @@
161160
A7F436602D4CB216003518B3 /* GoogleService-Info.plist */,
162161
A7B20C242CF5F71C0075CC1B /* RNCallKeep.h */,
163162
A7B20C252CF5F71C0075CC1B /* RNCallKeep.m */,
164-
A7B20BFB2CF5EB1B0075CC1B /* mirrorfly_rn.entitlements */,
165163
A7B20BDC2CF5E2880075CC1B /* custom_ringtones */,
166164
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
167165
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
@@ -682,7 +680,7 @@
682680
"$(inherited)",
683681
"@executable_path/Frameworks",
684682
);
685-
MARKETING_VERSION = 3.3.3;
683+
MARKETING_VERSION = 3.3.7;
686684
OTHER_LDFLAGS = (
687685
"$(inherited)",
688686
"-ObjC",
@@ -715,7 +713,7 @@
715713
"$(inherited)",
716714
"@executable_path/Frameworks",
717715
);
718-
MARKETING_VERSION = 3.3.3;
716+
MARKETING_VERSION = 3.3.7;
719717
OTHER_LDFLAGS = (
720718
"$(inherited)",
721719
"-ObjC",

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mirrorfly-uikit-react-native",
3-
"version": "2.1.0",
3+
"version": "2.3.0",
44
"description": "React-Native based UI kit for Mirrorfly",
55
"main": "dist/index.js",
66
"module": "dist/index.js",
@@ -69,7 +69,7 @@
6969
"jest": "^29.6.3",
7070
"lodash-es": "^4.17.21",
7171
"luxon": "^3.5.0",
72-
"mirrorfly-reactnative-sdk": "^1.1.0",
72+
"mirrorfly-reactnative-sdk": "^2.3.0",
7373
"moment": "^2.30.1",
7474
"patch-package": "^8.0.0",
7575
"prettier": "2.8.8",

src/Helper/Calls/Utility.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { openSettings } from 'react-native-permissions';
1010
import RNVoipPushNotification from 'react-native-voip-push-notification';
1111
import SDK, { RealmKeyValueStore } from '../../SDK/SDK';
1212
import { clearIosCallListeners, muteLocalAudio, muteLocalVideo, resetCallData } from '../../SDK/sdkCallBacks';
13-
import { getUserProfileFromApi, getUserProfileFromSDK } from '../../SDK/utils';
13+
import { getUserProfileFromApi, getUserProfileFromSDK, sdkLog } from '../../SDK/utils';
1414
import { callNotifyHandler, stopForegroundServiceNotification } from '../../calls/notification/callNotifyHandler';
1515
import { getNetworkState } from '../../common/hooks';
1616
import {
@@ -858,6 +858,7 @@ const onVoipPushNotificationReceived = async data => {
858858
payload: { caller_id, caller_name },
859859
callUUID,
860860
} = data;
861+
sdkLog('VoipPushNotificationReceived', data);
861862
const activeCallUUID = store.getState().callData?.callerUUID || '';
862863
if (activeCallUUID !== '') {
863864
const calls = await RNCallKeep.getCalls();

0 commit comments

Comments
 (0)