The following sections describe the process of embedding Source Experiences in a mobile device. This is a companion article to How to Embed Source Experiences from this help article.
iOS
Swift is a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV, and Apple Watch. The following code is what is needed to implement for Swift:
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://experience.sourcesync.io/test-watch-and-shop")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
}
Android
Kotlin is a general-purpose, free, open-source, programming language initially designed for Android combining object-oriented and functional programming features. The following code is what is needed to implement for Kotlin:
import android.app.Activity
import android.os.Bundle
import android.util.Base64
import android.view.View
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_home.*
class HomeActivity : AppCompatActivity(), View.OnClickListener {
private var url = "https://experience.sourcesync.io/test-watch-and-shop"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
init()
}
fun init() {
webView.isVerticalScrollBarEnabled = false
webView.isHorizontalScrollBarEnabled = false
webView.settings.domStorageEnabled = true;
webView.settings.javaScriptEnabled = true
webView.settings.javaScriptCanOpenWindowsAutomatically = true
webView.webViewClient = MywebViewClient(this)
webView.webViewClient = WebViewClient()
webView.loadUrl(url)
}
Comments
0 comments
Please sign in to leave a comment.