Skip to main content

Posts

Showing posts from May, 2019

Swift API Manager -Alamofire-Refresh Token-With TestCases

  import Foundation import KeychainAccess enum APIError : Error { case accessTokenExpired case networkError // Add more error cases as needed } class APIManager { private let keychain = Keychain (service: "com.example.app.refreshToken" ) private let refreshTokenKey = "refreshToken" private var accessToken: String ? func callAPI < T : Codable >( urlString : String , method : String , parameters : [ String : Any ] ? , completion : @escaping ( Result < T , APIError >) -> Void ) { guard let url = URL (string: urlString) else { completion(.failure(.networkError)) return } var request = URLRequest (url: url) request.httpMethod = method // Add access token to the request headers if available if let token = accessToken { request.setValue( "Bearer \(token) " , forHTTPHeaderField: "Aut...

How to Creating A Web Browser With in WKWebView

Create a simple Application open web URL in to WKWebView! or open web Browser WKWebView. iOS Developer Live - There are Two Different Type open url with web view, UIWebView or WKWebView. Before iOS 8.0 Used UIWebView. Now After iOS 8.0 or Later apple introduce A New Claas WKWebView in the Library  WebKit. WKWebView faster to fast load webpage and more batter than UIWebView, its do not overload memory. Example  Add code your ViewController class import UIKit import WebKit class ViewController: UIViewController , WKNavigationDelegate {          var webView : WKWebView !          override func viewDidLoad() {         super . viewDidLoad ()                  // loading URL :         let studyPlusUrl = " https://www.iosdeveloperlive.com/ "         let url = URL (string: ...