Branded Mini-Games Support
  • Welcome
  • Branded Mini-Games
    • Create a campaign
      • Method 1
      • Method 2
      • Campaign Types
        • Website
        • Mobile App
        • Playable ads
        • Brand Hosting
    • Game Settings
      • Game Customization: Easy Mode
      • Game Customization: Pro Mode
        • Other Features
      • How to Modify Graphics
      • Configurations
        • Minimum Game Score Setting
        • Using Hearts (Game Life)
      • Activating the prepared game
      • Instant Win
    • Campaign Settings
      • Campaign Profiles and SEO
      • Campaign URL
      • CNAME
      • How to Add a Game to Your Website
      • Deleting Games
    • Page Settings
      • Landing Page
      • Login
      • Results and Calls to Action
        • Leaderboard
        • No Leaderboard
        • Sharing
        • Call-to-Action
      • Changing Background Music and Favicon
      • Coupon
      • Skin Editor
    • Website
      • Website -> Leaderboard
      • Website -> UserID & Leaderboard
      • Website -> Participate & Win
      • Website -> UserID & Webhook
    • Mobile App Settings
      • Android App
      • iPhone iOS App
      • Mobile App -> Leaderboard
      • Mobile App -> UserID & Leaderboard
      • Mobile App -> UserID and Webhook
      • Close button
    • Play & Redeem
      • Select a Service Group
      • Choosing a Login Method & Service Start URL
      • Exchange game points to Shopping credits
      • Exchange game points to Coupons
      • Daily Missions settings for the game
    • UserID & Webhook
      • Website
      • Mobile App
      • Brand Hosting
    • Playable Ads
      • Customer acquisition through events
      • App installation
    • Data & Export
      • Participation
      • Sign up
      • Coupon Management
    • Google Analytics
    • Paid Plan & Publish
      • Publish
      • Subscribing to a Paid Plan
      • Purchase additional CPP
      • Invoice
      • Change credit card, update billing information, cancel service
    • Brand Hosting
      • Add game
      • Server setting test
      • Webhook and return values
  • Run actual Branded Mini-Games.
  • Terms of Use
    • Terms of Use
    • Privacy policy
    • Cookie Policy
    • Data Processor Agreement
    • GDPR
      • Understanding GDPR: Overview of Data Protection Regulation
      • Personal Data and Compliance: Key Considerations
      • GDPR Compliance in Studio Operations: User Sign-Up and Privacy Policies
      • Data Management: Retention, Analytics, and Reporting
    • Coupon Town - Terms and Conditions
  • Game Development Request
  • Deutsche / German
    • Marken-Mini-Spiele
  • Français / French
    • Mini-jeux de Marque
  • Italiano / Italian
    • Mini-Giochi Brandizzati
  • Español / Spanish
    • Mini-Juegos de Marca
  • Português / Portuguese
    • Mini-Jogos de Marca
  • Türkçe / Turkish
    • Markalı Mini Oyunlar
  • हिन्दी / Hindi
    • ब्रांडेड मिनी गेम्स
  • 한국어 / Korean
    • 브랜드 미니 게임
  • 日本語 / Japanese
    • ブランドミニゲーム
  • 简体中文 / Chinese
    • 品牌小游戏
  • Arabic (العربية)
    • ألعاب صغيرة ذات علامة تجارية
Powered by GitBook
On this page
  1. Branded Mini-Games
  2. Mobile App Settings

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

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:

import UIKit
import WebKit

class GameViewController: UIViewController, WKNavigationDelegate {
    
    var webView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Initialize WKWebView
        webView = WKWebView(frame: self.view.frame)
        webView.navigationDelegate = self
        self.view.addSubview(webView)
        
        // Load the URL
        if let url = URL(string: "https://branded.mini-games.io/?php=landing@UserID_Data&campaign_no=0123456") {
            let request = URLRequest(url: url)
            webView.load(request)
        }
    }
    
    // Called when the web content is successfully loaded
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        print("WebView content loaded successfully.")
    }
    
    // Called if the web content fails to load
    func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
        print("Failed to load WebView content: \(error.localizedDescription)")
    }
}

3. Key Explanations

  1. Initialize WKWebView: webView is set up as a WKWebView, filling the entire screen.

  2. Loading the URL: The URLRequest is used to load the specified URL (https://branded.mini-games.io/?php=landing@UserID_Data&campaign_no=0123456).

  3. navigationDelegate: This delegate is used to track the WebView’s state. The didFinish and didFail methods are called when the web content has either successfully loaded or failed.

  4. 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:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
  • 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.

PreviousAndroid AppNextMobile App -> Leaderboard

Last updated 8 months ago