Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ ActivityFeed/ActivityFeed.xcworkspace/xcuserdata/ApigeeCorporation.xcuserdatad/x
.build

#Intellij
.idea
.idea
/Samples/ActivityFeed/Pods
/Samples/ActivityFeed/Podfile.lock
7 changes: 6 additions & 1 deletion Samples/ActivityFeed/ActivityFeed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Apigee Inc.";
TargetAttributes = {
6348D95A1C4EAC0B005C978C = {
Expand Down Expand Up @@ -766,8 +766,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down Expand Up @@ -811,8 +813,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -832,6 +836,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
Expand Down
4 changes: 2 additions & 2 deletions Samples/ActivityFeed/Source/UsergridManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import UsergridSDK
/// This class handles the primary communications to the UsergirdSDK.
public class UsergridManager {

static let ORG_ID = "rwalsh"
static let ORG_ID = "rjwalsh"
static let APP_ID = "sandbox"
static let NOTIFIER_ID = "usergridsample"
static let BASE_URL = "https://api.usergrid.com"
static let BASE_URL = "https://apibaas-trial.apigee.net"

static func initializeSharedInstance() {
Usergrid.initSharedInstance(configuration: UsergridClientConfig(orgId: UsergridManager.ORG_ID, appId: UsergridManager.APP_ID, baseUrl: UsergridManager.BASE_URL))
Expand Down
11 changes: 8 additions & 3 deletions Samples/Push/Push.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 0820;
ORGANIZATIONNAME = "Apigee Inc.";
TargetAttributes = {
637A71EF1C5BF7B10056545A = {
Expand Down Expand Up @@ -348,8 +348,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand Down Expand Up @@ -393,8 +395,10 @@
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_IDENTITY = "iPhone Developer";
Expand All @@ -414,16 +418,17 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
637A72031C5BF7B10056545A /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = Source/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.usergridpushsample;
Expand All @@ -436,10 +441,10 @@
637A72041C5BF7B10056545A /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = Source/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.usergrid.usergridpushsample;
Expand Down
4 changes: 2 additions & 2 deletions Samples/Push/Source/UsergridManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ import UsergridSDK
/// This class handles the primary communications to the UsergridSDK.
public class UsergridManager {

static let ORG_ID = "rwalsh"
static let ORG_ID = "rjwalsh"
static let APP_ID = "sandbox"
static let NOTIFIER_ID = "usergridpushsample"
static let BASE_URL = "https://api.usergrid.com"
static let BASE_URL = "https://apibaas-trial.apigee.net"

static func initializeSharedInstance() {
Usergrid.initSharedInstance(configuration: UsergridClientConfig(orgId: UsergridManager.ORG_ID, appId: UsergridManager.APP_ID, baseUrl: UsergridManager.BASE_URL))
Expand Down
2 changes: 1 addition & 1 deletion Source/UsergridAsset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public class UsergridAsset: NSObject, NSCoding {

- parameter aDecoder: The decoder.

- returns: A decoded `UsergridUser` object.
- returns: A decoded `UsergridAsset` object.
*/
required public init?(coder aDecoder: NSCoder) {
guard let filename = aDecoder.decodeObject(forKey: "filename") as? String,
Expand Down
11 changes: 9 additions & 2 deletions Source/UsergridClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ The `UsergridClient` class is the base handler for making client connections to
*/
public class UsergridClient: NSObject, NSCoding {

static let DEFAULT_BASE_URL = "https://api.usergrid.com"
// MARK: - Static Variables -

/// The default base URL for all calls made by the UsergridClient instances.
public static let DEFAULT_BASE_URL = "https://apibaas-trial.apigee.net"

/// The default auth mode used when creating UsergridClient instances.
public static let DEFAULT_AUTH_MODE: UsergridAuthMode = .user

// MARK: - Instance Properties -

Expand Down Expand Up @@ -521,7 +527,8 @@ public class UsergridClient: NSObject, NSCoding {
- parameter completion: The optional completion block that will be called once the request has completed.
*/
public func PUT(_ type: String, jsonBody:[String:Any], completion: UsergridResponseCompletion? = nil) {
guard let uuidOrName = (jsonBody[UsergridEntityProperties.uuid.stringValue] ?? jsonBody[UsergridEntityProperties.name.stringValue]) as? String
guard let uuidOrName = jsonBody[UsergridEntityProperties.uuid.stringValue] as? String
?? jsonBody[UsergridEntityProperties.name.stringValue] as? String
else {
completion?(UsergridResponse(client:self, errorName: "jsonBody not valid.", errorDescription: "The `jsonBody` must contain a valid value for either `uuid` or `name`."))
return
Expand Down
6 changes: 3 additions & 3 deletions Source/UsergridClientConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class UsergridClientConfig : NSObject, NSCoding {
public var baseUrl: String = UsergridClient.DEFAULT_BASE_URL

/// The `UsergridAuthMode` value used to determine what type of token will be sent, if any.
public var authMode: UsergridAuthMode = .user
public var authMode: UsergridAuthMode = UsergridClient.DEFAULT_AUTH_MODE

/// Whether or not the `UsergridClient` current user will be saved and restored from the keychain.
public var persistCurrentUserInKeychain: Bool = true
Expand Down Expand Up @@ -112,7 +112,7 @@ public class UsergridClientConfig : NSObject, NSCoding {

- parameter aDecoder: The decoder.

- returns: A decoded `UsergridUser` object.
- returns: A decoded `UsergridClientConfig` object.
*/
public required init?(coder aDecoder: NSCoder) {
guard let appId = aDecoder.decodeObject(forKey: "appId") as? String,
Expand All @@ -129,7 +129,7 @@ public class UsergridClientConfig : NSObject, NSCoding {
self.baseUrl = baseUrl
self.appAuth = aDecoder.decodeObject(forKey: "appAuth") as? UsergridAppAuth
self.persistCurrentUserInKeychain = aDecoder.decodeBool(forKey: "persistCurrentUserInKeychain")
self.authMode = (UsergridAuthMode(rawValue:aDecoder.decodeInteger(forKey: "authMode")) ?? .none)!
self.authMode = UsergridAuthMode(rawValue:aDecoder.decodeInteger(forKey: "authMode")) ?? UsergridClient.DEFAULT_AUTH_MODE
super.init()
}

Expand Down
3 changes: 2 additions & 1 deletion Source/UsergridDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class UsergridDevice : UsergridEntity {

- parameter aDecoder: The decoder.

- returns: A decoded `UsergridUser` object.
- returns: A decoded `UsergridDevice` object.
*/
required public init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
Expand Down Expand Up @@ -150,6 +150,7 @@ public class UsergridDevice : UsergridEntity {
- Warning: When setting a properties value must be a valid JSON object.

- Example usage:

```
let uuid = usergridDevice["uuid"]
```
Expand Down
3 changes: 2 additions & 1 deletion Source/UsergridEntity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ open class UsergridEntity: NSObject, NSCoding {

- parameter aDecoder: The decoder.

- returns: A decoded `UsergridUser` object.
- returns: A decoded `UsergridEntity` object.
*/
required public init?(coder aDecoder: NSCoder) {
guard let properties = aDecoder.decodeObject(forKey: "properties") as? [String:Any]
Expand Down Expand Up @@ -220,6 +220,7 @@ open class UsergridEntity: NSObject, NSCoding {
Subscript for the `UsergridEntity` class.

- Example usage:

```
let propertyValue = usergridEntity["propertyName"]
usergridEntity["propertyName"] = propertyValue
Expand Down
2 changes: 1 addition & 1 deletion Source/UsergridFileMetaData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class UsergridFileMetaData : NSObject,NSCoding {

- parameter aDecoder: The decoder.

- returns: A decoded `UsergridUser` object.
- returns: A decoded `UsergridFileMetaData` object.
*/
required public init?(coder aDecoder: NSCoder) {
self.eTag = aDecoder.decodeObject(forKey: "etag") as? String
Expand Down
4 changes: 4 additions & 0 deletions Source/UsergridKeychainHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ internal extension UsergridDevice {


static func saveSharedDeviceKeychainItem(_ device:UsergridDevice) {
if (NSClassFromString("XCTest") != nil) {
return
}

var queryAttributes = UsergridDevice.deviceKeychainItem()
queryAttributes[kSecReturnData as String] = (kCFBooleanTrue != nil) as Bool
queryAttributes[kSecReturnAttributes as String] = (kCFBooleanTrue != nil) as Bool
Expand Down
1 change: 1 addition & 0 deletions Source/UsergridRequestManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ final class UsergridRequestManager {
self.client = client

let config = URLSessionConfiguration.default
config.httpMaximumConnectionsPerHost = 20

#if os(tvOS)
config.httpAdditionalHeaders = ["User-Agent": "usergrid-tvOS/v\(UsergridSDKVersion)"]
Expand Down
4 changes: 2 additions & 2 deletions Source/UsergridSessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ extension UsergridSessionDelegate : URLSessionTaskDelegate {

extension UsergridSessionDelegate : URLSessionDataDelegate {

public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Swift.Void) {
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive response: URLResponse, completionHandler: @escaping (URLSession.ResponseDisposition) -> Swift.Void) {
if let requestWrapper = requestDelegates[dataTask.taskIdentifier] {
requestWrapper.response = response
}
completionHandler(Foundation.URLSession.ResponseDisposition.allow)
}

public func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
func urlSession(_ session: URLSession, dataTask: URLSessionDataTask, didReceive data: Data) {
if let requestWrapper = requestDelegates[dataTask.taskIdentifier] {
var mutableData = requestWrapper.responseData != nil ? (NSMutableData(data: requestWrapper.responseData!) as Data) : Data()
mutableData.append(data)
Expand Down
10 changes: 5 additions & 5 deletions Source/UsergridUser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,11 @@ public class UsergridUser : UsergridEntity {
- Warning: When setting a properties value must be a valid JSON object.

- Example usage:
```
let someName = usergridUser["name"]

usergridUser["name"] = someName
```
```
let someName = usergridUser["name"]
usergridUser["name"] = someName
```
*/
override public subscript(propertyName: String) -> Any? {
get {
Expand Down
23 changes: 14 additions & 9 deletions Tests/ASSET_Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,18 @@ import Foundation

class ASSET_Tests: XCTestCase {

static let collectionName = "books"
static let entityUUID = "f4078aca-2fb1-11e5-8eb2-e13f8369aad1"
static let collectionName = "assetTestEntities"
static let pngLocation = "TestAssets/test.png"
static let jpgLocation = "TestAssets/UsergridGuy.jpg"
static let imageName = "test"

override func setUp() {
super.setUp()
Usergrid.initSharedInstance(orgId:ClientCreationTests.orgId, appId: ClientCreationTests.appId)
Usergrid.persistCurrentUserInKeychain = false
Usergrid.authMode = .none
}

override func tearDown() {
Usergrid._sharedClient = nil
Usergrid.authMode = .user
super.tearDown()
}

Expand Down Expand Up @@ -79,15 +77,15 @@ class ASSET_Tests: XCTestCase {
}

func test_IMAGE_UPLOAD() {
let getExpect = self.expectation(description: "\(#function)")
let expect = self.expectation(description: "\(#function)")
let uploadProgress : UsergridAssetRequestProgress = { (bytes,expected) in
print("UPLOAD PROGRESS BLOCK: BYTES:\(bytes) --- EXPECTED:\(expected)")
}
let downloadProgress : UsergridAssetRequestProgress = { (bytes,expected) in
print("DOWNLOAD PROGRESS BLOCK: BYTES:\(bytes) --- EXPECTED:\(expected)")
}

Usergrid.GET(ASSET_Tests.collectionName, uuidOrName:ASSET_Tests.entityUUID) { (response) in
Usergrid.POST(UsergridEntity(type:ASSET_Tests.collectionName)) { response in
XCTAssertTrue(Thread.isMainThread)

let entity = response.first!
Expand Down Expand Up @@ -129,21 +127,28 @@ class ASSET_Tests: XCTestCase {
let downloadedImage = UIImage(data: downloadedAsset!.data)
XCTAssertEqual(UIImagePNGRepresentation(localImage!), UIImagePNGRepresentation(downloadedImage!))
XCTAssertNotNil(downloadedImage)
getExpect.fulfill()

Usergrid.DELETE(entity) { response in
XCTAssertTrue(response.ok)
XCTAssertEqual(response.entity?.uuid, entity.uuid)

expect.fulfill()
}
}
}

}
self.waitForExpectations(timeout: 100, handler: nil)
}

func deleteUser(_ user:UsergridUser,expectation:XCTestExpectation) {
Usergrid._sharedClient.currentUser = nil
user.remove() { removeResponse in
XCTAssertTrue(Thread.isMainThread)
XCTAssertNotNil(removeResponse)
XCTAssertTrue(removeResponse.ok)
XCTAssertNotNil(removeResponse.user)
XCTAssertNotNil(removeResponse.users)
print(removeResponse.error)
expectation.fulfill()
}
}
Expand Down
Loading