Skip to content

Commit b2b3056

Browse files
Merge pull request #22 from MirrorFly/feature/update-2.2.0
Feature/update 2.2.0
2 parents 71dcc97 + 421fa88 commit b2b3056

File tree

9 files changed

+130
-17
lines changed

9 files changed

+130
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ yarn.lock
6060
# Ruby / CocoaPods
6161
**/Pods/
6262
/vendor/bundle/
63+
**/Podfile.lock
6364

6465
# Temporary files created by Metro to check the health of the file watcher
6566
.metro-health-check*
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.mirrorfly_rn
2+
3+
import android.annotation.SuppressLint
4+
import android.provider.Settings
5+
import com.facebook.react.bridge.ReactApplicationContext
6+
import com.facebook.react.bridge.ReactContextBaseJavaModule
7+
import com.facebook.react.bridge.Promise
8+
import com.facebook.react.bridge.ReactMethod
9+
10+
class DeviceIdModule(private val reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
11+
override fun getName(): String = "DeviceId"
12+
13+
@SuppressLint("HardwareIds")
14+
@ReactMethod
15+
fun getDeviceID(promise: Promise) {
16+
try {
17+
val androidId = Settings.Secure.getString(
18+
reactContext.contentResolver,
19+
Settings.Secure.ANDROID_ID
20+
)
21+
promise.resolve(androidId)
22+
} catch (e: Exception) {
23+
promise.reject("DEVICE_ID_ERROR", "Failed to get Android ID", e)
24+
}
25+
}
26+
}

android/app/src/main/java/com/mirrorfly_rn/MFModule.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class MFModule : ReactPackage {
1414
modules.add(BluetoothHeadsetDetectModule(reactContext))
1515
modules.add(RingtoneSilentKeyEventModule(reactContext))
1616
modules.add(MediaService(reactContext))
17+
modules.add(DeviceIdModule(reactContext))
1718
return modules
1819
}
1920

ios/DeviceIdModule.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// DeviceIdModule.m
3+
// mirrorfly_rn
4+
//
5+
// Created by user on 24/04/25.
6+
7+
// DeviceIdModule.m
8+
#import <Foundation/Foundation.h>
9+
#import <React/RCTBridgeModule.h>
10+
11+
12+
@interface RCT_EXTERN_MODULE(DeviceId, NSObject)
13+
RCT_EXTERN_METHOD(getDeviceID:(RCTPromiseResolveBlock *)resolve
14+
rejecter:(RCTPromiseRejectBlock)reject)
15+
@end
16+

ios/DeviceIdModule.swift

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// DeviceIdModule.swift
3+
// mirrorfly_rn
4+
//
5+
// Created by user on 24/04/25.
6+
//
7+
import React
8+
import Foundation
9+
import UIKit
10+
import Security
11+
12+
@objc(DeviceId)
13+
class DeviceId: NSObject {
14+
let key = "com.mirrorfly.deviceid"
15+
@objc
16+
func getDeviceID(
17+
_ resolve: @escaping RCTPromiseResolveBlock,
18+
rejecter reject: @escaping RCTPromiseRejectBlock
19+
) {
20+
if let data = KeychainHelper.load(key: key),
21+
let existingUUID = String(data: data, encoding: .utf8) {
22+
resolve(existingUUID)
23+
} else {
24+
let uuid = UUID().uuidString.replacingOccurrences(of: "-", with: "")
25+
let shortened = String(uuid.prefix(8))
26+
if KeychainHelper.save(key: key, data: shortened.data(using: .utf8)!) {
27+
resolve(shortened)
28+
} else {
29+
reject("DEVICE_ID_ERROR", "Failed to save UUID to Keychain", nil)
30+
}
31+
}
32+
}
33+
}
34+
35+
36+
class KeychainHelper {
37+
38+
static func save(key: String, data: Data) -> Bool {
39+
let query = [
40+
kSecClass: kSecClassGenericPassword,
41+
kSecAttrAccount: key,
42+
kSecValueData: data
43+
] as CFDictionary
44+
45+
SecItemDelete(query) // delete existing
46+
let status = SecItemAdd(query, nil)
47+
return status == errSecSuccess
48+
}
49+
50+
static func load(key: String) -> Data? {
51+
let query = [
52+
kSecClass: kSecClassGenericPassword,
53+
kSecAttrAccount: key,
54+
kSecReturnData: kCFBooleanTrue!,
55+
kSecMatchLimit: kSecMatchLimitOne
56+
] as CFDictionary
57+
58+
var dataTypeRef: AnyObject?
59+
let status = SecItemCopyMatching(query, &dataTypeRef)
60+
if status == errSecSuccess {
61+
return dataTypeRef as? Data
62+
}
63+
return nil
64+
}
65+
}
66+

ios/mirrorfly_rn.xcodeproj/project.pbxproj

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
CE312F572D26CC7D00069D84 /* MediaService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE312F542D26CC7D00069D84 /* MediaService.swift */; };
2222
CE312F582D26CC7D00069D84 /* FlyUtiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE312F552D26CC7D00069D84 /* FlyUtiles.swift */; };
2323
CE312F592D26CC7D00069D84 /* MediaServiceBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = CE312F562D26CC7D00069D84 /* MediaServiceBridge.m */; };
24+
CE8C4CA22DC0F00F00B1D471 /* DeviceIdModule.m in Sources */ = {isa = PBXBuildFile; fileRef = CE8C4CA02DC0F00F00B1D471 /* DeviceIdModule.m */; };
25+
CE8C4CA32DC0F00F00B1D471 /* DeviceIdModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE8C4CA12DC0F00F00B1D471 /* DeviceIdModule.swift */; };
2426
/* End PBXBuildFile section */
2527

2628
/* Begin PBXContainerItemProxy section */
@@ -75,6 +77,8 @@
7577
CE312F542D26CC7D00069D84 /* MediaService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MediaService.swift; sourceTree = "<group>"; };
7678
CE312F552D26CC7D00069D84 /* FlyUtiles.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FlyUtiles.swift; sourceTree = "<group>"; };
7779
CE312F562D26CC7D00069D84 /* MediaServiceBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MediaServiceBridge.m; sourceTree = "<group>"; };
80+
CE8C4CA02DC0F00F00B1D471 /* DeviceIdModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceIdModule.m; sourceTree = "<group>"; };
81+
CE8C4CA12DC0F00F00B1D471 /* DeviceIdModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceIdModule.swift; sourceTree = "<group>"; };
7882
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
7983
/* End PBXFileReference section */
8084

@@ -118,6 +122,8 @@
118122
13B07FAE1A68108700A75B9A /* mirrorfly_rn */ = {
119123
isa = PBXGroup;
120124
children = (
125+
CE8C4CA02DC0F00F00B1D471 /* DeviceIdModule.m */,
126+
CE8C4CA12DC0F00F00B1D471 /* DeviceIdModule.swift */,
121127
CE312F552D26CC7D00069D84 /* FlyUtiles.swift */,
122128
CE312F542D26CC7D00069D84 /* MediaService.swift */,
123129
CE312F562D26CC7D00069D84 /* MediaServiceBridge.m */,
@@ -465,6 +471,8 @@
465471
13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */,
466472
A7B20C262CF5F71C0075CC1B /* RNCallKeep.m in Sources */,
467473
CE312F582D26CC7D00069D84 /* FlyUtiles.swift in Sources */,
474+
CE8C4CA22DC0F00F00B1D471 /* DeviceIdModule.m in Sources */,
475+
CE8C4CA32DC0F00F00B1D471 /* DeviceIdModule.swift in Sources */,
468476
CE312F572D26CC7D00069D84 /* MediaService.swift in Sources */,
469477
13B07FC11A68108700A75B9A /* main.m in Sources */,
470478
CE312F592D26CC7D00069D84 /* MediaServiceBridge.m in Sources */,
@@ -692,10 +700,7 @@
692700
"-DFOLLY_CFG_NO_COROUTINES=1",
693701
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
694702
);
695-
OTHER_LDFLAGS = (
696-
"$(inherited)",
697-
" ",
698-
);
703+
OTHER_LDFLAGS = "$(inherited) ";
699704
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
700705
SDKROOT = iphoneos;
701706
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) DEBUG";
@@ -779,10 +784,7 @@
779784
"-DFOLLY_CFG_NO_COROUTINES=1",
780785
"-DFOLLY_HAVE_CLOCK_GETTIME=1",
781786
);
782-
OTHER_LDFLAGS = (
783-
"$(inherited)",
784-
" ",
785-
);
787+
OTHER_LDFLAGS = "$(inherited) ";
786788
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
787789
SDKROOT = iphoneos;
788790
USE_HERMES = true;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"jest": "^29.6.3",
4848
"lodash-es": "^4.17.21",
4949
"luxon": "^3.5.0",
50-
"mirrorfly-reactnative-sdk": "^2.1.0",
50+
"mirrorfly-reactnative-sdk": "^2.2.0",
5151
"moment": "^2.30.1",
5252
"patch-package": "^8.0.0",
5353
"prettier": "2.8.8",

src/config/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const config = {
2525
INVITE_APP_URL: 'https://app.mirrorfly.com',
2626
INVITE_SMS_CONTENT:
2727
'Hey, MirrorFly is a real time chat, Audio and Video call solution for B2B and B2C.\n Download the app from this URL: https://app.mirrorfly.com',
28-
API_URL: 'https://console.mirrorfly.com/', // NOSONAR
28+
API_URL: 'https://api-preprod-sandbox.mirrorfly.com/api/v1', // NOSONAR
2929
licenseKey: '*****************', // NOSONAR
3030
};
3131

src/uikitMethods.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CallComponent } from './calls/CallComponent';
1212
import { setupCallKit } from './calls/ios';
1313
import { setNotificationForegroundService } from './calls/notification/callNotifyHandler';
1414
import { getNotifyMessage, getNotifyNickName, getUserIdFromJid, showToast } from './helpers/chatHelpers';
15+
import { NOTIFICATION } from './helpers/constants';
1516
import { setLanguageCode } from './localization/stringSet';
1617
import { addChatMessageItem } from './redux/chatMessageDataSlice';
1718
import { clearState } from './redux/clearSlice';
@@ -21,7 +22,6 @@ import { setRoasterData } from './redux/rosterDataSlice';
2122
import store from './redux/store';
2223
import { updateTheme, updateThemeColor } from './redux/themeColorDataSlice';
2324
import { RECENTCHATSCREEN, REGISTERSCREEN } from './screens/constants';
24-
import { NOTIFICATION } from './helpers/constants';
2525

2626
let uiKitCallbackListenersVal = {},
2727
appInitialized = false,
@@ -140,13 +140,14 @@ export const mirrorflyRegister = async ({ userIdentifier, fcmToken = '', metadat
140140
};
141141
}
142142

143-
const registerRes = await SDK.register(
143+
const registerRes = await SDK.register({
144144
userIdentifier,
145-
fcmToken,
146-
voipToken,
147-
process.env?.NODE_ENV === 'production',
148-
metadata,
149-
);
145+
fcmtoken: fcmToken,
146+
voipDeviceToken: voipToken,
147+
mode: process.env?.NODE_ENV === 'production',
148+
registerMetaData: metadata,
149+
forceRegister: true,
150+
});
150151
if (registerRes.statusCode === 200) {
151152
const { data } = registerRes;
152153
const connect = await SDK.connect(data.username, data.password);

0 commit comments

Comments
 (0)