-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy pathCountlyConnectionManager.h
More file actions
124 lines (100 loc) · 4.62 KB
/
CountlyConnectionManager.h
File metadata and controls
124 lines (100 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// CountlyConnectionManager.h
//
// This code is provided under the MIT License.
//
// Please visit www.count.ly for more information.
#import <Foundation/Foundation.h>
#import "Resettable.h"
extern NSString* const kCountlyQSKeyAppKey;
extern NSString* const kCountlyQSKeyDeviceID;
extern NSString* const kCountlyQSKeyDeviceIDType;
extern NSString* const kCountlyQSKeySDKVersion;
extern NSString* const kCountlyQSKeySDKName;
extern NSString* const kCountlyQSKeyMethod;
extern NSString* const kCountlyQSKeyMetrics;
extern NSString* const kCountlyEndpointI;
extern NSString* const kCountlyEndpointO;
extern NSString* const kCountlyEndpointSDK;
extern NSString* const kCountlyEndpointFeedback;
extern NSString* const kCountlyEndpointWidget;
extern NSString* const kCountlyEndpointSurveys;
extern NSString* const kCountlyRCKeyKeys;
extern NSString* const kCountlyQSKeyTimestamp;
extern const NSInteger kCountlyGETRequestMaxLength;
@interface CountlyConnectionManager : NSObject <NSURLSessionDelegate, Resettable>
@property (nonatomic) NSString* appKey;
@property (nonatomic) NSString* host;
@property (nonatomic) NSURLSessionTask* connection;
@property (nonatomic) NSArray* pinnedCertificates;
@property (nonatomic) NSString* secretSalt;
@property (nonatomic) BOOL alwaysUsePOST;
@property (nonatomic) NSURLSessionConfiguration* URLSessionConfiguration;
@property (nonatomic) BOOL isTerminating;
+ (instancetype)sharedInstance;
- (void)recordMetrics:(nullable NSDictionary *)metricsOverride;
- (void)beginSession;
- (void)updateSession;
- (void)endSession;
- (void)sendEventsWithSaveIfNeeded;
- (void)sendEvents;
- (void)attemptToSendStoredRequests;
- (void)sendPushToken:(NSString *)token;
- (void)sendLocationInfo;
- (void)sendUserDetails:(NSString *)userDetails;
- (void)sendCrashReport:(NSString *)report immediately:(BOOL)immediately;
- (void)sendOldDeviceID:(NSString *)oldDeviceID;
- (void)sendAttribution;
- (void)sendDirectAttributionWithCampaignID:(NSString *)campaignID andCampaignUserID:(NSString *)campaignUserID;
- (void)sendAttributionData:(NSString *)attributionData;
- (void)sendIndirectAttribution:(NSDictionary *)attribution;
- (void)sendConsents:(NSString *)consents;
- (void)sendPerformanceMonitoringTrace:(NSString *)trace;
- (void)sendEnrollABRequestForKeys:(NSArray*)keys;
- (void)sendExitABRequestForKeys:(NSArray*)keys;
- (void)addDirectRequest:(NSDictionary<NSString *, NSString *> *)requestParameters;
- (void)addCustomNetworkRequestHeaders:(NSDictionary<NSString *, NSString *> *_Nullable)customHeaderValues;
- (void)proceedOnQueue;
- (NSString *)queryEssentials;
- (NSString *)appendChecksum:(NSString *)queryString;
- (BOOL)isSessionStarted;
#pragma mark - Request Callbacks
/**
* Callback block type for individual request results.
* @param response Response string from server (or error description if failed)
* @param success YES if request succeeded, NO if failed
*/
typedef void (^CLYRequestCallback)(NSString * _Nullable response, BOOL success);
/**
* Runnable block type for queue flush completion.
* @discussion Executed when all requests in the queue complete successfully.
*/
typedef void (^CLYQueueFlushRunnable)(void);
/**
* Adds a runnable to be executed when the request queue is successfully flushed.
* @discussion Multiple runnables can be registered and will all execute when queue becomes empty.
* @discussion Runnables are automatically removed after successful execution.
* @discussion Runnables only execute when ALL requests complete successfully.
* @param runnable Block to be executed when queue is successfully flushed
*/
- (void)addQueueFlushRunnable:(CLYQueueFlushRunnable _Nonnull)runnable;
/**
* Removes all registered queue flush runnables.
*/
- (void)clearQueueFlushRunnables;
/**
* Adds a request to the queue with an associated callback.
* @discussion The callback will be executed when this specific request completes.
* @discussion A unique callback ID will be automatically generated internally using UUID.
* @discussion Callback IDs are managed internally and cannot be accessed or modified by developers.
* @param queryString Query string for the request
* @param callback Block to be executed when this request completes
*/
- (void)addToQueueWithCallback:(NSString *)queryString callback:(CLYRequestCallback)callback;
/**
* Sends pending events with an associated callback.
* @discussion Used for Journey Trigger Events (JTE) to get notified when the events request succeeds.
* @discussion Serializes recorded events, adds them to queue with callback, and proceeds on queue.
* @param callback Block to be executed when the events request completes
*/
- (void)sendEventsWithCallback:(CLYRequestCallback)callback;
@end