Skip to content

Commit

Permalink
Merge pull request #67 from qonversion/release/2.2.0
Browse files Browse the repository at this point in the history
Release/2.2.0
  • Loading branch information
smejl authored Sep 20, 2020
2 parents ae43f13 + 3eec72d commit 1b8c87e
Show file tree
Hide file tree
Showing 61 changed files with 407 additions and 267 deletions.
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Framework/QonverisonFramework.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <Qonversion/Qonversion.h>

#import <Qonversion/QNLaunchResult.h>
#import <Qonversion/QNPermission.h>
#import <Qonversion/QNProduct.h>
#import <Qonversion/QNStoreKitSugare.h>
#import <Qonversion/QNConstants.h>
#import <Qonversion/QNErrors.h>

12 changes: 4 additions & 8 deletions Framework/Qonversion.modulemap
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
framework module Qonversion {
header "Qonversion.h"
header "QNLaunchResult.h"
header "QNPermission.h"
header "QNProduct.h"

export *
framework module Qonverison {
umbrella header "QonverisonFramework.h"

export *
}

19 changes: 19 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "Qonversion",
products: [
.library(
name: "Qonversion",
targets: ["Qonversion"]),
],
targets: [
.target(
name: "Qonversion",
exclude: [],
publicHeadersPath: "."),
]
)
9 changes: 5 additions & 4 deletions Qonversion.podspec
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
Pod::Spec.new do |s|
s.name = 'Qonversion'
s.version = '2.1.0'
s.version = '2.2.0'
s.summary = 'qonversion.io'
s.description = <<-DESC
Deep Analytics for iOS Subscriptions
Qonversion is the data platform to power in-app subscription revenue growth. Qonversion allows fast in-app subscriptions implementation. It provides the back-end infrastructure to validate user receipts and manage cross-platform user access to paid content on your app, so you do not need to build your own server. Qonversion also provides comprehensive subscription analytics and out-of-the-box integrations with the leading marketing, attribution, and product analytics platforms.
DESC
DESC
s.homepage = 'https://github.com/qonversion/qonversion-ios-sdk'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Qonversion Inc.' => '[email protected]' }
s.source_files = 'Sources/Qonversion/*.{h,m}'
s.source = { :git => 'https://github.com/qonversion/qonversion-ios-sdk.git', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
s.source_files = 'Sources/**/*'

s.requires_arc = true
end
254 changes: 130 additions & 124 deletions Qonversion.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1130"
LastUpgradeVersion = "1170"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
1 change: 1 addition & 0 deletions QonversionTests/QonversionMapperTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "QNTestConstants.h"

#import "QNMapperObject.h"
#import "QNPermission.h"
#import "QNLaunchResult.h"

@interface QNMapperTests : XCTestCase
Expand Down
2 changes: 1 addition & 1 deletion QonversionTests/QonversionTests.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import <XCTest/XCTest.h>
#import <OCMock/OCMock.h>

#import "Qonversion.h"

#import "XCTestCase+TestJSON.h"

@interface Qonversion (Tests)
Expand Down
34 changes: 0 additions & 34 deletions Sources/Network/Models/QNLaunchResult.h

This file was deleted.

7 changes: 0 additions & 7 deletions Sources/Network/Models/QNProduct+Protected.h

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "Qonversion.h"
#import "Foundation/Foundation.h"
#import "QNLaunchResult.h"

@class SKProduct, SKPaymentTransaction;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#import "QNAPIClient.h"
#import "QNConstants.h"
#import "QNRequestBuilder.h"
#import "QNRequestSerializer.h"
#import "QNDevice.h"
#import "QNMapper.h"
#import "QNConstants.h"
#import "QNErrors.h"
#import "QNMapperObject.h"
#import "QNUtils.h"
Expand Down Expand Up @@ -75,7 +75,7 @@ - (void)attributionRequest:(QNAttributionProvider)provider
completion:(QNAPIClientCompletionHandler)completion {
NSDictionary *body = [self.requestSerializer attributionDataWithDict:data fromProvider:provider];
NSDictionary *resultData = [self enrichParameters:body];
NSURLRequest *request = [[self requestBuilder] makeAttributionRequestWith:body];
NSURLRequest *request = [[self requestBuilder] makeAttributionRequestWith:resultData];
return [self dataTaskWithRequest:request completion:completion];
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#import <Foundation/Foundation.h>
#import "Qonversion.h"

NS_ASSUME_NONNULL_BEGIN

@interface QNAttributionManager : NSObject

- (void)addAttributionData:(NSDictionary *)data fromProvider:(QNAttributionProvider)provider;
- (void)addAttributionData:(NSDictionary *)data fromProvider:(NSInteger)provider;

@end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ - (instancetype)init
return self;
}

- (void)addAttributionData:(NSDictionary *)data fromProvider:(QNAttributionProvider)provider {
- (void)addAttributionData:(NSDictionary *)data fromProvider:(NSInteger)provider {
double delayInSeconds = 5.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));

dispatch_after(popTime, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){

[_client attributionRequest:provider data:data completion:^(NSDictionary * _Nullable dict, NSError * _Nullable error) {
[self->_client attributionRequest:provider data:data completion:^(NSDictionary * _Nullable dict, NSError * _Nullable error) {
if (dict && [dict respondsToSelector:@selector(valueForKey:)]) {
QONVERSION_LOG(@"Attribution Request Log Response:\n%@", dict);
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
NSString *const keyQPlatform = @"iOS";
NSString *const keyQOSName = @"ios";

NSString *const keyQVersion = @"2.1.0";
NSString *const keyQVersion = @"'2.2.0";
NSString *const keyQUnknownLibrary = @"unknown";
NSString *const keyQUnknownVersion = @"unknown";
NSString *const keyQInternalUserID = @"keyQInternalUserID";
Expand Down
File renamed without changes.
94 changes: 92 additions & 2 deletions Sources/Services/QNDevice.m → Sources/Qonversion/QNDevice.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#import "QNDevice.h"
#import "QNConstants.h"
#if !TARGET_OS_OSX
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#import <net/if.h>
#import <net/if_dl.h>
#endif


#import <sys/sysctl.h>
#import <sys/types.h>
Expand Down Expand Up @@ -43,7 +50,15 @@ - (NSString *)appVersion {

- (NSString *)osVersion {
if (!_osVersion) {
_osVersion = [[UIDevice currentDevice] systemVersion];
#if !TARGET_OS_OSX
_osVersion = [[UIDevice currentDevice] systemVersion];
#else
NSOperatingSystemVersion systemVersion = [[NSProcessInfo processInfo] operatingSystemVersion];
_osVersion = [NSString stringWithFormat:@"%ld.%ld.%ld",
systemVersion.majorVersion,
systemVersion.minorVersion,
systemVersion.patchVersion];
#endif
}
return _osVersion;
}
Expand Down Expand Up @@ -278,7 +293,12 @@ + (NSString*)getAdvertiserID:(int) maxAttempts {
}

+ (NSString*)getVendorID:(int) maxAttempts {
NSString *identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
#if !TARGET_OS_OSX
NSString *identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
#else
NSString *identifier = [self getMacAddress];
#endif

if (identifier == nil && maxAttempts > 0) {
// Try again every 5 seconds
[NSThread sleepForTimeInterval:5.0];
Expand Down Expand Up @@ -450,4 +470,74 @@ + (NSString*)getDeviceModel {
if ([platform hasPrefix:@"Xserve"]) return @"Xserve";
return platform;
}

#if TARGET_OS_OSX
+ (NSString *)getMacAddress {
int mgmtInfoBase[6];
char *msgBuffer = NULL;
size_t length;
unsigned char macAddress[6];
struct if_msghdr *interfaceMsgStruct;
struct sockaddr_dl *socketStruct;
NSString *errorFlag = NULL;
bool msgBufferAllocated = false;

// Setup the management Information Base (mib)
mgmtInfoBase[0] = CTL_NET; // Request network subsystem
mgmtInfoBase[1] = AF_ROUTE; // Routing table info
mgmtInfoBase[2] = 0;
mgmtInfoBase[3] = AF_LINK; // Request link layer information
mgmtInfoBase[4] = NET_RT_IFLIST; // Request all configured interfaces

// With all configured interfaces requested, get handle index
if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0) {
errorFlag = @"if_nametoindex failure";
} else {
// Get the size of the data available (store in len)
if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0) {
errorFlag = @"sysctl mgmtInfoBase failure";
} else {
// Alloc memory based on above call
if ((msgBuffer = malloc(length)) == NULL) {
errorFlag = @"buffer allocation failure";
} else {
msgBufferAllocated = true;
// Get system information, store in buffer
if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0) {
errorFlag = @"sysctl msgBuffer failure";
}
}
}
}

// Before going any further...
if (errorFlag != NULL) {
AMPLITUDE_LOG(@"Cannot detect mac address. Error: %@", errorFlag);
if (msgBufferAllocated) {
free(msgBuffer);
}
return nil;
}

// Map msgbuffer to interface message structure
interfaceMsgStruct = (struct if_msghdr *) msgBuffer;

// Map to link-level socket structure
socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);

// Copy link layer address data in socket structure to an array
memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);

// Read from char array into a string object, into traditional Mac address format
NSString *macAddressString = [NSString stringWithFormat:@"%02X%02X%02X%02X%02X%02X",
macAddress[0], macAddress[1], macAddress[2],
macAddress[3], macAddress[4], macAddress[5]];

// Release the buffer memory
free(msgBuffer);

return macAddressString;
}
#endif

@end
File renamed without changes.
4 changes: 3 additions & 1 deletion Sources/Helpers/QNErrors.m → Sources/Qonversion/QNErrors.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ + (NSError *)errorFromTransactionError:(NSError *)error {
errorCode = QNErrorPrivacyAcknowledgementRequired; break;
case 10: // SKErrorUnauthorizedRequestData
errorCode = QNErrorUnauthorizedRequestData; break;
default:
errorCode = QNErrorUnknown; break;
}
}

Expand All @@ -64,7 +66,7 @@ + (NSError *)errorFromTransactionError:(NSError *)error {

+ (NSError *)errorFromURLDomainError:(NSError *)error {
QNError errorCode = QNErrorUnknown;
NSMutableDictionary *userInfo = @{};
NSMutableDictionary *userInfo = [NSMutableDictionary new];
userInfo[NSLocalizedDescriptionKey] = error.localizedDescription ?: @"";

if ([[error domain] isEqualToString:NSURLErrorDomain]) {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface QNKeeper : NSObject

+ (nullable NSString *)userID;
+ (void)setUserID:(NSString *)userID;

@end


NS_ASSUME_NONNULL_END
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1b8c87e

Please sign in to comment.