iPhone iOS App
You can create HTML5 mini-games using Studio, activate the game, and obtain a URL link to run it. To add the completed mini-game to an iOS app, the app must support WebView.
Below is an example of code to load and run the URL in an iOS WebView, assuming that you have created a mini-game in Studio and the execution link is: https://branded.mini-games.io/?php=landing@UserID_Data&campaign_no=0123456.
1. Basic Setup for Using WKWebView
WKWebView
First, we’ll show how to add WKWebView
to your project and use it to load and run the HTML5 game.
2. Example Code
Swift Example:
3. Key Explanations
Initialize
WKWebView
:webView
is set up as aWKWebView
, filling the entire screen.Loading the URL: The
URLRequest
is used to load the specified URL (https://branded.mini-games.io/?php=landing@UserID_Data&campaign_no=0123456
).navigationDelegate
: This delegate is used to track the WebView’s state. ThedidFinish
anddidFail
methods are called when the web content has either successfully loaded or failed.Add to the ViewController: The WebView is added to the view controller to make it visible on the screen.
4. Additional Considerations
App Permissions: If you’re using WebView, you may need to update your app’s
Info.plist
file with the App Transport Security settings. If you need to load an HTTP URL, you can add the following keys to allow HTTP:
Error Handling: It's a good practice to handle network errors or failures to access the URL properly with error handling logic.
By using this code, you can load and run an HTML5 mini-game in an iOS app via a WebView.
Last updated