D
D
Daulet2020-10-13 13:10:33
Yii
Daulet, 2020-10-13 13:10:33

How can I make the page accessible only through the mobile application?

There is a site on the YII engine, there is a mobile application. There are pages - which we need to show only in the mobile application. For example, for the /index/index pages to be opened through the application, and if through a browser on a PC or phone, then redirect or any other solution.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
coderisimo, 2020-10-13
@coderisimo

There is such a Mobile-Detect thing and even a Yii2 extension for it

V
Vladislav, 2020-10-13
@cr1gger

var userDeviceArray = [
    {device: 'Android', platform: /Android/},
    {device: 'iPhone', platform: /iPhone/},
    {device: 'iPad', platform: /iPad/},
    {device: 'Symbian', platform: /Symbian/},
    {device: 'Windows Phone', platform: /Windows Phone/},
    {device: 'Tablet OS', platform: /Tablet OS/},
    {device: 'Linux', platform: /Linux/},
    {device: 'Windows', platform: /Windows NT/},
    {device: 'Macintosh', platform: /Macintosh/}
];
var platform = navigator.userAgent;

function getPlatform() {
    for (var i in userDeviceArray) {
        if (userDeviceArray[i].platform.test(platform)) {
            return userDeviceArray[i].device;
        }
    }
    return 'Неизвестная платформа!' + platform;
}

console.log('Ваша платформа: ' + getPlatform());

If the platform is not: Android, IOS, Symbian, then redirect

P
Popou, 2020-10-13
@Popou

The dumbest method is sending post data, if not then don't show it, and if through the application then send it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question