0
votes

I am building an app using Expo and React Native. I am in a situation where I need to get some device info such as: Phone Brand, Phone Model, and if possible Mac Address for both Android and iOS. Here I am only asking for Phone Brand. I have tried using Expo Constants API, but it only returns the Device Name (e.g. SM-A750GN for Samsung Galaxy A7). What I would like is to get the brand like 'Samsung'.

Is there any way to get the brand without ejecting from Expo? There is this library 'react-native-device-info' but I guess I would have to eject and link using react-native link.

1

1 Answers

-1
votes

If Device name returns always same format starting with first 2 letter as an abbreviation for brand, you can write simple switch statement to get the brand.

I guess this is the best possible option for you.

let deviceName = 'SM-A750GN' 
let brand = deviceName.slice(0,2); // this will give you SM
let realBrand = ''

switch(brand) {
  case "SM":
    realBrand = "Samsung";
    break;
  case "AP":
    realBrand = "Apple";
    break;
  case "LG":
    realBrand = "LG";
    break;
  default:
    realBrand = "Undefined";
}