How to handle HelaPay links inside UIWebView and WKWebView

Overview

Handling හෙළPay Links

Setup

Clone this repo.

git clone https://github.com/PayHereDevs/helapay-link-handler.git

To properly handle හෙළPay Links in your iOS WebView project, you will need the following helper class.

helapay-links/HelaPayLinkHandler.swift

Copy it into your Xcode project. Follow one of the following steps, depending on whether you use UIWebView or WKWebView.

For UIWebView

1. Set the web view delegate
class ViewController: UIViewController{
    override func viewWillAppear(_ animated: Bool) {
        // ...

        webView.delegate = self
    }
}
2. Implement the shouldStartLoadWith method
extension ViewController: UIWebViewDelegate{
    func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebView.NavigationType) -> Bool {

        // Important check for external suffix
        if let url = request.url, url.absoluteString.hasSuffix("#HKexternal") {
            HelaPayLinkHandler().handleHelaPayLink(url)
            return false
        }
        else{
            return true;
        }

    }
}

For WKWebView

1. Set the web view navigation delegate
class ViewController: UIViewController{
    override func viewWillAppear(_ animated: Bool) {
        // ...

        webView.navigationDelegate = self
    }
}
2. Implement the decidePolicyFor method
extension ViewController: WKNavigationDelegate{
    func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
        
        // Important check for external suffix
        if let url = navigationAction.request.url, url.absoluteString.hasSuffix("#HKexternal") {
            HelaPayLinkHandler().handleHelaPayLink(url)
            decisionHandler(.cancel)
        }
        else{
            decisionHandler(.allow)
        }
    }
}
You might also like...
This To-Do app was developed using Swift and SwiftUI and works on iOS, MacOS (Apple Silicon) and WatchOS. The tasks are kept on storage even when the app is restarted.

ToDo-SwiftUI This app has a lot of sentimental value for me, given that it helped me a lot to understand the process of doing an iOS app and became th

KHabit an open source, pure and minimalistic app which helps you maintain productive habits, and nothing more.

an open source, pure and minimalistic app which helps you maintain productive habits, and nothing more. The app is completely open source, it does not contain in-app or ads, and does not track the user in any way.

iOS app that detects LaTeX symbols from drawings. Built using PencilKit, SwiftUI, Combine and CoreML for iOS 14 and macOS 11.

DeTeXt Finding the symbol you want to use in LaTeX can be hard since you can't memorize all the possible commands and packages for every symbol you mi

an open source, pure and minimalistic app which helps you maintain productive habits, and nothing more.

KHabit an open source, pure and minimalistic app which helps you maintain productive habits, and nothing more. The app is completely open source, it d

🎮 Favorite your games filter and see the upcoming games and ! Swift + Combine = 💜 Hacktoberfest 🎃 👾
🎮 Favorite your games filter and see the upcoming games and ! Swift + Combine = 💜 Hacktoberfest 🎃 👾

✨ Revill is App to list games and search best games ✨ Design in Swift UI + Combine ✨ The idea is develop this app in Hacktober Fest Expected To Do Des

Native and encrypted password manager for iOS and macOS.
Native and encrypted password manager for iOS and macOS.

Open Sesame Native and encrypted password manager for iOS and macOS. What is it? OpenSesame is a free and powerful password manager that lets you mana

SwiftUI iOS Widget and WatchOS app that randomly shows a word of the day with description and example.
SwiftUI iOS Widget and WatchOS app that randomly shows a word of the day with description and example.

Word Of The Day iOS Widget and WatchOS app made in SwiftUI that displays a random word of the day with description and example of usuage. Requirements

A SwiftUI implementation of React Hooks. Enhances reusability of stateful logic and gives state and lifecycle to function view.

SwiftUI Hooks A SwiftUI implementation of React Hooks. Enhances reusability of stateful logic and gives state and lifecycle to function view. Introduc

iOS App to display game lists and details with the ability to add games to your favorites list and see metacritic ratings.
iOS App to display game lists and details with the ability to add games to your favorites list and see metacritic ratings.

Game Data System - GDS Author: Heitor Silveira ([email protected]) iOS App to view games from various platforms, their description, release

Owner
PayHereDevs
PayHereDevs
Conveniently getting the User Agent through WKWebView

WebKit User Agent Requirements iOS 9.0+ macOS 10.11+ Installation See the subsec

Dmytrii Golovanov 4 Dec 13, 2021
Bookmark important links with categories to read them later on the go!

Kicking Off Hacktoberfest with ACM-VIT! Sticky Links Save link of your favourite websites, articles, videos and pretty much anything! Overview This is

ACM VIT 6 Oct 3, 2022
macOS app to save links for later

Later Later is a SwiftUI, macOS app to store and save links for later use! Why? I was tired of Reddit's terrible post saving, and wanted an easy, conv

null 6 Oct 4, 2022
WeHobby is an IOS application which aims to facilitate the discovery of new hobbies while creating links between users.

???? WeHobby (EN) WeHobby is an IOS application which aims to facilitate the discovery of new hobbies while creating links between users. The issues t

Thomas 2 Dec 8, 2022
Example usage of FingerprintJS Pro inside a iOS WebView.

FingerprintJS Pro iOS Integrations An example app and packages demonstrating FingerprintJS Pro capabilities on the iOS platform. The repository illust

FingerprintJS 34 Nov 30, 2022
Example usage of FingerprintJS Pro inside a iOS WebView.

FingerprintJS Pro iOS Integrations An example app and packages demonstrating FingerprintJS Pro capabilities on the iOS platform. The repository illust

FingerprintJS 34 Nov 30, 2022
Matthew Asaminew 0 Jan 25, 2022
In this mini app covered the concepts like basics of SwiftUI and Navigations and Animations and List with CRUD functions and MVVM and App Launch and App icons adding and also applied persistence using UserDefaults Concept.

TodoList In this application used the concepts from the beginner level project of SwiftUI_Evolve_1 The following concepts covered in this mini app Swi

Sivaram Yadav 2 Dec 4, 2021
Mahmoud-Abdelwahab 5 Nov 23, 2022
An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and more.

SpotifyClone An iOS app that visually clones Spotify's app and consumes the official Spotify's Web API to show(and play) songs, podcasts, artists and

Gabriel Denoni 11 Dec 27, 2021