naver / egjs-agent

Extracts browser and operating system information from the user agent string or user agent object(userAgentData).
https://naver.github.io/egjs-agent/
MIT License
110 stars 18 forks source link

detect InApp Browser #10

Closed hikaMaeng closed 3 years ago

hikaMaeng commented 7 years ago

Need additional detecting of popular in-app browsers

happyhj commented 7 years ago

Hi @hikaMaeng! Currently we are offering webview property for inApp browser detection. Do you need to detect those in-app browsers seperatly? If you do, let me know by adding comments here.

vreality64 commented 7 years ago

@happyhj webview property have to give more option than now. for example, there is a case for applying other function based on in-app browser version like hotfix. I think it's better eg.Agent give option like plugin to parsing in-app browser version.

when I developing an application on WebView, I temporarily handled app bug in web. At that time, I had experience developing separated features based on in-app versions.

hikaMaeng commented 6 years ago

My Offer is something like

switch(eg.agent().browser.name){
case 'naver_inapp_android':
case 'cacaotalk_inapp_android':
case 'facebook_inapp_android':
...
}

and 3rd party plugin system for additional detection of browser or os or isMobile

eg.agent()
.extendOS({
  criteria: /customOS/,
  identity: "customOS"
})
.extendBrowser({
  criteria:/sony /,
  identity:"sony"
});
happyhj commented 6 years ago

@vreality64 I agree with the requirement to provide the app name and version.

@hikaMaeng Your '3rd party plugin system' looks awesome. This allows you to extend the agent module without modifying the library source.

I will develop both soon.

Will support the following mobile apps with the bundled parsing rule. It is selected according to the number of users.

happyhj commented 6 years ago

The new API will be look like below. And also backward compatibility will be guaranteed.

// Current Usage
eg.agent(); // -> agentInfo from navigate.userAgent
eg.agent(ua) // -> agentInfo from ua

// Extended Usage
const extendedParseRules = {
    os: [{ 
        criteria: /(myownos)\/([\w\.]+)/i, // <-- optional 
        identity: "my own os",
        versionSearch : "os version" // <-- optional 
    }], browser: [{ 
        criteria: /(myownbrowser)\/([\w\.]+)/i,  // <-- optional 
        identity: "my own browser", 
        versionSearch : "browser version" // <-- optional 
    }]
};

cosnt myAgent = new eg.agent(extendedParseRules) // this will custom agent function
myAgent() // -> agentInfo  from navigate.userAgent
var uaString = 'Mozilla/5.0 myownbrowser/1.3';
myAgent(ua) // -> agentInfo  from uaString
hikaMaeng commented 6 years ago

look so good! thanx f rapid feedback!!

ankitch01 commented 6 years ago

In Ios, inappbrowser creates iframe. So you can check that if there is an iframe created in your html that means it is an inappbrowser otherwise its a regular mobile browser.

if(document.getElementById("_cdvIframeBridge")){ alert('its an inappbrowser')}else{ alert('its a mobile browser') }

stale[bot] commented 3 years ago

This issue/PR has been automatically marked as stale because it has not had any update (including commits, comments, labels, milestones, etc) for 30 days. It will be closed automatically if no further update occurs in 7 day. Thank you for your contributions!

한글 이 이슈/PR은 commits, comments, labels, milestones 등 30일간 활동이 없어 자동으로 stale 상태로 전환되었습니다. 이후 7일간 활동이 없다면 자동으로 닫힐 예정입니다. 프로젝트 개선에 기여해주셔서 감사합니다.