Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package returning isMobile = false for React Native app #155

Open
ishdutt opened this issue Oct 23, 2021 · 0 comments
Open

Package returning isMobile = false for React Native app #155

ishdutt opened this issue Oct 23, 2021 · 0 comments

Comments

@ishdutt
Copy link

ishdutt commented Oct 23, 2021

I'm getting isMobile = false in the case of react native app from the express-useragent npm module. Although it is working in the case of Native script app.

Attaching the response from both the apps: React Native app response:

{
isYaBrowser: false,
isAuthoritative: false,
isMobile: false,
isMobileNative: false,
isTablet: false,
isiPad: false,
isiPod: false,
isiPhone: false,
isiPhoneNative: false,
isAndroid: false,
isAndroidNative: false,
isBlackberry: false,
isOpera: false,
isIE: false,
isEdge: false,
isIECompatibilityMode: false,
isSafari: false,
isFirefox: false,
isWebkit: false,
isChrome: false,
isKonqueror: false,
isOmniWeb: false,
isSeaMonkey: false,
isFlock: false,
isAmaya: false,
isPhantomJS: false,
isEpiphany: false,
isDesktop: false,
isWindows: false,
isLinux: false,
isLinux64: false,
isMac: false,
isChromeOS: false,
isBada: false,
isSamsung: false,
isRaspberry: false,
isBot: false,
isCurl: false,
isAndroidTablet: false,
isWinJs: false,
isKindleFire: false,
isSilk: false,
isCaptive: false,
isSmartTV: false,
isUC: false,
isFacebook: false,
isAlamoFire: false,
isElectron: false,
silkAccelerated: false,
browser: 'okhttp',
version: '3.12.12',
os: 'unknown',
platform: 'unknown',
geoIp: {},
source: 'okhttp/3.12.12',
isWechat: false
}

Also the response from Native script app:

{
isYaBrowser: false,
isAuthoritative: true,
isMobile: true,
isMobileNative: true,
isTablet: true,
isiPad: false,
isiPod: false,
isiPhone: false,
isiPhoneNative: false,
isAndroid: true,
isAndroidNative: true,
isBlackberry: false,
isOpera: false,
isIE: false,
isEdge: false,
isIECompatibilityMode: false,
isSafari: false,
isFirefox: false,
isWebkit: false,
isChrome: false,
isKonqueror: false,
isOmniWeb: false,
isSeaMonkey: false,
isFlock: false,
isAmaya: false,
isPhantomJS: false,
isEpiphany: false,
isDesktop: false,
isWindows: false,
isLinux: true,
isLinux64: false,
isMac: false,
isChromeOS: false,
isBada: false,
isSamsung: false,
isRaspberry: false,
isBot: false,
isCurl: false,
isAndroidTablet: true,
isWinJs: false,
isKindleFire: false,
isSilk: false,
isCaptive: false,
isSmartTV: false,
isUC: false,
isFacebook: false,
isAlamoFire: false,
isElectron: false,
silkAccelerated: false,
browser: 'unknown',
version: 'unknown',
os: 'Linux',
platform: 'Android',
geoIp: {},
source: 'Dalvik/2.1.0 (Linux; U; Android 11; SM-A305F Build/RP1A.200720.012)',
isWechat: false
}

The code which I've used is the same as mentioned in your docs:

app.use(useragent.express());

app.get('/', function(req, res){
    res.send(req.useragent);
});

My main motive is to get the device from which the request is made and I've used this logic for that:

const source = req.useragent;
const device = source.isMobile ? (source.isiPhone ? devices.iOS : devices.Android) : devices.Web;
@ishdutt ishdutt changed the title Express-useragent returning isMobile = false for React Native app Package returning isMobile = false for React Native app Oct 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ishdutt and others