Skip to content

Commit a81f0f8

Browse files
authored
Merge pull request #796 from Iterable/MOB-9247-BugFix-Push-iOSBeta
[MOB-9247] - Bug fix for no push on APNS SANDBOX
2 parents 8d2bb0f + 877bdae commit a81f0f8

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

swift-sdk/Internal/APNSTypeChecker.swift

+24-4
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,36 @@ struct APNSTypeChecker: APNSTypeCheckerProtocol {
5959
}
6060

6161
static func readMobileProvision(fromPath path: String) -> [AnyHashable: Any] {
62-
guard let asciiString = try? String(contentsOfFile: path, encoding: .ascii) else {
62+
guard let data = try? Data(contentsOf: URL(fileURLWithPath: path)) else {
6363
ITBError("Could not read file: \(path)")
6464
return [:]
6565
}
66+
67+
let encodings: [String.Encoding] = [
68+
.ascii,
69+
.isoLatin1,
70+
.utf8,
71+
.utf16,
72+
.utf16BigEndian,
73+
.utf16LittleEndian,
74+
.utf32,
75+
.utf32BigEndian,
76+
.utf32LittleEndian,
77+
.macOSRoman
78+
]
6679

67-
guard let propertyListString = scan(string: asciiString, begin: "<plist", end: "</plist>") else {
68-
return [:]
80+
var plistString: String?
81+
82+
for encoding in encodings {
83+
if let string = String(data: data, encoding: encoding),
84+
let propertyListString = scan(string: string, begin: "<plist", end: "</plist>") {
85+
plistString = propertyListString
86+
break
87+
}
6988
}
7089

71-
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")
7292
return [:]
7393
}
7494

0 commit comments

Comments
 (0)