Skip to content

Commit 877bdae

Browse files
author
“Akshay
committed
APS scanning Improvements
1. isoLatin1 is moved to 2nd position 2. Typecasting now also checks for plist to ensure the typecasting does not resulted in unreadable string and only then, proceeding.
1 parent 8a19e44 commit 877bdae

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

swift-sdk/Internal/APNSTypeChecker.swift

+7-14
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,29 @@ struct APNSTypeChecker: APNSTypeCheckerProtocol {
6666

6767
let encodings: [String.Encoding] = [
6868
.ascii,
69+
.isoLatin1,
6970
.utf8,
7071
.utf16,
7172
.utf16BigEndian,
7273
.utf16LittleEndian,
7374
.utf32,
7475
.utf32BigEndian,
7576
.utf32LittleEndian,
76-
.isoLatin1,
7777
.macOSRoman
7878
]
7979

80-
var asciiString: String?
80+
var plistString: String?
8181

8282
for encoding in encodings {
83-
if let string = String(data: data, encoding: encoding) {
84-
asciiString = string
83+
if let string = String(data: data, encoding: encoding),
84+
let propertyListString = scan(string: string, begin: "<plist", end: "</plist>") {
85+
plistString = propertyListString
8586
break
8687
}
8788
}
8889

89-
guard let finalString = asciiString else {
90-
ITBError("Failed to detect APNS type from provisioning file. Defaulting to type - Production. Please use IterableConfig.pushPlatform to manually set APNS platform type")
91-
return [:]
92-
}
93-
94-
guard let propertyListString = scan(string: finalString, begin: "<plist", end: "</plist>") else {
95-
return [:]
96-
}
97-
98-
guard let propertyListData = propertyListString.data(using: .utf8) else {
90+
guard let propertyListData = plistString?.data(using: .utf8) else {
91+
ITBDebug("Failed to detect APNS type from provisioning file. Defaulting to type - Production. Please use IterableConfig.pushPlatform to manually set APNS platform type")
9992
return [:]
10093
}
10194

0 commit comments

Comments
 (0)