# Client

The Client App should pass the following parameters to the Game Client URL.

**Parameters:**

| Param | Val    | Required | Description                         |
| ----- | ------ | -------- | ----------------------------------- |
| token | String | YES      | The User API Authoriaztion Token    |
| lang  | String | NO       | <p>The Game Lang<br>Default: ar</p> |
|       |        |          |                                     |

**Example**:

```
https://1231example.cloudfront.net/game/index.html
?token=xxxxx&lang=en
```

Once you passed a valid parameters you should see the game started.

### Android API&#x20;

The webview may need to interact with the application for example the webview may send you message in order a player how need to re-charge or it needs the web-view background to be transparent or close the webview<br>

```
webView.addJavascriptInterface(WebAppInterface(view.context), "Android")
inner class WebAppInterface(private val mContext: Context) {
    @JavascriptInterface
    /** 
     The following methods is called by the Web-View
    */
    fun closeWindow() {
        // close webview
        // dismiss()
    }
    @JavascriptInterface
    fun openChargePage() {
        // start charge page activity
    }
    @JavascriptInterface
    fun backgroundTransparent() {
        // set webview background transparent
    }
    
     @JavascriptInterface
    fun orientationLandscape() {
        // set webview background transparent
    }
}
```

**IOS API**

```
1- import WebKit
2- Implement WKUIDelegate ,WKScriptMessageHandler
3- Connect with UI
@IBOutlet weak var webViewContainer: UIView!
4- Define variables

var webView: WKWebView!
var transparentWebView = false


5- First Method : 
override func viewWillAppear(_ animated: Bool) {
        if transparentWebView == true {
            self.webViewTransparent()
        }
    }


6- Handle Transparent case 
func webViewTransparent() {
        webView.backgroundColor = .clear
        webView.isOpaque = false
        view.backgroundColor = .clear
    }


7- Then you can make configuration for webView 
    fileprivate func setupUI() {
        self.title = ""
        let contentController = WKUserContentController()
        contentController.add(
            self,
            name: "Mobile"
        )
        let config = WKWebViewConfiguration()
        config.userContentController = contentController
        webView = WKWebView(frame: webViewContainer.bounds, configuration: config)
        webView.translatesAutoresizingMaskIntoConstraints = false
        webViewContainer.addSubview(webView)
        webV1- import WebKit


2- Implement WKUIDelegate ,WKScriptMessageHandler


3- Connect with UI
@IBOutlet weak var webViewContainer: UIView!


4- Define variables
var webView: WKWebView!
var transparentWebView = false


5- First Method : 
override func viewWillAppear(_ animated: Bool) {
        if transparentWebView == true {
            self.webViewTransparent()
        }
    }


6- Handle Transparent case 
func webViewTransparent() {
        webView.backgroundColor = .clear
        webView.isOpaque = false
        view.backgroundColor = .clear
    }


7- Then you can make configuration for webView 
    fileprivate func setupUI() {
        self.title = ""
        let contentController = WKUserContentController()
        contentController.add(
            self,
            name: "Mobile"
        )
        let config = WKWebViewConfiguration()
        config.userContentController = contentController
        webView = WKWebView(frame: webViewContainer.bounds, configuration: config)
        webView.translatesAutoresizingMaskIntoConstraints = false
        webViewContainer.addSubview(webView)
        webView.leadingAnchor.constraint(equalTo: webViewContainer.leadingAnchor, constant: 0).isActive = true
        webView.trailingAnchor.constraint(equalTo: webViewContainer.trailingAnchor, constant: 0).isActive = true
        webView.topAnchor.constraint(equalTo: webViewContainer.topAnchor, constant: 0).isActive = true
        webView.bottomAnchor.constraint(equalTo: webViewContainer.bottomAnchor, constant: 0).isActive = true
        webView.navigationDelegate = self
        webView.uiDelegate = self
     
        if let urlPath = URL(string: url) {
            webView.load(URLRequest(url: urlPath))
        }
    }


8- You can call this message to handle response 
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        getMessageData(message: message)
    }


9- Then handle getMessage method 
func getMessageData(message: WKScriptMessage) {
        guard let data = message.body as? NSDictionary else {return}
if let methodName = data["method_name"] as? String {
switch methodName {
case "closeWindow":
                navigationController?.popViewController(animated: true)
                dismiss(animated: true, completion: nil)
case "openChargePage":
                let view = WalletRouter.createModule()
                navigationController?.pushViewController(view, animated: true)
case "backgroundTransparent":
                hideNavigationBar()
                webViewTransparent()
}
}
}iew.leadingAnchor.constraint(equalTo: webViewContainer.leadingAnchor, constant: 0).isActive = true
        webView.trailingAnchor.constraint(equalTo: webViewContainer.trailingAnchor, constant: 0).isActive = true
        webView.topAnchor.constraint(equalTo: webViewContainer.topAnchor, constant: 0).isActive = true
        webView.bottomAnchor.constraint(equalTo: webViewContainer.bottomAnchor, constant: 0).isActive = true
        webView.navigationDelegate = self
        webView.uiDelegate = self
     
        if let urlPath = URL(string: url) {
            webView.load(URLRequest(url: urlPath))
        }
    }


8- You can call this message to handle response 
func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
        getMessageData(message: message)
    }


9- Then handle getMessage method 
func getMessageData(message: WKScriptMessage) {
        guard let data = message.body as? NSDictionary else {return}
if let methodName = data["method_name"] as? String {
switch methodName {
case "closeWindow":
                navigationController?.popViewController(animated: true)
                dismiss(animated: true, completion: nil)
case "openChargePage":
                let view = WalletRouter.createModule()
                navigationController?.pushViewController(view, animated: true)
case "backgroundTransparent":
                hideNavigationBar()
                webViewTransparent()
}
}
}
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.game-ox.com/documentation/client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
