Skip to content

Commit

Permalink
fix: deep links previously being ignored (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
levibostian authored Nov 18, 2021
1 parent 7bacf56 commit 2041767
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
5 changes: 2 additions & 3 deletions Sources/MessagingPush/MessagingPush+NotificationCenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ public extension MessagingPush {
return false
}

switch response.actionIdentifier {
case UNNotificationDismissActionIdentifier, UNNotificationDefaultActionIdentifier:
cleanup(pushContent: pushContent)
cleanup(pushContent: pushContent)

switch response.actionIdentifier {
case UNNotificationDefaultActionIdentifier: // push notification was touched.
if let deepLinkurl = pushContent.deepLink {
UIApplication.shared.open(url: deepLinkurl)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Tracking/DeviceInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ internal enum DeviceInfo {
/// Device's model on which SDK is running eg. iPhone12,3
static let deviceInfo: String = UIDevice.deviceModelCode
/// Operating system and version of OS of the Device
static let osInfo : String = "\(UIDevice().systemName) \(UIDevice().systemVersion)"
static let osInfo: String = "\(UIDevice().systemName) \(UIDevice().systemVersion)"
/// Name of customer's application using the SDK
static let customerAppName : String = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? ""
static let customerAppName: String = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? ""
/// Version of the customer's application using the SDK
static let customerAppVersion : String = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
static let customerAppVersion: String = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
}
#endif
9 changes: 3 additions & 6 deletions Sources/Tracking/Extensions/DeviceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@ import Foundation
#if canImport(UIKit)
import UIKit


/**
Extend `UIDevice` to get user's device information such as
device's model. If running on Simulator `deviceModelCode`
will return values like`x86_64` but when running on a device, this function
returns exact device model for example, `iPhone12,3`

Use case :
To get model detail, simply use

let deviceModelInfo = UIDevice.deviceModelCode
*/
public extension UIDevice {

static let deviceModelCode : String = {

static let deviceModelCode: String = {
var systemInfo = utsname()
uname(&systemInfo)
let machineMirror = Mirror(reflecting: systemInfo.machine)
Expand Down
3 changes: 1 addition & 2 deletions Sources/Tracking/Service/HttpClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ extension CIOHttpClient {
let urlSessionConfig = URLSessionConfiguration.ephemeral
let basicAuthHeaderString = "Basic \(getBasicAuthHeaderString(siteId: siteId, apiKey: apiKey))"


urlSessionConfig.allowsCellularAccess = true
urlSessionConfig.timeoutIntervalForResource = 30
urlSessionConfig.timeoutIntervalForRequest = 60
Expand All @@ -128,7 +127,7 @@ extension CIOHttpClient {

return encodedRawHeader.base64EncodedString(options: NSData.Base64EncodingOptions(rawValue: 0))
}

/**
* getUserAgent - To get `user-agent` header value. This value depends on SDK version
* and device detail such as OS version, device model, customer's app name etc
Expand Down
8 changes: 4 additions & 4 deletions Tests/Tracking/Service/HttpClientTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,20 @@ class HttpClientTest: UnitTest {

XCTAssertEqual(actual, expected)
}

func testGetUserAgent() {
let userAgentValue = CIOHttpClient.getUserAgent()

var expectedUserAgent = "Customer.io iOS Client/\(SdkVersion.version)"

#if canImport(UIKit)
let deviceModel = UIDevice.deviceModelCode
let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String ?? ""
let osInfo = "\(UIDevice().systemName) \(UIDevice().systemVersion)"
let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
expectedUserAgent += " (\(deviceModel); \(osInfo)) \(appName)/\(appVersion)"
#endif

XCTAssertEqual(userAgentValue, expectedUserAgent)
}
}

0 comments on commit 2041767

Please sign in to comment.