Monday, March 4, 2024
HomeiOS DevelopmentImplementing URL-encoded Kind Information Submission in Xamarin.Types WebView for iOS

Implementing URL-encoded Kind Information Submission in Xamarin.Types WebView for iOS


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

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

 public func toUrlEncodedForm() -> Information? {
        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.knowledge(utilizing: .utf8)
    }

This methodology works effectively in Swift, however I must implement an equal answer in Xamarin.Types 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.Types for iOS that generates kind knowledge in URL-encoded format and returns it as an NSData object?



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments