Skip to content

Commit 6cefd4a

Browse files
MRN-969
1 parent 66cde00 commit 6cefd4a

File tree

10 files changed

+125
-12
lines changed

10 files changed

+125
-12
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: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
A7B20D1B2CF6DF400075CC1B /* sendDeliveredApiCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7B20D162CF6DF400075CC1B /* sendDeliveredApiCall.swift */; };
2525
A7F436612D4CB216003518B3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = A7F436602D4CB216003518B3 /* GoogleService-Info.plist */; };
2626
B42B189CF199C58746A31FD6 /* Pods_mirrorfly_rn.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D29BAF4B0875C49FA458AB9 /* Pods_mirrorfly_rn.framework */; };
27+
CE2074AA2DBA65C800C4A09A /* DeviceIdModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE2074A92DBA65C800C4A09A /* DeviceIdModule.swift */; };
28+
CE2074AC2DBA666300C4A09A /* DeviceIdModule.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2074AB2DBA666300C4A09A /* DeviceIdModule.m */; };
2729
CE4307242D801FFC002485FF /* FlyUtiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE4307212D801FFC002485FF /* FlyUtiles.swift */; };
2830
CE4307252D801FFC002485FF /* MediaService.swift in Sources */ = {isa = PBXBuildFile; fileRef = CE4307222D801FFC002485FF /* MediaService.swift */; };
2931
CE4307262D801FFC002485FF /* MediaServiceBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = CE4307232D801FFC002485FF /* MediaServiceBridge.m */; };
@@ -96,6 +98,8 @@
9698
A7B20D152CF6DF400075CC1B /* NotificationService.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationService.m; sourceTree = "<group>"; };
9799
A7B20D162CF6DF400075CC1B /* sendDeliveredApiCall.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = sendDeliveredApiCall.swift; sourceTree = "<group>"; };
98100
A7F436602D4CB216003518B3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
101+
CE2074A92DBA65C800C4A09A /* DeviceIdModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceIdModule.swift; sourceTree = "<group>"; };
102+
CE2074AB2DBA666300C4A09A /* DeviceIdModule.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DeviceIdModule.m; sourceTree = "<group>"; };
99103
CE4307212D801FFC002485FF /* FlyUtiles.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FlyUtiles.swift; sourceTree = "<group>"; };
100104
CE4307222D801FFC002485FF /* MediaService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaService.swift; sourceTree = "<group>"; };
101105
CE4307232D801FFC002485FF /* MediaServiceBridge.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MediaServiceBridge.m; sourceTree = "<group>"; };
@@ -167,6 +171,8 @@
167171
13B07FB71A68108700A75B9A /* main.m */,
168172
13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */,
169173
351382106977CC60AE8C9180 /* PrivacyInfo.xcprivacy */,
174+
CE2074A92DBA65C800C4A09A /* DeviceIdModule.swift */,
175+
CE2074AB2DBA666300C4A09A /* DeviceIdModule.m */,
170176
);
171177
name = mirrorfly_rn;
172178
sourceTree = "<group>";
@@ -565,6 +571,8 @@
565571
CE4307252D801FFC002485FF /* MediaService.swift in Sources */,
566572
CE4307262D801FFC002485FF /* MediaServiceBridge.m in Sources */,
567573
13B07FC11A68108700A75B9A /* main.m in Sources */,
574+
CE2074AC2DBA666300C4A09A /* DeviceIdModule.m in Sources */,
575+
CE2074AA2DBA65C800C4A09A /* DeviceIdModule.swift in Sources */,
568576
);
569577
runOnlyForDeploymentPostprocessing = 0;
570578
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@
122122
"rollup-plugin-node-polyfills": "^0.2.1",
123123
"rollup-plugin-peer-deps-external": "^2.2.4",
124124
"rollup-plugin-terser": "^7.0.2",
125-
"typescript": "4.8.4",
126-
"react-native-device-info": "^14.0.4"
125+
"typescript": "4.8.4"
127126
},
128127
"engines": {
129128
"node": ">=18"

src/SDK/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config/config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ const config = {
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',
2828
// ================ Dev environment variables =====================
29-
// API_URL: 'https://api-uikit-dev.contus.us/api/v1',
30-
// licenseKey: '2sdgNtr3sFBSM3bYRa7RKDPEiB38Xo',
29+
API_URL: 'https://api-uikit-dev.contus.us/api/v1',
30+
licenseKey: '2sdgNtr3sFBSM3bYRa7RKDPEiB38Xo',
3131
// =====================================
3232
// ================ QA Environment variables =====================
33-
API_URL: 'https://api-uikit-qa.contus.us/api/v1',
34-
licenseKey: 'ckIjaccWBoMNvxdbql8LJ2dmKqT5bp',
33+
// API_URL: 'https://api-uikit-qa.contus.us/api/v1',
34+
// licenseKey: 'ckIjaccWBoMNvxdbql8LJ2dmKqT5bp',
3535
// ================ UAT/Staging Environment variables =====================
3636
// API_URL: 'https://api-uikit-uat.contus.us/api/v1',
3737
// licenseKey: 'lu3Om85JYSghcsB6vgVoSgTlSQArL5',

src/uikitMethods.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { setRoasterData } from './redux/rosterDataSlice';
2222
import store from './redux/store';
2323
import { updateTheme, updateThemeColor } from './redux/themeColorDataSlice';
2424
import { RECENTCHATSCREEN, REGISTERSCREEN } from './screens/constants';
25-
import DeviceInfo from 'react-native-device-info';
2625

2726
let uiKitCallbackListenersVal = {},
2827
appInitialized = false,
@@ -141,15 +140,12 @@ export const mirrorflyRegister = async ({ userIdentifier, fcmToken = '', metadat
141140
};
142141
}
143142

144-
const deviceId = await DeviceInfo.getUniqueId();
145-
146143
const registerRes = await SDK.register({
147144
userIdentifier,
148145
fcmtoken: fcmToken,
149146
voipDeviceToken: voipToken,
150147
mode: process.env?.NODE_ENV === 'production',
151148
registerMetaData: metadata,
152-
deviceId: deviceId.toLowerCase(),
153149
forceRegister: true,
154150
});
155151
if (registerRes.statusCode === 200) {
@@ -214,7 +210,7 @@ export const mirrorflyLogout = async () => {
214210
notifee.stopForegroundService();
215211
notifee.cancelAllNotifications();
216212
return statusCode;
217-
} catch (error) { }
213+
} catch (error) {}
218214
};
219215

220216
export const fetchCurrentUserProfile = async (iq = false) => {

0 commit comments

Comments
 (0)