mirror of
https://github.com/VKCOM/vk-ios-sdk.git
synced 2024-09-11 06:45:37 +03:00
Bump target sdk version to 8.0 and migrate to WKWebView
This commit is contained in:
parent
5504d80f2b
commit
5680136d80
@ -1,7 +1,7 @@
|
||||
vk-ios-sdk
|
||||
==========
|
||||
|
||||
Library for working with VK API, authorizing through VK app, using VK API methods. Supported iOS from 6.0
|
||||
Library for working with VK API, authorizing through VK app, using VK API methods. Supported iOS from 8.0
|
||||
Prepare for Using VK SDK
|
||||
----------
|
||||
|
||||
@ -61,7 +61,7 @@ CocoaPods is a dependency manager for Objective-C, which automates and simplifie
|
||||
|
||||
`Podfile`
|
||||
|
||||
platform :ios, '6.0'
|
||||
platform :ios, '8.0'
|
||||
target 'YourProjectName' do
|
||||
pod 'VK-ios-sdk'
|
||||
end
|
||||
|
@ -1,11 +1,11 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "VK-ios-sdk"
|
||||
s.version = "1.4.6"
|
||||
s.version = "1.5.0"
|
||||
s.summary = "Library for working with VK."
|
||||
s.homepage = "https://github.com/VKCOM/vk-ios-sdk"
|
||||
s.license = 'MIT'
|
||||
s.author = { "Roman Truba" => "dreddkr@gmail.com" }
|
||||
s.platform = :ios, '6.0'
|
||||
s.platform = :ios, '8.0'
|
||||
s.source = { :git => "https://github.com/VKCOM/vk-ios-sdk.git", :tag => s.version.to_s }
|
||||
s.source_files = 'library/source/**/*.{h,m}'
|
||||
s.public_header_files = 'library/source/**/*.h'
|
||||
|
@ -12,6 +12,7 @@
|
||||
132CF80019D2B3360084884D /* VKBundle.h in Copy Files */ = {isa = PBXBuildFile; fileRef = F3BACC5618659493003158DA /* VKBundle.h */; };
|
||||
132CF80719D2B3360084884D /* VKPermissions.h in Copy Files */ = {isa = PBXBuildFile; fileRef = F3EEFFA41827B726000BB525 /* VKPermissions.h */; };
|
||||
132CF80A19D2B3360084884D /* VKSdkVersion.h in Copy Files */ = {isa = PBXBuildFile; fileRef = F3EEFFBC1827C582000BB525 /* VKSdkVersion.h */; };
|
||||
15DF536B232BBBE600593625 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 15DF536A232BBBE600593625 /* WebKit.framework */; };
|
||||
183C475918B2F1ED00F978DB /* VKAccessToken.m in Sources */ = {isa = PBXBuildFile; fileRef = F3C7549A18226ABB00964716 /* VKAccessToken.m */; };
|
||||
183C475A18B2F1ED00F978DB /* VKBatchRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = F3D38E7E183F7B4800D05079 /* VKBatchRequest.m */; };
|
||||
183C475B18B2F1ED00F978DB /* VKBundle.m in Sources */ = {isa = PBXBuildFile; fileRef = F3BACC5718659493003158DA /* VKBundle.m */; };
|
||||
@ -330,6 +331,7 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
15DF536A232BBBE600593625 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/WebKit.framework; sourceTree = DEVELOPER_DIR; };
|
||||
1ACA602BF516D3FC45609A2B /* VKAuthorizeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKAuthorizeController.m; sourceTree = "<group>"; };
|
||||
1ACA6041B183FB7781AC6F07 /* VKUploadMessagesPhotoRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKUploadMessagesPhotoRequest.h; sourceTree = "<group>"; };
|
||||
1ACA60549B5805BC010388F6 /* VKCaptchaViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKCaptchaViewController.h; sourceTree = "<group>"; };
|
||||
@ -467,6 +469,7 @@
|
||||
files = (
|
||||
F3C68F171C0C855C00E1EB5E /* Security.framework in Frameworks */,
|
||||
F3769E711BE8E41C00AEC4AF /* SafariServices.framework in Frameworks */,
|
||||
15DF536B232BBBE600593625 /* WebKit.framework in Frameworks */,
|
||||
F3769E6F1BE8E41800AEC4AF /* CoreGraphics.framework in Frameworks */,
|
||||
F346704B1B8B7C70003EF74B /* Foundation.framework in Frameworks */,
|
||||
F346704A1B8B7C6B003EF74B /* UIKit.framework in Frameworks */,
|
||||
@ -723,6 +726,7 @@
|
||||
F3C7542F182133CC00964716 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
15DF536A232BBBE600593625 /* WebKit.framework */,
|
||||
F3C68F161C0C855C00E1EB5E /* Security.framework */,
|
||||
F3769E701BE8E41C00AEC4AF /* SafariServices.framework */,
|
||||
F3769E6E1BE8E41800AEC4AF /* CoreGraphics.framework */,
|
||||
@ -936,6 +940,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
ru,
|
||||
@ -1349,7 +1354,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
@ -1381,7 +1386,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
|
@ -239,6 +239,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
ru,
|
||||
);
|
||||
@ -372,7 +373,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
@ -404,7 +405,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
|
@ -60,10 +60,10 @@ typedef NS_ENUM(NSInteger, VKAuthorizationType) {
|
||||
/**
|
||||
Controller for authorization through webview (if VK app not available)
|
||||
*/
|
||||
@interface VKAuthorizeController : UIViewController <UIWebViewDelegate>
|
||||
@interface VKAuthorizeController : UIViewController
|
||||
|
||||
/**
|
||||
Causes UIWebView in standard UINavigationController be presented in SDK delegate
|
||||
Causes web view in standard UINavigationController be presented in SDK delegate
|
||||
@param appId Identifier of VK application
|
||||
@param permissions Permissions that user specified for application
|
||||
@param revoke If YES, user will see permissions list and allow to logout (if logged in already)
|
||||
@ -75,7 +75,7 @@ Causes UIWebView in standard UINavigationController be presented in SDK delegate
|
||||
displayType:(VKDisplayType)displayType;
|
||||
|
||||
/**
|
||||
Causes UIWebView in standard UINavigationController be presented for user validation
|
||||
Causes web view in standard UINavigationController be presented for user validation
|
||||
@param validationError validation error returned by API
|
||||
*/
|
||||
+ (void)presentForValidation:(VKError *)validationError;
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#import "VKAuthorizeController.h"
|
||||
#import "VKBundle.h"
|
||||
#import <WebKit/WebKit.h>
|
||||
|
||||
NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
|
||||
@ -50,8 +51,8 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
+ (BOOL)processOpenInternalURL:(NSURL *)passedUrl validation:(BOOL)validation;
|
||||
@end
|
||||
|
||||
@interface VKAuthorizeController ()
|
||||
@property(nonatomic, strong) UIWebView *webView;
|
||||
@interface VKAuthorizeController () <WKUIDelegate, WKNavigationDelegate>
|
||||
@property(nonatomic, strong) WKWebView *webView;
|
||||
@property(nonatomic, strong) NSString *appId;
|
||||
@property(nonatomic, strong) NSString *scope;
|
||||
@property(nonatomic, strong) NSURL *redirectUri;
|
||||
@ -157,11 +158,11 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
_warningLabel.text = VKLocalizedString(@"Please check your internet connection");
|
||||
[view addSubview:_warningLabel];
|
||||
|
||||
_webView = [[UIWebView alloc] initWithFrame:view.bounds];
|
||||
_webView.delegate = self;
|
||||
_webView = [[WKWebView alloc] initWithFrame:view.bounds];
|
||||
_webView.UIDelegate = self;
|
||||
_webView.navigationDelegate = self;
|
||||
_webView.hidden = YES;
|
||||
_webView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
|
||||
_webView.scalesPageToFit = YES;
|
||||
_webView.scrollView.bounces = NO;
|
||||
_webView.scrollView.clipsToBounds = NO;
|
||||
[view addSubview:_webView];
|
||||
@ -205,7 +206,8 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
|
||||
#pragma mark Web view work
|
||||
|
||||
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
|
||||
- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
|
||||
NSURLRequest *request = navigationAction.request;
|
||||
self.lastRequest = request;
|
||||
NSString *urlString = [[request URL] absoluteString];
|
||||
self.statusBar.text = urlString;
|
||||
@ -220,12 +222,12 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
[self.validationError.request cancel];
|
||||
}
|
||||
}];
|
||||
return NO;
|
||||
decisionHandler(WKNavigationActionPolicyCancel);
|
||||
}
|
||||
return YES;
|
||||
decisionHandler(WKNavigationActionPolicyAllow);
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
|
||||
- (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
|
||||
if (self.finished) return;
|
||||
if ([error code] != NSURLErrorCancelled) {
|
||||
self.warningLabel.hidden = NO;
|
||||
@ -245,7 +247,7 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
[self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:activityView] animated:YES];
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView *)webView {
|
||||
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
|
||||
[self makeViewport];
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (300 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^(void) {
|
||||
_warningLabel.hidden = YES;
|
||||
@ -256,7 +258,7 @@ NSString *VK_AUTHORIZE_URL_STRING = @"vkauthorize://authorize";
|
||||
|
||||
- (void)makeViewport {
|
||||
NSString *javaScript = [NSString stringWithFormat:@"viewport = document.querySelector('meta[name=viewport]'); viewport.setAttribute('content', 'width = %d, height = %d, initial-scale = 1.0, maximum-scale = 1.0, minimum-scale = 1.0, user-scalable=yes');", (int) self.webView.frame.size.width, (int) self.webView.frame.size.height];
|
||||
[_webView stringByEvaluatingJavaScriptFromString:javaScript];
|
||||
[_webView evaluateJavaScript:javaScript completionHandler:nil];
|
||||
}
|
||||
|
||||
#pragma mark Cancelation and dismiss
|
||||
|
Loading…
Reference in New Issue
Block a user