How can I get the screen resolution of a device?

Hello everyone! How can I get the screen resolution of a device and then load the game in that resolution?

Example:

  1. If the device’s maximum resolution is 960×540, we load the game in that resolution.
  2. If 1920×1080 is available, we load the game in 1920×1080.

I’m using Cocos Creator v3.8.