react-native-inapp-inspector 1.1.10 → 1.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { Clipboard, Platform, ToastAndroid, Alert } from 'react-native';
1
+ import { Clipboard, Platform, ToastAndroid, Alert, NativeModules } from 'react-native';
2
2
  // Stylesheet
3
3
  import { AppColors } from '../styles/AppColors';
4
4
  // Constants
@@ -216,3 +216,89 @@ export const formatDateTimeToAnalytics = (ts) => {
216
216
  second: '2-digit',
217
217
  });
218
218
  };
219
+ export const getBundleIdentifier = () => {
220
+ const RNDeviceInfo = NativeModules.RNDeviceInfo;
221
+ if (RNDeviceInfo && typeof RNDeviceInfo.bundleId === 'string') {
222
+ return RNDeviceInfo.bundleId;
223
+ }
224
+ if (RNDeviceInfo && typeof RNDeviceInfo.getBundleId === 'function') {
225
+ try {
226
+ const res = RNDeviceInfo.getBundleId();
227
+ if (typeof res === 'string')
228
+ return res;
229
+ }
230
+ catch (e) { }
231
+ }
232
+ const ExponentConstants = NativeModules.ExponentConstants;
233
+ if (ExponentConstants && ExponentConstants.manifest) {
234
+ const manifest = ExponentConstants.manifest;
235
+ if (manifest.ios && manifest.ios.bundleIdentifier) {
236
+ return manifest.ios.bundleIdentifier;
237
+ }
238
+ if (manifest.android && manifest.android.package) {
239
+ return manifest.android.package;
240
+ }
241
+ }
242
+ const ExpoApplication = NativeModules.ExpoApplication;
243
+ if (ExpoApplication && typeof ExpoApplication.applicationId === 'string') {
244
+ return ExpoApplication.applicationId;
245
+ }
246
+ const SourceCode = NativeModules.SourceCode;
247
+ if (SourceCode && typeof SourceCode.scriptURL === 'string') {
248
+ const url = SourceCode.scriptURL;
249
+ if (url.includes('assets/')) {
250
+ try {
251
+ const match = url.match(/assets\/([^/?#]+)/);
252
+ if (match && match[1]) {
253
+ return match[1];
254
+ }
255
+ }
256
+ catch (e) { }
257
+ }
258
+ }
259
+ return 'org.reactjs.native.example';
260
+ };
261
+ export const getAppName = () => {
262
+ // Try iOS via PlatformConstants
263
+ const constants = NativeModules.PlatformConstants;
264
+ if (constants && typeof constants.interfaceIdiom === 'string') {
265
+ // On iOS, try to get display name from the main bundle
266
+ const SettingsManager = NativeModules.SettingsManager;
267
+ if (SettingsManager && SettingsManager.settings) {
268
+ const appName = SettingsManager.settings.AppleLocale
269
+ ? undefined
270
+ : undefined;
271
+ // Fallback: try to parse from SourceCode
272
+ }
273
+ }
274
+ // Try react-native-device-info
275
+ const RNDeviceInfo = NativeModules.RNDeviceInfo;
276
+ if (RNDeviceInfo && typeof RNDeviceInfo.appName === 'string') {
277
+ return RNDeviceInfo.appName;
278
+ }
279
+ // Try Expo
280
+ const ExpoApplication = NativeModules.ExpoApplication;
281
+ if (ExpoApplication && typeof ExpoApplication.applicationName === 'string') {
282
+ return ExpoApplication.applicationName;
283
+ }
284
+ const ExponentConstants = NativeModules.ExponentConstants;
285
+ if (ExponentConstants && ExponentConstants.manifest) {
286
+ const manifest = ExponentConstants.manifest;
287
+ if (manifest.name)
288
+ return manifest.name;
289
+ }
290
+ // Android: try to get from AndroidInfoModule
291
+ const AppInfo = NativeModules.AppInfo;
292
+ if (AppInfo && typeof AppInfo.appName === 'string') {
293
+ return AppInfo.appName;
294
+ }
295
+ // Fallback: derive from bundle ID (last segment, cleaned up)
296
+ const bundleId = getBundleIdentifier();
297
+ if (bundleId && bundleId !== 'org.reactjs.native.example') {
298
+ const parts = bundleId.split('.');
299
+ const last = parts[parts.length - 1];
300
+ // Capitalize first letter
301
+ return last ? last.charAt(0).toUpperCase() + last.slice(1) : 'App';
302
+ }
303
+ return 'App';
304
+ };