Express-useragent returning isMobile = false for React Native app

Viewed 252

I am 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,
}

Also the response from Native script app:

{
isYaBrowser: false,
isAuthoritative: true,
isMobile: true,
isMobileNative: true,
}

The code which I've used is as follow:

app.use(useragent.express());

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

I was able to solve this problem from frontend side. In their headers request, they have to send the user-agent explicitly.

 ‘User-Agent’: Platform.OS == ‘ios’
            ? ‘AppName/1.6.4.176 CFNetwork/897.15 Darwin/17.5.0’
            : ‘AppName/1.6.7.42 Dalvik/2.1.0 (Linux; U; Android 5.1.1; Android SDK built for x86 Build/LMY48X)‘
Related