You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found this wonderful library while searching for handling user-agent based results in my web application. It worked out of the box for all major browser platforms.
I have a specific requirement to track native application along with web access. This device detector library works pretty well for all popular/public user agents. However I would like to add my custom application for example MyAppName iOS 1.0 and MyAppName Android 1.0 to the list.
I started with creating a custom parser extending ClientParserAbstract and setting custom yml file to fixture.
Then in my application after creating object of DeviceDetector, I called addClientParser method with a new object of my parser class before calling parse() method.
So far no error or warning, and after parse I can use getOs fine. But calling getClient returns a warning Illegal string offset 'regex' in vendor/piwik/device-detector/Parser/ParserAbstract.php on line 260.
Just for trial, I had added same signature in regexes/client/mobile_apps.yml file and it worked exactly how I wanted. But I don't want to modify original regex dataset with my custom signatures.
So either I am missing something or this is not right way to extend library for custom application signatures. Any clue will be highly appreciated.
The text was updated successfully, but these errors were encountered:
You should also extend the core DeviceDetector package and override addClientParser() to push the new ClientParser in front of the array rather than behind, else the Browser parser will match the UserAgent before it even gets to your Parser.
Something like this:
Hi,
I found this wonderful library while searching for handling user-agent based results in my web application. It worked out of the box for all major browser platforms.
I have a specific requirement to track native application along with web access. This device detector library works pretty well for all popular/public user agents. However I would like to add my custom application for example
MyAppName iOS 1.0
andMyAppName Android 1.0
to the list.I started with creating a custom parser extending ClientParserAbstract and setting custom yml file to fixture.
Then in my application after creating object of DeviceDetector, I called addClientParser method with a new object of my parser class before calling
parse()
method.So far no error or warning, and after parse I can use getOs fine. But calling
getClient
returns a warningIllegal string offset 'regex' in vendor/piwik/device-detector/Parser/ParserAbstract.php on line 260
.Just for trial, I had added same signature in
regexes/client/mobile_apps.yml
file and it worked exactly how I wanted. But I don't want to modify original regex dataset with my custom signatures.So either I am missing something or this is not right way to extend library for custom application signatures. Any clue will be highly appreciated.
The text was updated successfully, but these errors were encountered: