Conveniently getting the User Agent through WKWebView

Overview

WebKit User Agent

Requirements

  • iOS 9.0+
  • macOS 10.11+

Installation

See the subsections below for details about the different installation methods.

  1. CocoaPods
  2. Swift Package Manager

CocoaPods

  1. Prepare project for CocoaPods usage by CocoaPods - Install / Get Started
  2. Add pod to project's profile
    pod 'WebKitUserAgent'
  1. LETS ROCK! or install pod
    cd {PATH_TO_PROJECT}
    pod install

Swift Package Manager

  1. Go to project
  2. FileAdd Packages...
  3. Search for library, using URL:
    https://github.com/dmytriigolovanov/webkit-user-agent
  1. Set the Dependency Rule to Up to Next Major Version
  2. Add Package

Using

Import library to needed swift file.

    import WebKitUserAgent

Library provides 2 variants of usage.

  1. With prepared WKWebView.

example:

    let webView = WKWebView(frame: .zero)
    WKUserAgent.getUserAgent(webView: webView) { result in 
        switch result {
        case .success(let userAgent):
            // Get the User Agent
        case .failure(let error):
            // Handle error
        }
    }
  1. With applicationName String value (WKWebView initializes in library). Application name is additional part for User Agent, which will be added at the end of original WebView's User Agent.

example:

    let applicationName = "EXAMPLE/1.0.0"
    
    WKUserAgent.getUserAgent(applicationName: applicationName) { result in 
        switch result {
        case .success(let userAgent):
            // Get the User Agent
        case .failure(let error):
            // Handle error
        }
    }

License

The contents of this repository are licensed under the MIT License.

You might also like...
A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the track of the history of the meetings.
A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the track of the history of the meetings.

Meetings A Meetings app where the user is presented with the number of meetings created , join any them , edit the varied details also keeping the tra

‪‪An app that stores and displays the information entered by the user‬‬

To do list :‬‬ ‪‪An app that stores and displays the information entered by the user‬‬ ‪‪The user can : Add, delete one or clear all , Edit, Show the

iOS App by which the user can display a list of characters from the Harry Potter Movies.

iOS App by which the user can display a list of characters from the Harry Potter Movies. They can display a list of all characters, students, staff or view characters by house.

An App that gives a nice interface where the user can type in their start location and destination

SixtCarSummoner What it does We developed an App that gives a nice interface where the user can type in their start location and destination. The user

Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another city manually.
Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another city manually.

⛅️ Cloudy Weather forecast app that allows the user to either look for weather at their current location based on the GPS data or search for another c

MovieAppSwiftUI - The Application is using TMDB API and Server API to reduce user searching movies resources time with search engine
MovieAppSwiftUI - The Application is using TMDB API and Server API to reduce user searching movies resources time with search engine

MovieAppSwiftUI The Application is using TMDB API and Server API to reduce user searching movies resources time with search engine.This Application is

Stocks-App - App that allows the user to track stocks of their choice
Stocks-App - App that allows the user to track stocks of their choice

Stocks-App App that allows the user to track stocks of their choice (Coming soon

Introducing SwiftUI. A declarative way to create User Interfaces with Swift.

SwiftUI - Landmarks Introducing SwiftUI. A declarative way to create User Interfaces with Swift. SwiftUI was introduced at WWDC 2019 by Apple. It is t

An iOS app that lets user quickly jot down thoughts with Markdown support
An iOS app that lets user quickly jot down thoughts with Markdown support

Thoughtless An iOS app that lets user quickly jot down thoughts with Markdown support. Description Perhaps you are often in a situation where you want

Releases(v4.0.0)
Owner
Dmytrii Golovanov
iOS Engineer
Dmytrii Golovanov
How to handle HelaPay links inside UIWebView and WKWebView

Handling හෙළPay Links Setup Clone this repo. git clone https://github.com/PayHereDevs/helapay-link-handler.git To properly handle හෙළPay Links in you

PayHereDevs 0 Feb 9, 2022
Exposing macOS Services through a Catalyst app

CatalystServices This is a simple example to show how you can implement the macOS Services system in your Catalyst app. The services you expose are pr

Steven Troughton-Smith 33 Oct 26, 2022
Guide users through your SwiftUI app with coach marks

Guide users through your SwiftUI app with coach marks

Jake Heiser 15 Nov 22, 2022
A realistic reflective shimmer to SwiftUI Views that uses device orientation. Position any View relative to device orientation to appear as if through a window or reflected by the screen.

A 3d rotation effect that uses Core Motion to allow SwiftUI views to appear projected in a specific direction and distance relative to the device in r

Ryan Lintott 235 Dec 30, 2022
You can share and communicate with developers around the world through the Fabula app.

FabulaItemsProvider This is the source package for the Fabula project. You can share and communicate with developers around the world through the Fabu

jasu 231 Dec 31, 2022
100-Days-of-SwiftUI - Studying through Paul Hudson's 100 Days of SwiftUI

Hacking with SwiftUI 100 Days of SwiftUI Studying through Paul Hudson's "100 Day

Dean Thompson 3 Aug 29, 2022
This is a project about Swift Student Challenge - WWDC22 [Submitted] Detailed walk through video link below.

Oh My Flag The App Oh My Flag helps students get familiar with flags. It is both educating and entertaining with the design of multi-module and intera

Frank Chu 10 Jun 30, 2022
An iOS app that generates random activities for the user to do. And can be personalized by setting the categories.

RandomActivityApp An iOS app that generates random activities for the user to do. And can be personalized by setting the categories. Created by: Pedro

Pedro Esli 2 Jul 4, 2022
A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI.

?? SwiftUI News App with NewsAPI A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI. ✅ Features The data

Doğancan Mavideniz 5 Nov 15, 2021
Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

Seaglass is a truly native macOS client for Matrix. It is written in Swift and uses the Cocoa user interface framework.

null 1 Jan 17, 2022