Skip to content

Commit af230bd

Browse files
authored
Refactoring device heuristics collection to a helper class. (#8432)
* Refactoring device heuristics collection to a helper class.
1 parent 2b58948 commit af230bd

File tree

4 files changed

+88
-9
lines changed

4 files changed

+88
-9
lines changed

FirebaseDynamicLinks/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# v8.7.0
2+
- [added] Refactoring and adding helper class. (#8432)
3+
14
# v8.6.0
25
- [changed] Replaced conditionally-compiled APIs with `API_UNAVAILABLE` annotations on unsupported platforms (#8467).
36

FirebaseDynamicLinks/Sources/FIRDynamicLinkNetworking.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#import "FirebaseDynamicLinks/Sources/GINInvocation/GINArgument.h"
2323
#import "FirebaseDynamicLinks/Sources/GINInvocation/GINInvocation.h"
24+
#import "FirebaseDynamicLinks/Sources/Utilities/FDLDeviceHeuristicsHelper.h"
2425
#import "FirebaseDynamicLinks/Sources/Utilities/FDLUtilities.h"
2526

2627
NS_ASSUME_NONNULL_BEGIN
@@ -207,15 +208,14 @@ - (void)retrievePendingDynamicLinkWithIOSVersion:(NSString *)IOSVersion
207208

208209
NSMutableDictionary *requestBody = [@{
209210
@"bundleId" : [NSBundle mainBundle].bundleIdentifier,
210-
@"device" : @{
211-
@"screenResolutionHeight" : @(resolutionHeight),
212-
@"screenResolutionWidth" : @(resolutionWidth),
213-
@"languageCode" : locale,
214-
@"languageCodeRaw" : localeRaw,
215-
@"languageCodeFromWebview" : localeFromWebView,
216-
@"timezone" : timezone,
217-
@"deviceModelName" : modelName,
218-
},
211+
@"device" :
212+
[FDLDeviceHeuristicsHelper FDLDeviceInfoDictionaryFromResolutionHeight:resolutionHeight
213+
resolutionWidth:resolutionWidth
214+
locale:locale
215+
localeRaw:localeRaw
216+
localeFromWebview:localeFromWebView
217+
timeZone:timezone
218+
modelName:modelName],
219219
@"iosVersion" : IOSVersion,
220220
@"sdkVersion" : FDLSDKVersion,
221221
@"visualStyle" : @(uniqueMatchVisualStyle),
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import <Foundation/Foundation.h>
18+
19+
@interface FDLDeviceHeuristicsHelper : NSObject
20+
21+
/**
22+
* Creates DeviceInfo dictionary based on the provided information.
23+
*/
24+
+ (NSDictionary<NSString *, NSObject *> *)
25+
FDLDeviceInfoDictionaryFromResolutionHeight:(NSInteger)resolutionHeight
26+
resolutionWidth:(NSInteger)resolutionWidth
27+
locale:(NSString *)locale
28+
localeRaw:(NSString *)localeRaw
29+
localeFromWebview:(NSString *)localeFromWebView
30+
timeZone:(NSString *)timezone
31+
modelName:(NSString *)modelName;
32+
33+
@end
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2021 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#import "FirebaseDynamicLinks/Sources/Utilities/FDLDeviceHeuristicsHelper.h"
18+
#import <Foundation/Foundation.h>
19+
20+
@implementation FDLDeviceHeuristicsHelper
21+
22+
/**
23+
* Creates DeviceInfo dictionary based on the provided information.
24+
*/
25+
+ (NSDictionary<NSString *, NSObject *> *)
26+
FDLDeviceInfoDictionaryFromResolutionHeight:(NSInteger)resolutionHeight
27+
resolutionWidth:(NSInteger)resolutionWidth
28+
locale:(NSString *)locale
29+
localeRaw:(NSString *)localeRaw
30+
localeFromWebview:(NSString *)localeFromWebView
31+
timeZone:(NSString *)timezone
32+
modelName:(NSString *)modelName {
33+
return @{
34+
@"screenResolutionHeight" : @(resolutionHeight),
35+
@"screenResolutionWidth" : @(resolutionWidth),
36+
@"languageCode" : locale,
37+
@"languageCodeRaw" : localeRaw,
38+
@"languageCodeFromWebview" : localeFromWebView,
39+
@"timezone" : timezone,
40+
@"deviceModelName" : modelName,
41+
};
42+
}
43+
@end

0 commit comments

Comments
 (0)