Skip to content

Commit

Permalink
Update example to 1.2 version
Browse files Browse the repository at this point in the history
  • Loading branch information
MageSantana committed Jun 14, 2022
1 parent ede4743 commit 589fe3f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 30 deletions.
19 changes: 12 additions & 7 deletions webViewSample/webViewSample.xcodeproj/project.pbxproj
Expand Up @@ -113,11 +113,12 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0940;
LastUpgradeCheck = 0940;
LastUpgradeCheck = 1340;
ORGANIZATIONNAME = "Lyra Network";
TargetAttributes = {
A66D4B2B214A6B19000A9334 = {
CreatedOnToolsVersion = 9.4.1;
LastSwiftMigration = 1340;
};
};
};
Expand Down Expand Up @@ -212,6 +213,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -237,7 +239,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -272,6 +274,7 @@
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
Expand All @@ -291,7 +294,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.4;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
Expand All @@ -307,14 +310,15 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = YNB6GZCAPQ;
INFOPLIST_FILE = webViewSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.lyra.webViewSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -326,14 +330,15 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = YNB6GZCAPQ;
INFOPLIST_FILE = webViewSample/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = com.lyra.webViewSample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
Expand Up @@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>webViewSample.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
2 changes: 1 addition & 1 deletion webViewSample/webViewSample/AppDelegate.swift
Expand Up @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
Expand Down
12 changes: 6 additions & 6 deletions webViewSample/webViewSample/Info.plist
Expand Up @@ -17,11 +17,16 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.1</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -41,10 +46,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
Expand Up @@ -35,7 +35,7 @@ struct PaymentInformation {
//MARK: - PaymentProviderDelegate protocol

/// Protocol for notifying the completion of the payment process. Client applications must conform this protocol.
protocol PaymentProviderDelegate: class {
protocol PaymentProviderDelegate: AnyObject {

/// Method to notifying classes that conform the protocol when the payment process is complete
///
Expand Down Expand Up @@ -116,8 +116,8 @@ class PaymentProvider: PaymentDelegate {
var redirectionUrl = ""
var errorMsg = ""
if let jsonResponse = json {
redirectionUrl = (jsonResponse!["redirectionUrl"] as? String)!
errorMsg = (jsonResponse!["errorMessage"] as? String)!
redirectionUrl = (jsonResponse["redirectionUrl"] as? String)!
errorMsg = (jsonResponse["errorMessage"] as? String)!
}
switch(httpResponse.statusCode){
case 200:
Expand Down Expand Up @@ -157,6 +157,7 @@ class PaymentProvider: PaymentDelegate {
controller.paymentInfo = self.paymentInfo
controller.urlPayment = redirectUrl
controller.paymentDelegate = self
controller.modalPresentationStyle = .fullScreen
contextView.present(controller, animated: true, completion: nil)
}
}
Expand Down
Expand Up @@ -12,7 +12,7 @@ import WebKit
//MARK: PaymentDelegate protocol

/// Protocol for notifying the completion of the payment process via WebView. PaymentProvider class conform this protocol.
protocol PaymentDelegate: class {
protocol PaymentDelegate: AnyObject {
func didPaymentProcessFinish(error: NSError?)
}

Expand Down Expand Up @@ -51,14 +51,13 @@ class PaymentViewController: UIViewController{
let req = NSURLRequest(url:url! as URL)

// We create and load a webview pointing to this Url
self.automaticallyAdjustsScrollViewInsets = false
self.navigationController?.isNavigationBarHidden = true;
self.webView!.load(req as URLRequest)
self.webView.addObserver(self, forKeyPath: #keyPath(WKWebView.loading), options: .new, context: nil)
self.webView.addObserver(self, forKeyPath: #keyPath(WKWebView.isLoading), options: .new, context: nil)
}

deinit{
webView.removeObserver(self, forKeyPath: #keyPath(WKWebView.loading))
webView.removeObserver(self, forKeyPath: #keyPath(WKWebView.isLoading))
webView.navigationDelegate = nil
webView.scrollView.delegate = nil
webView.removeFromSuperview()
Expand All @@ -71,7 +70,7 @@ class PaymentViewController: UIViewController{
self.webView = WKWebView()
self.webView.navigationDelegate = self
self.webView.scrollView.frame = self.webView.frame
self.webView.scrollView.contentInset = UIEdgeInsetsMake(20,0,0,0)
self.webView.scrollView.contentInset = UIEdgeInsets.init(top:20, left:0, bottom:0, right:0)
self.webView.scrollView.delegate = self
self.webView.scrollView.bounces = false
self.webView.allowsBackForwardNavigationGestures = true // Enable/Disable swiping to navigate
Expand Down Expand Up @@ -161,15 +160,15 @@ class PaymentViewController: UIViewController{

self.hideActivityIndicator()
//create activity indicator view
activityIndicatorView = UIActivityIndicatorView(activityIndicatorStyle: .gray)
activityIndicatorView = UIActivityIndicatorView(style: .gray)
activityIndicatorView?.color = UIColor.black
activityIndicatorView?.hidesWhenStopped = true
//adding activity indicator in view
self.view.addSubview(activityIndicatorView!)
//adding constraint to activity indicator for center in view
activityIndicatorView?.translatesAutoresizingMaskIntoConstraints = false
view.addConstraint(NSLayoutConstraint(item: activityIndicatorView!, attribute: NSLayoutAttribute.centerX, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerX, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: activityIndicatorView!, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: view, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: activityIndicatorView!, attribute: NSLayoutConstraint.Attribute.centerX, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.centerX, multiplier: 1, constant: 0))
view.addConstraint(NSLayoutConstraint(item: activityIndicatorView!, attribute: NSLayoutConstraint.Attribute.centerY, relatedBy: NSLayoutConstraint.Relation.equal, toItem: view, attribute: NSLayoutConstraint.Attribute.centerY, multiplier: 1, constant: 0))

//starting activity indicator
activityIndicatorView?.startAnimating()
Expand Down Expand Up @@ -212,7 +211,7 @@ extension PaymentViewController: WKNavigationDelegate{
// We detect a page that should be open in a separate browser
}else if isUrlToOpenedSeparately(url: (navigationAction.request.url?.absoluteString)!) {
decisionHandler(.cancel)
UIApplication.shared.openURL(navigationAction.request.url!)
UIApplication.shared.open(navigationAction.request.url!)
// We detect that a link in expiration page have been cliked
}else{
decisionHandler(.allow)
Expand Down
8 changes: 4 additions & 4 deletions webViewSample/webViewSample/ViewController.swift
Expand Up @@ -64,13 +64,13 @@ class ViewController: UIViewController {

let cardTypesController = UIAlertController(title: "Cards Types", message: "Select the supported card types", preferredStyle: .actionSheet)

let allCardSupportedAction = UIAlertAction(title: "All", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("All", for: UIControlState.normal)
let allCardSupportedAction = UIAlertAction(title: "All", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("All", for: UIControl.State.normal)
})

let visaCardSupportedAction = UIAlertAction(title: "Visa", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("Visa", for: UIControlState.normal)
let visaCardSupportedAction = UIAlertAction(title: "Visa", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("Visa", for: UIControl.State.normal)
})

let mastercardCardSupportedAction = UIAlertAction(title: "Mastercard", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("Mastercard", for: UIControlState.normal)
let mastercardCardSupportedAction = UIAlertAction(title: "Mastercard", style: .default, handler:{(action) -> Void in self.btnSelectCardTypes.setTitle("Mastercard", for: UIControl.State.normal)
})

let cancelAction = UIAlertAction(title: "Cancel", style: .default, handler:nil)
Expand Down Expand Up @@ -101,7 +101,7 @@ extension ViewController: PaymentProviderDelegate {
message = "Payment failed. \(error.userInfo[NSLocalizedFailureReasonErrorKey] as! String)"

}
let alert = UIAlertController(title: "Information", message: message, preferredStyle: UIAlertControllerStyle.alert)
let alert = UIAlertController(title: "Information", message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler:nil))
self.present(alert, animated: true, completion: nil)
}
Expand Down

0 comments on commit 589fe3f

Please sign in to comment.