4.1 C
London
Monday, March 4, 2024

Implementing URL-encoded Kind Knowledge Submission in Xamarin.Kinds WebView for iOS


I am making an attempt to make a POST request in a WebView in Xamarin.Kinds for iOS. I’ve already applied the WkWebViewRenderer and WebViewRenderer renderers as per the reply right here. This implementation works wonderful on Android, however on iOS, I am encountering a difficulty.

I have to carry out a form-data submission within the POST request. I’ve discovered a local methodology in Swift that converts information into URL-encoded format and returns a Knowledge object. The Swift methodology is as follows:
https://github.com/asjservicios/pluspagosfirm/blob/grasp/PlusPagosFirm/Lessons/FormularioModel.swift

 public func toUrlEncodedForm() -> Knowledge? {
        var allowed = CharacterSet.alphanumerics
        allowed.insert(charactersIn: "-._~")
        
        if hash == nil {
            hash = SHA256Firm.getFirm(ipClient: ip, secretKey: secretKey, guidComercio: comercio, sucursalId: sucursalComercio, monto: monto)
        }
        
        var r = "";
        r += "Hash=(hash!.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        r += "TransaccionComercioId=(transaccionComercioId.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        r += "COMERCIO=(comercio.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        
        var i = 0
        for p in producto {
            r += "Producto[(i)]".addingPercentEncoding(withAllowedCharacters: allowed)! + "=(p.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
            i += 1
        }
        
        r += "Monto=(AESEncrypter.encryptString(plainText: monto, phrase: secretKey)!.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        r += "SucursalComercio=(AESEncrypter.encryptString(plainText: sucursalComercio, phrase: secretKey)!.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        r += "CallbackCancel=(AESEncrypter.encryptString(plainText: callbackCancel, phrase: secretKey)!.addingPercentEncoding(withAllowedCharacters: allowed)!)&"
        r += "CallbackSuccess=(AESEncrypter.encryptString(plainText: callbackSuccess, phrase: secretKey)!.addingPercentEncoding(withAllowedCharacters: allowed)!)"
        
        return r.information(utilizing: .utf8)
    }

This methodology works nicely in Swift, however I have to implement an equal resolution in Xamarin.Kinds for iOS. I’ve tried a number of approaches, however have not been capable of finding an answer that works.

Might somebody present steerage on how I can implement the same methodology in Xamarin.Kinds for iOS that generates type information in URL-encoded format and returns it as an NSData object?

Latest news
Related news

LEAVE A REPLY

Please enter your comment!
Please enter your name here