iOS Implementation Guide
Open Xcode and create a new Single View App.
Go to the Storyboard and select the View Controller.
Go to the Editor menu and select Embed in -> Navigation Controller.
In your
ViewController.swiftfile add the following:
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let webView = WKWebView(frame: .zero)
view.addSubview(webView)
let layoutGuide = view.safeAreaLayoutGuide
webView.translatesAutoresizingMaskIntoConstraints = false
webView.leadingAnchor.constraint(
equalTo: layoutGuide.leadingAnchor).isActive = true
webView.trailingAnchor.constraint(
equalTo: layoutGuide.trailingAnchor).isActive = true
webView.topAnchor.constraint(
equalTo: layoutGuide.topAnchor).isActive = true
webView.bottomAnchor.constraint(
equalTo: layoutGuide.bottomAnchor).isActive = true
if let url = URL(string: "<YOUR WEB TICKET SUBMISSION URL WITH PARQEX>") {
webView.load(URLRequest(url: url))
}
}
}This is the basic code for opening your ParqEx main home/dashboard page (which should auto-launch ParqEx) in a webview. If ParqEx is not installed on your web ticket submission page or does not auto-launch, contact your ParqEx tech support ([email protected]). Note: to customize the behavior of the webview in various ways, please consult the documentation.
Passing data to the webview
In certain situations, it is necessary to pass data to ParqEx running in the webview, e.g. to specify user credentials, the language the app is using so ParqEx can be properly localized, or helpful metadata that needs to be included (like mobile platform, app version, user ID, etc.). This can easily be accomplished by setting JS variables on the webpage when launching the webview. Put all your variables in the window.parqexConfig object. If you want the data to be passed directly as certain custom fields, please use the custom field ID as the variable name, as below:
Getting Data From the Webview
Your native app can get certain information/data from ParqEx:
Define a callback function:
Make sure you use the exact name: name: "supportOptionHandler" because that is what ParqEx will call when a support option is clicked by the user.
Now your
ViewController.swiftshould look like this:
Closing the webview to EXIT the parking (white-labeled ParqEx app)
When a user is done using the parking functionality in the app, they can click on the menu, back or home icon to navigate back to the native app. To end the parking session, the webview needs to pass control back to the native app. This happens through another callback function which the ParqEx modal calls. Use the following code to handle that callback:
Please note that the userContentController method is called with only an empty string argument.
Allowing attachments on tickets
If you want to allow Email/Ticket as one of the options for contacting support, and you want to allow the users to add attachments from their local device to the ticket form, then you will need to add the following code:
Intercept URL requests from within a webview
First, make something conform to WKNavigationDelegate. For example:
Second, make that object the navigation delegate of your web view. If you were using your view controller, you’d write this:
Finally, implement the decidePolicyFor method with whatever logic should decide whether the page is loaded normally or execute deep links to app screens. For deep links make sure you call the decisionHandler() closure with .cancel so the load halts.
As an example, this implementation will load all links inside the web view as long as they don’t go to the Apple homepage:
Last updated
Was this helpful?