Skip to content

Commit

Permalink
Unity Plugin v2.0.0 (Update iOS SDK to 7.2.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoliu-amp authored Jan 14, 2021
2 parents 9a228c5 + 46fb46f commit f381e39
Show file tree
Hide file tree
Showing 85 changed files with 2,816 additions and 705 deletions.
2 changes: 1 addition & 1 deletion Assets/Amplitude/Amplitude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class Amplitude {
private static readonly string UnityLibraryName = "amplitude-unity";
private static readonly string UnityLibraryVersion = "1.6.0";
private static readonly string UnityLibraryVersion = "2.0.0";

private static Dictionary<string, Amplitude> instances;
private static readonly object instanceLock = new object();
Expand Down
35 changes: 35 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPBubbleView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// AMPBubbleView.h
// Amplitude
//
// Copyright (c) 2020 Amplitude Inc. (https://amplitude.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

@interface AMPBubbleView : UIView

@end

NS_ASSUME_NONNULL_END

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
//
// AMPLocationManagerDelegate.m
// Copyright (c) 2014 Amplitude Inc. (https://amplitude.com/)
// AMPBubbleView.m
// Amplitude
//
// Copyright (c) 2020 Amplitude Inc. (https://amplitude.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -21,32 +23,38 @@
// THE SOFTWARE.
//

#import "AMPLocationManagerDelegate.h"
#import "Amplitude.h"

@implementation AMPLocationManagerDelegate
#import "AMPBubbleView.h"

@implementation AMPBubbleView

- (void)locationManager:(CLLocationManager*) manager didFailWithError:(NSError*) error {
- (instancetype)initWithCoder:(NSCoder *)coder {
self = [super initWithCoder:coder];

if (self) {
[self loadViewFromNib];
}

return self;
}

- (void)locationManager:(CLLocationManager*) manager didUpdateToLocation:(CLLocation*) newLocation fromLocation:(CLLocation*) oldLocation {
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];

if (self) {
[self loadViewFromNib];
}

return self;
}

- (void)locationManager:(CLLocationManager*) manager didChangeAuthorizationStatus:(CLAuthorizationStatus) status {
#if TARGET_OS_IPHONE
// kCLAuthorizationStatusAuthorized is deprecated in iOS 8. Add support for
// the new location authorization types if we're compiling for iOS 8 or higher.
#ifdef __IPHONE_8_0
if (status == kCLAuthorizationStatusAuthorizedAlways || status == kCLAuthorizationStatusAuthorizedWhenInUse) {
#else
if (status == kCLAuthorizationStatusAuthorized) {
#endif
#else
if (status == kCLAuthorizationStatusAuthorized) {
#endif
SEL updateLocation = NSSelectorFromString(@"updateLocation");
[Amplitude performSelector:updateLocation];
}
- (void)loadViewFromNib {
NSBundle *bundle = [NSBundle bundleForClass:[AMPBubbleView class]];
UINib *nib = [UINib nibWithNibName:@"AMPBubbleView" bundle:bundle];

NSArray *views = [nib instantiateWithOwner:self options:nil];
UIView *view = [views objectAtIndex:0];
view.frame = self.bounds;
[self addSubview:view];
}

@end

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

38 changes: 38 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPBubbleView.xib
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="AMPBubbleView"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<view contentMode="scaleToFill" id="Mmh-9r-w4b">
<rect key="frame" x="0.0" y="0.0" width="414" height="528"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo-button.png" translatesAutoresizingMaskIntoConstraints="NO" id="hmO-o9-Njq">
<rect key="frame" x="187" y="244" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="a6l-yI-MEY"/>
<constraint firstAttribute="height" constant="40" id="xHf-Rm-QMQ"/>
</constraints>
</imageView>
</subviews>
<viewLayoutGuide key="safeArea" id="lWT-B1-1eZ"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="hmO-o9-Njq" firstAttribute="centerY" secondItem="Mmh-9r-w4b" secondAttribute="centerY" id="Mym-Qv-9D3"/>
<constraint firstItem="hmO-o9-Njq" firstAttribute="centerX" secondItem="Mmh-9r-w4b" secondAttribute="centerX" id="kRW-Gm-aWN"/>
</constraints>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<point key="canvasLocation" x="111.59420289855073" y="-49.553571428571423"/>
</view>
</objects>
<resources>
<image name="logo-button.png" width="56" height="56"/>
</resources>
</document>
33 changes: 33 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPBubbleView.xib.meta

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// AMPLocationManagerDelegate.h
// Copyright (c) 2014 Amplitude Inc. (https://amplitude.com/)
// AMPConfigManager.h
// Copyright (c) 2020 Amplitude Inc. (https://amplitude.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand All @@ -22,14 +22,16 @@
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@interface AMPLocationManagerDelegate : NSObject <CLLocationManagerDelegate>
NS_ASSUME_NONNULL_BEGIN

- (void)locationManager:(CLLocationManager*) manager didFailWithError:(NSError*) error;
@interface AMPConfigManager : NSObject

- (void)locationManager:(CLLocationManager*) manager didUpdateToLocation:(CLLocation*) newLocation fromLocation:(CLLocation*) oldLocation;
@property (nonatomic, strong, readonly) NSString *ingestionEndpoint;

- (void)locationManager:(CLLocationManager*) manager didChangeAuthorizationStatus:(CLAuthorizationStatus) status;
+ (instancetype)sharedInstance;
- (void)refresh:(void(^)(void))completionHandler;

@end

NS_ASSUME_NONNULL_END
33 changes: 33 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConfigManager.h.meta

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

78 changes: 78 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConfigManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
//
// AMPConfigManager.m
// Copyright (c) 2020 Amplitude Inc. (https://amplitude.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

#import "AMPConfigManager.h"
#import "AMPConstants.h"

@interface AMPConfigManager ()

@property (nonatomic, strong, readwrite) NSString *ingestionEndpoint;

@end

@implementation AMPConfigManager

+ (instancetype)sharedInstance {
static id instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance = [[self alloc] init];
});
return instance;
}

- (instancetype)init {
if ((self = [super init])) {
self.ingestionEndpoint = kAMPEventLogUrl;
}
return self;
}

- (void)refresh:(void(^)(void))completionHandler {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:kAMPDyanmicConfigUrl]];

NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request
completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (!error) {
NSError *jsonError = nil;
NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&jsonError];
NSString *urlString = [dictionary objectForKey:@"ingestionEndpoint"];
if (urlString) {
NSString *ingestionEndpoint = [NSString stringWithFormat:@"https://%@", urlString];

NSURL *url = [NSURL URLWithString:ingestionEndpoint];
if (url && url.scheme && url.host) {
self.ingestionEndpoint = ingestionEndpoint;
}
}
} else {
// Error
}

completionHandler();
}];
[task resume];
}

@end
33 changes: 33 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConfigManager.m.meta

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

1 change: 1 addition & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern NSString *const kAMPPlatform;
extern NSString *const kAMPOSName;
extern NSString *const kAMPEventLogDomain;
extern NSString *const kAMPEventLogUrl;
extern NSString *const kAMPDyanmicConfigUrl;
extern NSString *const kAMPDefaultInstance;
extern const int kAMPApiVersion;
extern const int kAMPDBVersion;
Expand Down
Loading

0 comments on commit f381e39

Please sign in to comment.