Skip to content

Commit

Permalink
fix: code warnings with debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed Dec 27, 2023
1 parent 69ff185 commit ce3a481
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 18 deletions.
6 changes: 6 additions & 0 deletions Example/Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import "AppDelegate.h"
#import <AppTrackingTransparency/AppTrackingTransparency.h>
#import <UserNotifications/UserNotifications.h>
#import <GrowingToolsKit/GrowingToolsKit.h>
#import <Bugly/Bugly.h>

Expand Down Expand Up @@ -37,6 +38,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(

[Bugly startWithAppId:@"93004a21ca"];

[UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:UNAuthorizationOptionAlert
completionHandler:^(BOOL granted, NSError * _Nullable error) {

}];

return YES;
}

Expand Down
2 changes: 2 additions & 0 deletions Example/Example/Example.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:testlink.growingio.com</string>
Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ target 'Example' do

# pod 'GrowingToolsKit/SDK30202', :path => './', :configurations => ['Debug']
# pod 'GrowingToolsKit/SDK2nd', :path => './', :configurations => ['Debug']
pod 'GrowingToolsKit/UseInRelease', :path => './'
pod 'GrowingToolsKit', :path => './', :configurations => ['Debug']

end

Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Database/GrowingTKDatabase.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ - (BOOL)vacuum {
return result;
}

static BOOL isExecuteVacuum() {
static BOOL isExecuteVacuum(void) {
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
NSDate *beforeDate = [userDefault objectForKey:@"GrowingTKDatabaseVACUUM"];
NSDate *nowDate = [NSDate date];
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Tools/GrowingTKPermission.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ typedef NS_ENUM(NSUInteger, GrowingTKAuthorizationStatus) {
+ (void)startListenToLocationPermissionDidUpdate:(void(^)(GrowingTKAuthorizationStatus status))didUpdateBlock;

/// 推送权限
+ (GrowingTKAuthorizationStatus)pushPermission;
+ (void)startListenToPushPermissionDidUpdate:(void(^)(GrowingTKAuthorizationStatus status))didUpdateBlock;

/// 相机权限
+ (GrowingTKAuthorizationStatus)cameraPermission;
Expand Down
30 changes: 26 additions & 4 deletions Sources/Core/Tools/GrowingTKPermission.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#import "GrowingTKPermission.h"
#import <UIKit/UIKit.h>
#import <UserNotifications/UserNotifications.h>
#import <CoreLocation/CLLocationManager.h>
#import <AVFoundation/AVFoundation.h>
#import <Photos/Photos.h>
Expand Down Expand Up @@ -107,10 +108,31 @@ + (void)startListenToLocationPermissionDidUpdate:(void(^)(GrowingTKAuthorization
});
}

+ (GrowingTKAuthorizationStatus)pushPermission {
return UIApplication.sharedApplication.currentUserNotificationSettings.types == UIUserNotificationTypeNone
? GrowingTKAuthorizationStatusDenied
: GrowingTKAuthorizationStatusAuthorized;
+ (void)startListenToPushPermissionDidUpdate:(void(^)(GrowingTKAuthorizationStatus status))didUpdateBlock {
if (!didUpdateBlock) {
return;
}
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
[center getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings) {
GrowingTKAuthorizationStatus result = GrowingTKAuthorizationStatusNotDetermined;
switch (settings.authorizationStatus) {
case UNAuthorizationStatusNotDetermined:
result = GrowingTKAuthorizationStatusNotDetermined;
break;
case UNAuthorizationStatusDenied:
result = GrowingTKAuthorizationStatusDenied;
break;
case UNAuthorizationStatusAuthorized:
result = GrowingTKAuthorizationStatusAuthorized;
break;
default:
break;
}

if (didUpdateBlock) {
didUpdateBlock(result);
}
}];
}

+ (GrowingTKAuthorizationStatus)cameraPermission {
Expand Down
12 changes: 4 additions & 8 deletions Sources/Core/Tools/GrowingTKUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,11 @@ + (void)openAppSetting {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url
options:@{}
completionHandler:^(BOOL success) {
[[UIApplication sharedApplication] openURL:url
options:@{}
completionHandler:^(BOOL success) {

}];
} else {
[[UIApplication sharedApplication] openURL:url];
}
}];
}
}

Expand Down
16 changes: 13 additions & 3 deletions Sources/SDKInfo/Controller/GrowingTKSDKInfoViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,7 @@ - (void)initData {
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
self.networkPermission = GrowingTKLocalizedString(@"用户没有选择");
#endif

GrowingTKAuthorizationStatus pushPermission = [GrowingTKPermission pushPermission];
GrowingTKAuthorizationStatus pushPermission = GrowingTKAuthorizationStatusNotDetermined;
GrowingTKAuthorizationStatus cameraPermission = [GrowingTKPermission cameraPermission];
GrowingTKAuthorizationStatus audioPermission = [GrowingTKPermission audioPermission];
GrowingTKAuthorizationStatus photoPermission = [GrowingTKPermission photoPermission];
Expand Down Expand Up @@ -246,7 +245,7 @@ - (void)initData {
#if TARGET_OS_IOS && !TARGET_OS_MACCATALYST
@{@"title": GrowingTKLocalizedString(@"网络权限"), @"value": self.networkPermission}.mutableCopy,
#endif
@{@"title": GrowingTKLocalizedString(@"推送权限"), @"value": @(pushPermission)},
@{@"title": GrowingTKLocalizedString(@"推送权限"), @"value": @(pushPermission)}.mutableCopy,
@{@"title": GrowingTKLocalizedString(@"相机权限"), @"value": @(cameraPermission)},
@{@"title": GrowingTKLocalizedString(@"麦克风权限"), @"value": @(audioPermission)},
@{@"title": GrowingTKLocalizedString(@"相册权限"), @"value": @(photoPermission)},
Expand Down Expand Up @@ -297,6 +296,17 @@ - (void)initData {
});
}];
#endif
[GrowingTKPermission startListenToPushPermissionDidUpdate:^(GrowingTKAuthorizationStatus status) {
__strong typeof(weakSelf) self = weakSelf;
NSMutableDictionary *item = self.dataArray[3][@"array"][2];
[item setValue:@(status) forKey:@"value"];

__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
__strong typeof(weakSelf) self = weakSelf;
[self.tableView reloadData];
});
}];
}

- (UIImage *)snapshot {
Expand Down

0 comments on commit ce3a481

Please sign in to comment.