Skip to content

Commit 8f9cd53

Browse files
committed
Release 1.6.37
1 parent d661098 commit 8f9cd53

File tree

3 files changed

+31
-29
lines changed

3 files changed

+31
-29
lines changed

SensorsAnalyticsSDK/SensorsAnalyticsSDK.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "SensorsAnalyticsSDK"
3-
s.version = "1.6.36"
3+
s.version = "1.6.37"
44
s.summary = "The offical iOS SDK of Sensors Analytics."
55
s.homepage = "http://www.sensorsdata.cn"
66
s.source = { :git => 'https://github.com/sensorsdata/sa-sdk-ios.git', :tag => "v#{s.version}" }

SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
298298
/**
299299
* @abstract
300300
* 重置默认匿名id
301-
*
302-
* @return anonymousId 匿名id
303301
*/
304302
- (void)resetAnonymousId;
305303

@@ -341,7 +339,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
341339
* 特别的,<code>NSSet</code>类型的value中目前只支持其中的元素是<code>NSString</code>
342340
*
343341
* @param event event的名称
344-
* @param propertieDict event的属性
342+
* @param propertyDict event的属性
345343
*/
346344
- (void)track:(NSString *)event withProperties:(NSDictionary *)propertyDict;
347345

@@ -396,7 +394,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
396394
* 这个接口是一个较为复杂的功能,请在使用前先阅读相关说明: http://www.sensorsdata.cn/manual/track_signup.html,并在必要时联系我们的技术支持人员。
397395
*
398396
* @param newDistinctId 用户完成注册后生成的注册ID
399-
* @param propertieDict event的属性
397+
* @param propertyDict event的属性
400398
*/
401399
- (void)trackSignUp:(NSString *)newDistinctId withProperties:(NSDictionary *)propertyDict __attribute__((deprecated("已过时,请参考login")));
402400

@@ -424,7 +422,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
424422
* 这个接口是一个较为复杂的功能,请在使用前先阅读相关说明: https://sensorsdata.cn/manual/track_installation.html,并在必要时联系我们的技术支持人员。
425423
*
426424
* @param event event的名称
427-
* @param propertieDict event的属性
425+
* @param propertyDict event的属性
428426
*/
429427
- (void)trackInstallation:(NSString *)event withProperties:(NSDictionary *)propertyDict;
430428

@@ -469,9 +467,7 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
469467
* Track $AppViewScreen事件
470468
*
471469
* @param url 当前页面url
472-
* @param 用户扩展属性
473-
*
474-
* @return
470+
* @param properties 用户扩展属性
475471
*/
476472
- (void)trackViewScreen:(NSString *)url withProperties:(NSDictionary *)properties;
477473

@@ -651,8 +647,8 @@ typedef NS_ENUM(NSInteger, SensorsAnalyticsTimeUnit) {
651647
* 如前面所述,这个<code>NSSet</code>的元素必须是<code>NSString</code>,否则,会忽略
652648
* 同时,如果要append的Profile之前不存在,会初始化一个空的<code>NSSet</code>
653649
*
654-
* @param profile
655-
* @param content <#content description#>
650+
* @param profile profile
651+
* @param content description
656652
*/
657653
- (void)append:(NSString *)profile by:(NSSet *)content;
658654

SensorsAnalyticsSDK/SensorsAnalyticsSDK/SensorsAnalyticsSDK.m

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
// Created by 曹犟 on 15/7/1.
55
// Copyright (c) 2015年 SensorsData. All rights reserved.
66

7-
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_7_1
8-
#define supportsWKWebKit
9-
#endif
10-
117
#import <objc/runtime.h>
128
#include <sys/sysctl.h>
139

@@ -31,11 +27,7 @@
3127
#import "SensorsAnalyticsSDK.h"
3228
#import "JSONUtil.h"
3329

34-
#if defined(supportsWKWebKit)
35-
#import <WebKit/WebKit.h>
36-
#endif
37-
38-
#define VERSION @"1.6.36"
30+
#define VERSION @"1.6.37"
3931

4032
#define PROPERTY_LENGTH_LIMITATION 8191
4133

@@ -122,6 +114,7 @@ @implementation SensorsAnalyticsSDK {
122114
BOOL _showDebugAlertView;
123115
NSString *_referrerScreenUrl;
124116
NSDictionary *_lastScreenTrackProperties;
117+
BOOL _applicationWillResignActive;
125118
}
126119

127120
static SensorsAnalyticsSDK *sharedInstance = nil;
@@ -242,6 +235,7 @@ - (instancetype)initWithServerURL:(NSString *)serverURL
242235
_showDebugAlertView = YES;
243236
_referrerScreenUrl = nil;
244237
_lastScreenTrackProperties = nil;
238+
_applicationWillResignActive = NO;
245239

246240
_filterControllers = [[NSMutableArray alloc] init];
247241
_dateFormatter = [[NSDateFormatter alloc] init];
@@ -429,27 +423,32 @@ - (BOOL)showUpWebView:(id)webView WithRequest:(NSURLRequest *)request andPropert
429423

430424
NSString *scheme = @"sensorsanalytics://getAppInfo";
431425
NSString *js = [NSString stringWithFormat:@"sensorsdata_app_js_bridge_call_js('%@')", jsonString];
426+
427+
//判断系统是否支持WKWebView
428+
Class wkWebViewClass = NSClassFromString(@"WKWebView");
429+
432430
if ([webView isKindOfClass:[UIWebView class]] == YES) {//UIWebView
433431
SADebug(@"showUpWebView: UIWebView");
434432
if ([request.URL.absoluteString rangeOfString:scheme].location != NSNotFound) {
435433
[webView stringByEvaluatingJavaScriptFromString:js];
436434
return YES;
437435
}
438436
return NO;
439-
}
440-
#if defined(supportsWKWebKit )
441-
else if([webView isKindOfClass:[WKWebView class]] == YES) {//WKWebView
437+
} else if(wkWebViewClass && [webView isKindOfClass:wkWebViewClass] == YES) {//WKWebView
442438
SADebug(@"showUpWebView: WKWebView");
443439
if ([request.URL.absoluteString rangeOfString:scheme].location != NSNotFound) {
444-
[webView evaluateJavaScript:js completionHandler:^(id _Nullable response, NSError * _Nullable error) {
440+
typedef void(^Myblock)(id,NSError *);
441+
Myblock myBlock = ^(id _Nullable response, NSError * _Nullable error){
445442
NSLog(@"response: %@ error: %@", response, error);
446-
}];
443+
};
444+
SEL sharedManagerSelector = NSSelectorFromString(@"evaluateJavaScript:completionHandler:");
445+
if (sharedManagerSelector) {
446+
((void (*)(id, SEL, NSString *, Myblock))[webView methodForSelector:sharedManagerSelector])(webView, sharedManagerSelector, js, myBlock);
447+
}
447448
return YES;
448449
}
449450
return NO;
450-
}
451-
#endif
452-
else{
451+
} else{
453452
SADebug(@"showUpWebView: not UIWebView or WKWebView");
454453
return NO;
455454
}
@@ -1692,6 +1691,12 @@ - (void)applicationWillEnterForeground:(NSNotification *)notification {
16921691
- (void)applicationDidBecomeActive:(NSNotification *)notification {
16931692
SADebug(@"%@ application did become active", self);
16941693

1694+
if (_applicationWillResignActive) {
1695+
_applicationWillResignActive = NO;
1696+
return;
1697+
}
1698+
_applicationWillResignActive = NO;
1699+
16951700
// 是否首次启动
16961701
BOOL isFirstStart = NO;
16971702
if (![[NSUserDefaults standardUserDefaults] boolForKey:@"HasLaunchedOnce"]) {
@@ -1736,12 +1741,13 @@ - (void)applicationDidBecomeActive:(NSNotification *)notification {
17361741

17371742
- (void)applicationWillResignActive:(NSNotification *)notification {
17381743
SADebug(@"%@ application will resign active", self);
1739-
1744+
_applicationWillResignActive = YES;
17401745
[self stopFlushTimer];
17411746
}
17421747

17431748
- (void)applicationDidEnterBackground:(NSNotification *)notification {
17441749
SADebug(@"%@ application did enter background", self);
1750+
_applicationWillResignActive = NO;
17451751

17461752
// 遍历trackTimer
17471753
// eventAccumulatedDuration = eventAccumulatedDuration + timeStamp - eventBegin

0 commit comments

Comments
 (0)