Skip to content

Commit 2dc990b

Browse files
committed
removed uncessary code
1 parent 146a84a commit 2dc990b

File tree

1 file changed

+7
-76
lines changed

1 file changed

+7
-76
lines changed

src/ios/CDVPassbook.m

Lines changed: 7 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
#import "CDVPassbook.h"
22
#import <Cordova/CDV.h>
33
#import <PassKit/PassKit.h>
4-
#import <WebKit/WebKit.h>
54

65
NSString * const UserAgentHeader = @"User-Agent";
76
NSString * const PasskitAgentHeader = @"Passbook/1.0 CFNetwork/672.0.2 Darwin/14.0.0";
87

98
typedef void (^AddPassResultBlock)(PKPass *pass, BOOL added);
109
typedef void (^AddPassesResultBlock)(NSArray<PKPass *> *passes, BOOL added);
1110

12-
@interface CDVPassbook()<PKAddPassesViewControllerDelegate, WKNavigationDelegate>
11+
@interface CDVPassbook()<PKAddPassesViewControllerDelegate>
1312

1413
@property (nonatomic, retain) PKPass *lastPass;
1514
@property (nonatomic, retain) NSArray<PKPass *> *lastPasses;
16-
@property (nonatomic, retain) id<WKNavigationDelegate> navigationDelegate;
1715
@property (nonatomic, copy) AddPassResultBlock lastAddPassCallback;
1816
@property (nonatomic, copy) AddPassesResultBlock lastAddPassesCallback;
1917

@@ -40,15 +38,15 @@ @implementation CDVPassbook
4038
@synthesize lastPasses;
4139
@synthesize lastAddPassCallback;
4240
@synthesize lastAddPassesCallback;
43-
@synthesize navigationDelegate;
4441

45-
- (void)pluginInitialize
42+
- (BOOL)shouldOverrideLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
4643
{
47-
if ([self.webView isKindOfClass:[WKWebView class]]) {
48-
WKWebView * webView = (WKWebView*)self.webView;
49-
self.navigationDelegate = webView.navigationDelegate;
50-
webView.navigationDelegate = self;
44+
if(PKPassLibrary.isPassLibraryAvailable && [request.URL.pathExtension isEqualToString:@"pkpass"]) {
45+
[self downloadPass:request.URL headers:nil success:nil error:nil];
46+
return YES;
5147
}
48+
49+
return NO;
5250
}
5351

5452
+ (BOOL)available
@@ -445,71 +443,4 @@ -(void)addPassesViewControllerDidFinish:(PKAddPassesViewController *)controller
445443
}];
446444
}
447445

448-
# pragma mark - WKNavigationDelegate
449-
450-
- (void) webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
451-
{
452-
if (navigationAction.navigationType == WKNavigationTypeLinkActivated && PKPassLibrary.isPassLibraryAvailable && [navigationAction.request.URL.pathExtension isEqualToString:@"pkpass"]) {
453-
[self downloadPass:navigationAction.request.URL headers:nil success:nil error:nil];
454-
decisionHandler(WKNavigationActionPolicyCancel);
455-
return;
456-
}
457-
458-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:decidePolicyForNavigationAction:decisionHandler:)]) {
459-
[self.navigationDelegate webView:webView decidePolicyForNavigationAction:navigationAction decisionHandler:decisionHandler];
460-
} else {
461-
decisionHandler(WKNavigationActionPolicyAllow);
462-
}
463-
}
464-
465-
- (void) webView:(WKWebView *)webView didCommitNavigation:(null_unspecified WKNavigation *)navigation
466-
{
467-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didCommitNavigation:)]) {
468-
[self.navigationDelegate webView:webView didCommitNavigation:navigation];
469-
}
470-
}
471-
472-
- (void) webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
473-
{
474-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didFinishNavigation:)]) {
475-
[self.navigationDelegate webView:webView didFinishNavigation:navigation];
476-
}
477-
}
478-
479-
- (void) webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error
480-
{
481-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didFailNavigation:withError:)]) {
482-
[self.navigationDelegate webView:webView didFailNavigation:navigation withError:error];
483-
}
484-
}
485-
486-
- (void) webViewWebContentProcessDidTerminate:(WKWebView *)webView
487-
{
488-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webViewWebContentProcessDidTerminate:)]) {
489-
[self.navigationDelegate webViewWebContentProcessDidTerminate:webView];
490-
}
491-
}
492-
493-
- (void) webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
494-
{
495-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didStartProvisionalNavigation:)]) {
496-
[self.navigationDelegate webView:webView didStartProvisionalNavigation:navigation];
497-
}
498-
}
499-
500-
- (void) webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation withError:(NSError *)error
501-
{
502-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didFailProvisionalNavigation:withError:)]) {
503-
[self.navigationDelegate webView:webView didFailProvisionalNavigation:navigation withError:error];
504-
}
505-
}
506-
507-
- (void) webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
508-
{
509-
if (self.navigationDelegate && [self.navigationDelegate respondsToSelector:@selector(webView:didReceiveServerRedirectForProvisionalNavigation:)]) {
510-
[self.navigationDelegate webView:webView didReceiveServerRedirectForProvisionalNavigation:navigation];
511-
}
512-
}
513-
514-
515446
@end

0 commit comments

Comments
 (0)