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

Including Oculus Browser #359

Closed
jazilzaim opened this issue Mar 29, 2022 · 4 comments
Closed

Including Oculus Browser #359

jazilzaim opened this issue Mar 29, 2022 · 4 comments

Comments

@jazilzaim
Copy link

With more increase of VR headset sales, it would be nice to include Oculus Browser. Is there any chance someone like me can assist through a PR to include the Oculus Browser in this library?

@quentin-sommer
Copy link
Owner

Hi, you can already access its value directly through the parsing library using the returnFullParser prop
https://github.com/faisalman/ua-parser-js#methods

<UserAgent returnFullParser>
  {parser => (
    {parser.getBrowser().name == "Oculus Browser" && 
      <p>Oculus specific content</p>
    }
  )}
</UserAgent>

Or were you thinking about adding a prop like <UserAgent oculus>?

@jazilzaim
Copy link
Author

Yea I was referring to adding a prop potentially

@quentin-sommer
Copy link
Owner

quentin-sommer commented Mar 30, 2022

I think there are a lot of commonly used browsers which don't have a pre-computed prop for, like Vivaldi, Mobile Safari or Brave for example.

I'm not sure about adding one because it feels arbitrary.
You could implement it building a new context hook on top of the existing one to provide the prop?
Using this example

import React, {useContext} from 'react'
import {UAContext} from '../src'

const UsingContextHook = () => {
  const {uaResults, parser} = useContext(UAContext)
  return {
    parser,
    uaResults: {
      ...uaResults,
      oculus: parser.getBrowser().name === "Oculus Browser"
    }
  }
}

export default UsingContextHook

@jazilzaim
Copy link
Author

Alright thank you! :)

@jazilzaim jazilzaim reopened this Mar 30, 2022
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