Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agios 525.swift3.release #91

Merged
merged 3 commits into from
Nov 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion AeroGearPush.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run \'pod install\' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
70053302C71988E02CB5246C /* [CP] Embed Pods Frameworks */ = {
Expand Down
11 changes: 0 additions & 11 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,4 @@ use_frameworks!

target 'AeroGearPushTests' do
pod 'OHHTTPStubs', '5.2.0'
end

# Workaround to fix swift version to 3.0 for Pods.
# it could be removed once CocoaPods 1.1.0 is released.
# https://github.com/CocoaPods/CocoaPods/issues/5521
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['SWIFT_VERSION'] = '3.0'
end
end
end
4 changes: 2 additions & 2 deletions push-sdk-swift/DeviceRegistration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ open class DeviceRegistration: NSObject, URLSessionTaskDelegate {
self.session = Foundation.URLSession(configuration: sessionConfig, delegate: self, delegateQueue: OperationQueue.main)
}

open func overridePushProperties(_ pushProperties: [String: String]) {
open func override(pushProperties: [String: String]) {
overrrideProperties = pushProperties;
}

Expand Down Expand Up @@ -99,7 +99,7 @@ open class DeviceRegistration: NSObject, URLSessionTaskDelegate {
This block has no return value and takes one argument: The `NSError` object describing
the error that occurred during the registration process.
*/
open func registerWithClientInfo(_ clientInfo: ((_ config: ClientDeviceInformation) -> Void)!,
open func register(clientInfo: ((ClientDeviceInformation) -> Void)!,
success:(() -> Void)!, failure:((NSError) -> Void)!) -> Void {

// can't proceed with no configuration block set
Expand Down
4 changes: 2 additions & 2 deletions push-sdk-swift/PushAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ open class PushAnalytics {

:param: completionHandler A block object to be executed when the send metrics operation finishes. Defaulted to no action.
*/
class open func sendMetricsWhenAppLaunched(_ launchOptions: [AnyHashable: Any]?, completionHandler: @escaping ((_ error: NSError? ) -> Void) = {(error: NSError?) in }) {
class open func sendMetricsWhenAppLaunched(launchOptions: [AnyHashable: Any]?, completionHandler: @escaping ((_ error: NSError? ) -> Void) = {(error: NSError?) in }) {
if let options = launchOptions {
if let option : NSDictionary = options[UIApplicationLaunchOptionsKey.remoteNotification] as? NSDictionary {
if let metrics = option["aerogear-push-id"] as? String {
Expand All @@ -52,7 +52,7 @@ open class PushAnalytics {
:param: userInfo contains the message id used to collect metrics.
:param: completionHandler A block object to be executed when the send metrics operation finishes. Defaulted to no action.
*/
class open func sendMetricsWhenAppAwoken(_ applicationState: UIApplicationState, userInfo: [AnyHashable: Any], completionHandler: @escaping ((_ error: NSError? ) -> Void) = {(error: NSError?) in }) {
class open func sendMetricsWhenAppAwoken(applicationState: UIApplicationState, userInfo: [AnyHashable: Any], completionHandler: @escaping ((_ error: NSError? ) -> Void) = {(error: NSError?) in }) {
if applicationState == .inactive || applicationState == .background {
//opened from a push notification when the app was on background
if let messageId = userInfo["aerogear-push-id"] as? String {
Expand Down
44 changes: 22 additions & 22 deletions push-sdk-swiftTests/DeviceRegistrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,21 @@ class DeviceRegistrationTests: XCTestCase {
let registration = DeviceRegistration(serverURL: URL(string: "http://server.com")!)

// attemp to register
registration.registerWithClientInfo({ (clientInfo: ClientDeviceInformation!) in
registration.register(clientInfo: { (config: ClientDeviceInformation!) in

// setup configuration
clientInfo.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
clientInfo.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
clientInfo.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"
config.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
config.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
config.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"

// apply the token, to identify THIS device
let currentDevice = UIDevice()

// --optional config--
// set some 'useful' hardware information params
clientInfo.operatingSystem = currentDevice.systemName
clientInfo.osVersion = currentDevice.systemVersion
clientInfo.deviceType = currentDevice.model
config.operatingSystem = currentDevice.systemName
config.osVersion = currentDevice.systemVersion
config.deviceType = currentDevice.model
},

success: {
Expand Down Expand Up @@ -92,24 +92,24 @@ class DeviceRegistrationTests: XCTestCase {

// setup registration
let registration = DeviceRegistration(config: "pushproperties")
registration.overridePushProperties(["serverURL": "http://serveroverridden.com"])
registration.override(pushProperties: ["serverURL": "http://serveroverridden.com"])

// attemp to register
registration.registerWithClientInfo({ (clientInfo: ClientDeviceInformation!) in
registration.register(clientInfo: { (config: ClientDeviceInformation!) in

// setup configuration
clientInfo.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
clientInfo.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
clientInfo.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"
config.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
config.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
config.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"

// apply the token, to identify THIS device
let currentDevice = UIDevice()

// --optional config--
// set some 'useful' hardware information params
clientInfo.operatingSystem = currentDevice.systemName
clientInfo.osVersion = currentDevice.systemVersion
clientInfo.deviceType = currentDevice.model
config.operatingSystem = currentDevice.systemName
config.osVersion = currentDevice.systemVersion
config.deviceType = currentDevice.model
},

success: {
Expand Down Expand Up @@ -147,21 +147,21 @@ class DeviceRegistrationTests: XCTestCase {
let registration = DeviceRegistration(serverURL: URL(string: "http://server.com")!)

// attemp to register
registration.registerWithClientInfo({ (clientInfo: ClientDeviceInformation!) in
registration.register(clientInfo: { (config: ClientDeviceInformation!) in

// setup configuration
clientInfo.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
clientInfo.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
clientInfo.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"
config.deviceToken = "2c948a843e6404dd013e79d82e5a0009".data(using: String.Encoding.utf8) // dummy token
config.variantID = "8bd6e6a3-df6b-466c-8292-ed062f2427e8"
config.variantSecret = "1c9a6066-e0e5-4bcb-ab78-994335f59874"

// apply the token, to identify THIS device
let currentDevice = UIDevice()

// --optional config--
// set some 'useful' hardware information params
clientInfo.operatingSystem = currentDevice.systemName
clientInfo.osVersion = currentDevice.systemVersion
clientInfo.deviceType = currentDevice.model
config.operatingSystem = currentDevice.systemName
config.osVersion = currentDevice.systemVersion
config.deviceType = currentDevice.model
},

success: {
Expand Down
4 changes: 2 additions & 2 deletions push-sdk-swiftTests/PushAnalyticsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class PushAnalyticsTests: XCTestCase {
var options: [AnyHashable: Any] = [:]
options[UIApplicationLaunchOptionsKey.remoteNotification] = ["aerogear-push-id":"123456"]
// attemp to register
PushAnalytics.sendMetricsWhenAppLaunched(options) { (error) -> Void in
PushAnalytics.sendMetricsWhenAppLaunched(launchOptions: options) { (error) -> Void in
assert(error == nil, "Metrics sent without error")
sendMetricsExpectation.fulfill()
}
Expand All @@ -83,7 +83,7 @@ class PushAnalyticsTests: XCTestCase {
options[UIApplicationLaunchOptionsKey.remoteNotification] = ["aerogear-push-id":"123456"]

// attemp to register
PushAnalytics.sendMetricsWhenAppLaunched(options) { (error) -> Void in
PushAnalytics.sendMetricsWhenAppLaunched(launchOptions: options) { (error) -> Void in
assert(error != nil, "Registration should happen before sending metrics")
sendMetricsExpectation.fulfill()
}
Expand Down